]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: avoid memory leak in bgp flowspec list, plus usage of bool
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 20 Aug 2018 16:32:00 +0000 (18:32 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 22 Aug 2018 12:35:59 +0000 (14:35 +0200)
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>
bgpd/bgp_flowspec_vty.c
bgpd/bgp_route.c

index 0f06de3ebea33c93349e3c86018f47c97c590ee3..1f5f685890643a23d64255c05df188f8e428345d 100644 (file)
@@ -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,17 +347,17 @@ 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_all_node(list_bpm);
+                       list_delete_and_null(&list_bpm);
                } else
                        vty_out(vty, "\tnot installed in PBR\n");
        }
index c890435247badb271b42cf33a4a2e8acd7a1057a..ac688d72ab02761f070e63814df9d7a7e5ede8f1 100644 (file)
@@ -181,8 +181,7 @@ static void bgp_info_extra_free(struct bgp_info_extra **extra)
                (*extra)->damp_info = NULL;
 
                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);