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>
This commit is contained in:
Donald Sharp 2018-05-21 20:13:27 -04:00
parent c93a3b77e6
commit 0e42e319d5

View 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();