From aab5893aa68016935b84d058f7fb8648383639c9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 2 Apr 2020 11:16:50 -0400 Subject: [PATCH] zebra: Don't kill the global rtadv socket when a vrf is deleted The rtadv code has two types of sockets: a) namespace -> Where each zvrf get's it's own socket b) vrf lite -> Where we get 1 socket for everything When we were terminating a vrf we were *always* killing the (b) socket. This is a mistake in that other vrf's may need to be communicating. Modify the code on vrf shutdown to only disable that vrf's event processing and when we actually terminate we shut the socket. Signed-off-by: Donald Sharp --- zebra/main.c | 1 + zebra/rtadv.c | 14 ++++++++++---- zebra/rtadv.h | 3 ++- zebra/zebra_vrf.c | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/zebra/main.c b/zebra/main.c index 4673ec53e4..306372ccdb 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -174,6 +174,7 @@ static void sigint(void) work_queue_free_and_null(&zrouter.lsp_process_q); vrf_terminate(); + rtadv_terminate(); ns_walk_func(zebra_ns_early_shutdown); zebra_ns_notify_close(); diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 60ac471b5a..4a553a4269 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -2371,20 +2371,26 @@ void rtadv_init(struct zebra_vrf *zvrf) } } -void rtadv_terminate(struct zebra_vrf *zvrf) +void rtadv_vrf_terminate(struct zebra_vrf *zvrf) { rtadv_event(zvrf, RTADV_STOP, 0); if (zvrf->rtadv.sock >= 0) { close(zvrf->rtadv.sock); zvrf->rtadv.sock = -1; - } else if (zrouter.rtadv_sock >= 0) { - close(zrouter.rtadv_sock); - zrouter.rtadv_sock = -1; } + zvrf->rtadv.adv_if_count = 0; zvrf->rtadv.adv_msec_if_count = 0; } +void rtadv_terminate(void) +{ + if (zrouter.rtadv_sock >= 0) { + close(zrouter.rtadv_sock); + zrouter.rtadv_sock = -1; + } +} + void rtadv_cmd_init(void) { hook_register(zebra_if_extra_info, nd_dump_vty); diff --git a/zebra/rtadv.h b/zebra/rtadv.h index 64b28cbfd6..68a5bbcdbe 100644 --- a/zebra/rtadv.h +++ b/zebra/rtadv.h @@ -153,7 +153,8 @@ typedef enum { } ipv6_nd_suppress_ra_status; extern void rtadv_init(struct zebra_vrf *zvrf); -extern void rtadv_terminate(struct zebra_vrf *zvrf); +extern void rtadv_vrf_terminate(struct zebra_vrf *zvrf); +extern void rtadv_terminate(void); extern void rtadv_stop_ra(struct interface *ifp); extern void rtadv_stop_ra_all(void); extern void rtadv_cmd_init(void); diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index dfa7d5ae92..ee1e251a69 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -178,7 +178,7 @@ static int zebra_vrf_disable(struct vrf *vrf) zebra_vxlan_vrf_disable(zvrf); #if defined(HAVE_RTADV) - rtadv_terminate(zvrf); + rtadv_vrf_terminate(zvrf); #endif /* Inform clients that the VRF is now inactive. This is a -- 2.39.5