Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -5377,7 +5377,8 @@ static void evpn_mpattr_encode_type5(struct stream *s, const struct prefix *p,
*
* NOTE: NO need to pop the VPN routes in two cases
* 1) In free_vni_entry
* - Called by bgp_free()->bgp_evpn_cleanup().
* - Called by bgp_free()->bgp_evpn_cleanup() or
* bgp_delete()->bgp_evpn_cleanup() when terminating.
* - Since bgp_delete is called before bgp_free and we pop all the dest
* pertaining to bgp under delete.
* 2) evpn_delete_vni() when user configures "no vni" since the withdraw
Expand Down Expand Up @@ -7770,6 +7771,10 @@ void bgp_evpn_cleanup_on_disable(struct bgp *bgp)
*/
void bgp_evpn_cleanup(struct bgp *bgp)
{
/* Guard against double-call during termination */
if (!bgp->vnihash)
return;

hash_iterate(bgp->vnihash,
(void (*)(struct hash_bucket *, void *))free_vni_entry,
bgp);
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -8030,7 +8030,7 @@ void bgp_cleanup_routes(struct bgp *bgp)
/*
* VPN and ENCAP and EVPN tables are two-level (RD is top level)
*/
if (safi != SAFI_MPLS_VPN && IS_BGP_INSTANCE_HIDDEN(bgp))
if (safi != SAFI_MPLS_VPN && IS_BGP_INSTANCE_HIDDEN(bgp) && !bm->terminating)
continue;

for (dest = bgp_table_top(bgp->rib[afi][safi]); dest; dest = bgp_route_next(dest)) {
Expand Down
8 changes: 8 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4590,6 +4590,14 @@ int bgp_delete(struct bgp *bgp)

bgp_cleanup_routes(bgp);

if (bm->terminating)
/*
* Release EVPN VNI bgp_lock references so the
* subsequent bgp_unlock() can drive refcount to
* zero and trigger bgp_free().
*/
bgp_evpn_cleanup(bgp);

for (afi = 0; afi < AFI_MAX; ++afi) {
if (!bgp->vpn_policy[afi].import_redirect_rtlist)
continue;
Expand Down
Loading