bgpd: Fix EVPN-MH route cleanup race condition during interfaces flap - #20710
Merged
ton31337 merged 1 commit intoMar 3, 2026
Merged
Conversation
Greptile OverviewGreptile SummaryThis PR fixes a race condition in EVPN multi-homing (MH) that causes stale route entries when interfaces are flapped. The issue occurs when a local ES add event arrives before the VNI-VRF association is available, causing route cleanup to be skipped. The fix introduces a deferred cleanup mechanism using a
Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant System
participant ES as Ethernet Segment (ES)
participant ESEVI as ES-EVI
participant VRF
Note over User,VRF: Interface Flap Scenario (ifdown/ifup)
User->>System: ifdown br_default
System->>ES: Deactivate ES
System->>ESEVI: Remove local host interfaces
Note over ESEVI: Multi-homed hosts become remote<br/>Create vxlan routes for hosts
User->>System: ifup br_default
System->>ES: ES becomes active (local)
ES->>ESEVI: bgp_evpn_local_es_evi_add()
alt VRF not yet available
ESEVI->>ESEVI: bgp_evpn_local_es_evi_uninstall_local_routes_in_vrfs()
Note over ESEVI: es_vrf is NULL
ESEVI->>ESEVI: Set sweep_local_routes = true
Note over ESEVI: Defer route cleanup
end
System->>VRF: VNI-VRF association received
VRF->>ESEVI: bgp_evpn_es_evi_vrf_ref()
ESEVI->>ESEVI: bgp_evpn_es_vrf_ref()
Note over ESEVI: es_vrf is now set
alt sweep_local_routes is true
ESEVI->>ESEVI: Check sweep_local_routes && es_vrf
ESEVI->>ESEVI: Set sweep_local_routes = false
ESEVI->>ESEVI: bgp_evpn_local_es_evi_uninstall_local_routes_in_vrfs()
Note over ESEVI: Clean up stale vxlan routes<br/>Routes now point to local hosts
end
|
krishna-samy
marked this pull request as draft
February 5, 2026 09:53
krishna-samy
force-pushed
the
krishna/evpn-mh-stale-route-fix
branch
from
February 5, 2026 10:03
6189f13 to
91f2e95
Compare
krishna-samy
marked this pull request as ready for review
February 5, 2026 10:06
Contributor
Author
|
ci:rerun |
1 similar comment
Contributor
Author
|
ci:rerun |
ton31337
reviewed
Feb 9, 2026
| es_evi->es = es; | ||
| es_evi->vpn = vpn; | ||
| es_evi->flags = 0; | ||
| es_evi->sweep_local_routes = false; |
Member
There was a problem hiding this comment.
Can't we just reuse es_evi->flags?
Contributor
Author
There was a problem hiding this comment.
Yes. Agree
updated the changes, please check.
Issue: In EVPN-MH setup, when all the interfaces are flapped(using 'ifdown/ifup'), the VTEP ends up having stale route entries(via vxlan) to the multi-homed hosts even though they are connected MH hosts. The events sequencing is as below: ifdown br_default: - Brings down all the host facing interfaces/vni/es - So, new route entries(via vxlan) created for the hosts, because the multi-homed hosts(before ifdown) are not connected hosts now. ifup br_default: - The ES becomes active now. - We should clear/uninstall the above created routes as the hosts are multi-homed now. This does not happen. - This is because of the events sequencing where a local ES add event arrives bgpd before before the VNI-VRF association becomes available. - When this happens, the current code that handles the es_evi add is skipping the unistall_local_routes (bgp_evpn_local_es_evi_add->bgp_evpn_local_es_evi_unistall_local_routes_in_vrfs). - This is because the explicit check 'if(es_evi->es_vrf)' fails in this path as the VRF mapping is not yet received. - Also, we never go for an attempt to clear the global routes in the same ES when the 'es_evi->es_vrf' mapping is received later. - So, This causes stale routes in the system and traffic drop as well. Fix: Add 'sweep_local_routes' flag in es-evi to track when cleanup is needed but VRF is not yet available. Once we receive vni-vrf update, clean up the local routes that were installed earlier for remote ES(now local ES hosts). Signed-off-by: Krishnasamy R <krishnasamyr@nvidia.com>
krishna-samy
force-pushed
the
krishna/evpn-mh-stale-route-fix
branch
from
February 10, 2026 13:10
91f2e95 to
efc795a
Compare
Contributor
Author
|
@ton31337 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue:
In EVPN-MH setup, when all the interfaces are flapped(using 'ifdown/ifup'), the VTEP ends up having stale route entries(via vxlan) to the multi-homed hosts even though they are connected MH hosts.
The events sequencing is as below:
ifdown br_default:
ifup br_default:
Fix:
Add 'sweep_local_routes' flag in es-evi to track when cleanup is needed but VRF is not yet available.
Once we receive vni-vrf update, clean up the local routes that were installed earlier for remote ES(now local ES hosts).