summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-08-22 00:46:42 +0200
committerGitHub <noreply@github.com>2018-08-22 00:46:42 +0200
commit962709b8d24b8d36cb127a27f6d6c5fc28d0798f (patch)
tree58d4d15aae770a7a13963892f109719ce3f96a56 /bgpd
parentMerge pull request #2876 from donaldsharp/lsa_new_and_data (diff)
parentbgpd: pbr entry log message changed to zlog_debug (diff)
downloadfrr-962709b8d24b8d36cb127a27f6d6c5fc28d0798f.tar.xz
frr-962709b8d24b8d36cb127a27f6d6c5fc28d0798f.zip
Merge pull request #2877 from pguibert6WIND/fixup_fs_master
bgpd: avoid memory leak in bgp flowspec list, plus usage of bool
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_flowspec_vty.c10
-rw-r--r--bgpd/bgp_pbr.c13
-rw-r--r--bgpd/bgp_route.c3
3 files changed, 12 insertions, 14 deletions
diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c
index f8c061320..31d2c540f 100644
--- a/bgpd/bgp_flowspec_vty.c
+++ b/bgpd/bgp_flowspec_vty.c
@@ -335,7 +335,7 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
struct listnode *node;
struct bgp_pbr_match_entry *bpme;
struct bgp_pbr_match *bpm;
- int unit = 0;
+ bool list_began = false;
struct list *list_bpm;
list_bpm = list_new();
@@ -347,14 +347,14 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
if (listnode_lookup(list_bpm, bpm))
continue;
listnode_add(list_bpm, bpm);
- if (unit == 0)
+ if (!list_began) {
vty_out(vty, " (");
- else
+ list_began = true;
+ } else
vty_out(vty, ", ");
vty_out(vty, "%s", bpm->ipset_name);
- unit++;
}
- if (unit)
+ if (list_began)
vty_out(vty, ")");
vty_out(vty, "\n");
list_delete_and_null(&list_bpm);
diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c
index 129c143a6..b182fde1e 100644
--- a/bgpd/bgp_pbr.c
+++ b/bgpd/bgp_pbr.c
@@ -1680,7 +1680,7 @@ static void bgp_pbr_dump_entry(struct bgp_pbr_filter *bpf, bool add)
? "!" : "",
bpf->dscp->val);
}
- zlog_info("BGP: %s FS PBR from %s to %s, %s %s",
+ zlog_debug("BGP: %s FS PBR from %s to %s, %s %s",
add ? "adding" : "removing",
bpf->src == NULL ? "<all>" :
prefix2str(bpf->src, bufsrc, sizeof(bufsrc)),
@@ -1807,7 +1807,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
bgp_pbr_match_alloc_intern);
/* new, then self allocate ipset_name and unique */
- if (bpm && bpm->unique == 0) {
+ if (bpm->unique == 0) {
bpm->unique = ++bgp_pbr_match_counter_unique;
/* 0 value is forbidden */
sprintf(bpm->ipset_name, "match%p", bpm);
@@ -1838,10 +1838,9 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
temp2.src_port_max = src_port ? src_port->max_port : 0;
temp2.dst_port_max = dst_port ? dst_port->max_port : 0;
temp2.proto = bpf->protocol;
- if (bpm)
- bpme = hash_get(bpm->entry_hash, &temp2,
- bgp_pbr_match_entry_alloc_intern);
- if (bpme && bpme->unique == 0) {
+ bpme = hash_get(bpm->entry_hash, &temp2,
+ bgp_pbr_match_entry_alloc_intern);
+ if (bpme->unique == 0) {
bpme->unique = ++bgp_pbr_match_entry_counter_unique;
/* 0 value is forbidden */
bpme->backpointer = bpm;
@@ -1853,7 +1852,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
bpme_found = true;
/* already installed */
- if (bpme_found && bpme) {
+ if (bpme_found) {
struct bgp_info_extra *extra = bgp_info_extra_get(binfo);
if (extra && extra->bgp_fs_pbr &&
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 041049d05..eedfe7503 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -198,8 +198,7 @@ static void bgp_info_extra_free(struct bgp_info_extra **extra)
bgp_unlock(e->bgp_orig);
if ((*extra)->bgp_fs_pbr)
- list_delete_all_node((*extra)->bgp_fs_pbr);
- (*extra)->bgp_fs_pbr = NULL;
+ list_delete_and_null(&((*extra)->bgp_fs_pbr));
XFREE(MTYPE_BGP_ROUTE_EXTRA, *extra);
*extra = NULL;