Skip to content

Commit

Permalink
babel: Clean babel related config on daemon stop
Browse files Browse the repository at this point in the history
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 <y.kholod@vyos.io>
  • Loading branch information
Yaroslav Kholod committed Dec 23, 2024
1 parent 61ba8b9 commit 74fdb08
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions babeld/babel_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions babeld/babel_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions babeld/babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand 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);
Expand Down

0 comments on commit 74fdb08

Please sign in to comment.