diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-05-22 02:13:27 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-06-12 21:12:48 +0200 |
commit | 0e42e319d53ed3a4ffed4fc074f486974b4a4f7e (patch) | |
tree | 82411e9e2bf2126e24f4429b57b470d994c696f9 /bgpd/bgp_main.c | |
parent | bgpd: Move extra free code and fix a bug. (diff) | |
download | frr-0e42e319d53ed3a4ffed4fc074f486974b4a4f7e.tar.xz frr-0e42e319d53ed3a4ffed4fc074f486974b4a4f7e.zip |
bgpd: Fix crash when shutdown
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>
Diffstat (limited to 'bgpd/bgp_main.c')
-rw-r--r-- | bgpd/bgp_main.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index acb4272cd..1740f3d1d 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -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(); |