diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 7645c67734..0f899d9617 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -15777,6 +15777,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) diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index bde0580d6c..474e229575 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -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, diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 74f79cdd72..2f234e3a5a 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -4240,6 +4240,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; }