From 74fdb08ea2f2ead0f02ed6e57d7ddf9701c6a35e Mon Sep 17 00:00:00 2001 From: Yaroslav Kholod Date: Mon, 23 Dec 2024 13:06:57 +0200 Subject: [PATCH] babel: Clean babel related config on daemon stop When deactivating babel no router babel and later re-enabling it router babel the previous configuration is still in place. Steps to reproduce: Enable babel Configure babel Disable babel with "no router babel" Verify config Expected correct behavior: No config present Signed-off-by: Yaroslav Kholod --- babeld/babel_interface.c | 3 +-- babeld/babel_interface.h | 1 + babeld/babeld.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index b83c7b1908ec..b92a0e2145a0 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -35,7 +35,6 @@ DEFINE_MTYPE_STATIC(BABELD, BABEL_IF, "Babel Interface"); static int babel_enable_if_lookup (const char *ifname); static int babel_enable_if_add (const char *ifname); -static int babel_enable_if_delete (const char *ifname); static int interface_recalculate(struct interface *ifp); static int interface_reset(struct interface *ifp); static int babel_if_new_hook (struct interface *ifp); @@ -196,7 +195,7 @@ babel_enable_if_add (const char *ifname) } /* Delete interface from babel_enable_if. */ -static int +int babel_enable_if_delete (const char *ifname) { int babel_enable_if_index; diff --git a/babeld/babel_interface.h b/babeld/babel_interface.h index ab08ded91a1c..474b4f4915d0 100644 --- a/babeld/babel_interface.h +++ b/babeld/babel_interface.h @@ -117,5 +117,6 @@ int is_interface_ll_address(struct interface *ifp, const unsigned char *address) void babel_interface_close_all(void); extern int babel_enable_if_config_write (struct vty *); +int babel_enable_if_delete (const char *ifname); #endif diff --git a/babeld/babeld.c b/babeld/babeld.c index 1d2f60e3ada8..9abd247ae741 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -301,6 +301,10 @@ babel_initial_noise(void) /* Delete all the added babel routes, make babeld only speak to zebra. */ void babel_clean_routing_process(void) { + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); + struct interface *ifp = NULL; + int type = ZEBRA_ROUTE_ALL; + flush_all_routes(); babel_interface_close_all(); @@ -310,6 +314,17 @@ void babel_clean_routing_process(void) resend_delay = BABEL_DEFAULT_RESEND_DELAY; change_smoothing_half_life(BABEL_DEFAULT_SMOOTHING_HALF_LIFE); + /* Clean babel network interfaces */ + FOR_ALL_INTERFACES(vrf, ifp) { + babel_enable_if_delete(ifp->name); + } + + /* Disable babel redistribution */ + for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { + zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, family2afi(AF_INET), type, 0, VRF_DEFAULT); + zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, family2afi(AF_INET6), type, 0, VRF_DEFAULT); + } + /* cancel events */ event_cancel(&babel_routing_process->t_read); event_cancel(&babel_routing_process->t_update);