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 23, 2024
1 parent 61ba8b9 commit 46919e9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -15778,6 +15778,30 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
return CMD_SUCCESS;
}

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

for (afi=AFI_IP;afi<AFI_MAX;afi++) {
for (safi=SAFI_UNICAST;safi<SAFI_MAX;safi++) {
for (dest = bgp_table_top(bgp_distance_table[afi][safi]); dest;
dest = bgp_route_next(dest)) {
bdistance = bgp_dest_get_bgp_distance_info(dest);
XFREE(MTYPE_AS_LIST, bdistance->access_list);
bgp_distance_free(bdistance);

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

return CMD_SUCCESS;
}

/* 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 @@ -787,6 +787,7 @@ extern void bgp_clear_stale_route(struct peer *, afi_t, safi_t);
extern void bgp_set_stale_route(struct peer *peer, afi_t afi, safi_t safi);
extern bool bgp_outbound_policy_exists(struct peer *, struct bgp_filter *);
extern bool bgp_inbound_policy_exists(struct peer *, struct bgp_filter *);
int bgp_address_family_distance_clean();

extern struct bgp_dest *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
safi_t safi, 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_clean();

return 0;
}

Expand Down

0 comments on commit 46919e9

Please sign in to comment.