diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2018-08-20 18:32:00 +0200 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2018-08-21 18:30:26 +0200 |
commit | 503d1ec6eb5a505c57b78a65a9c7ea94b932355e (patch) | |
tree | 7905c1cdbd4b7df31cf68f8a9f88cf17682a8930 /bgpd | |
parent | Merge pull request #2829 from donaldsharp/more_upstream (diff) | |
download | frr-503d1ec6eb5a505c57b78a65a9c7ea94b932355e.tar.xz frr-503d1ec6eb5a505c57b78a65a9c7ea94b932355e.zip |
bgpd: avoid memory leak in bgp flowspec list, plus usage of bool
Avoid memory leak in bgp flowspec list.
Usage of bool parameter instead of int, to handle the number of entries
PBR.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_flowspec_vty.c | 10 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 3 |
2 files changed, 6 insertions, 7 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_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; |