Skip to content

Commit

Permalink
BGP: Clean address-family config on daemon restart
Browse files Browse the repository at this point in the history
When stopping and restarting BGP daemon part of the configuration
remains. It should be cleared.
Particulary those are address-family parametes, like: distance,
ead-es-frag, disable-ead-evi-rx, disable-ead-evi-tx.

Signed-off-by: Yaroslav Kholod <[email protected]>
  • Loading branch information
Yaroslav Kholod committed Dec 30, 2024
1 parent 61ba8b9 commit 663281c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -15778,6 +15778,28 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
return CMD_SUCCESS;
}

void bgp_address_family_distance_delete(void)
{
afi_t afi = AFI_UNSPEC;
safi_t safi = SAFI_UNSPEC;
struct bgp_dest *dest = NULL;
struct bgp_distance *bdistance = NULL;

FOREACH_AFI_SAFI (afi, safi) {
for (dest = bgp_table_top(bgp_distance_table[afi][safi]); dest;
dest = bgp_route_next(dest)) {
if (!bgp_dest_has_bgp_path_info_data(dest))
continue;
bdistance = bgp_dest_get_bgp_distance_info(dest);
XFREE(MTYPE_AS_LIST, bdistance->access_list);
bgp_distance_free(bdistance);

bgp_dest_set_bgp_distance_info(dest, NULL);
bgp_dest_unlock_node(dest);
}
}
}

/* Apply BGP information to distance method. */
uint8_t bgp_distance_apply(const struct prefix *p, struct bgp_path_info *pinfo,
afi_t afi, safi_t safi, struct bgp *bgp)
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ extern void bgp_redistribute_withdraw(struct bgp *, afi_t, int, unsigned short);

extern void bgp_static_add(struct bgp *);
extern void bgp_static_delete(struct bgp *);
extern void bgp_address_family_distance_delete(void);
extern void bgp_static_redo_import_check(struct bgp *);
extern void bgp_purge_static_redist_routes(struct bgp *bgp);
extern void bgp_static_update(struct bgp *bgp, const struct prefix *p,
Expand Down
8 changes: 8 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4237,6 +4237,14 @@ int bgp_delete(struct bgp *bgp)
}
}

/* Clean BGP address family parameters */
bgp_mh_info->ead_evi_rx = BGP_EVPN_MH_EAD_EVI_RX_DEF;
bgp_evpn_switch_ead_evi_rx();
bgp_mh_info->ead_evi_tx = BGP_EVPN_MH_EAD_EVI_TX_DEF;
bgp_mh_info->evi_per_es_frag = BGP_EVPN_MAX_EVI_PER_ES_FRAG;

bgp_address_family_distance_delete();

return 0;
}

Expand Down

0 comments on commit 663281c

Please sign in to comment.