]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fix crash when shutdown
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 22 May 2018 00:13:27 +0000 (20:13 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 12 Jun 2018 19:12:48 +0000 (15:12 -0400)
The process of BGP shutdown hard free's memory irrelevant to
the fact that another process may be using that memory still
in route leaking scenario's.

As a temporary fix find the default instance and free it
last.

Ticket: CM-21068
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_main.c

index acb4272cd1ff4179cb5ec876b3f1dcde90135904..1740f3d1db7d71cbd0a121d29eade589436b7e3e 100644 (file)
@@ -168,7 +168,7 @@ void sigusr1(void)
 */
 static __attribute__((__noreturn__)) void bgp_exit(int status)
 {
-       struct bgp *bgp;
+       struct bgp *bgp, *bgp_default;
        struct listnode *node, *nnode;
 
        /* it only makes sense for this to be called on a clean exit */
@@ -180,9 +180,15 @@ static __attribute__((__noreturn__)) void bgp_exit(int status)
 
        bgp_close();
 
+       bgp_default = bgp_get_default();
+
        /* reverse bgp_master_init */
-       for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp))
+       for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) {
+               if (bgp_default == bgp)
+                       continue;
                bgp_delete(bgp);
+       }
+       bgp_delete(bgp_default);
 
        /* reverse bgp_dump_init */
        bgp_dump_finish();