Skip to content

bgpd: Fix nht to properly notice a change - #20986

Merged
riw777 merged 1 commit into
FRRouting:masterfrom
donaldsharp:bgp_nhc_problems_in_evpn
Mar 3, 2026
Merged

bgpd: Fix nht to properly notice a change#20986
riw777 merged 1 commit into
FRRouting:masterfrom
donaldsharp:bgp_nhc_problems_in_evpn

Conversation

@donaldsharp

Copy link
Copy Markdown
Member

commit: 8dcd0a6 broke path handling in some rare cases. This can be especially seen in bgp evpn processing when a path transitions from !valid to valid. The bgp_evpn_rt5_addpath code is failing occassionally because of this change. Modify the code to intentionally also call bgp_process when the old_path_valid is not the same as the new path being valid.

commit: 8dcd0a6 broke
path handling in some rare cases.  This can be especially
seen in bgp evpn processing when a path transitions from !valid
to valid.  The bgp_evpn_rt5_addpath code is failing occassionally
because of this change.  Modify the code to intentionally also
call bgp_process when the old_path_valid is not the same
as the new path being valid.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
@greptile-apps

greptile-apps Bot commented Mar 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a regression introduced by commit 8dcd0a6b9cdbfac47eea2cf2100badf7744dbf98 in bgpd/bgp_nht.c. The evaluate_paths() function already correctly detected when a path transitioned between valid and invalid states (updating flags, calling aggregate and EVPN/VPN helpers, and firing the bgp_nht_path_update hook), but the subsequent call to bgp_process() β€” which triggers bestpath re-evaluation β€” was only gated on BGP_NEXTHOP_METRIC_CHANGED or BGP_NEXTHOP_CHANGED. When neither of those change flags was set but validity still changed (e.g. a path going from !valid to valid during BGP EVPN RT5 addpath processing), bgp_process() was never invoked and the downstream state became inconsistent.

Changes:

  • In bgpd/bgp_nht.c, the condition guarding bgp_process() now also checks old_path_valid != bnc_is_valid_nexthop, ensuring re-evaluation is always triggered on any validity transition.

Confidence Score: 5/5

  • This PR is safe to merge β€” it is a targeted one-liner bug fix with clear, well-understood intent.
  • The change is minimal and surgical: a single additional OR condition added to the bgp_process() guard. The condition (old_path_valid != bnc_is_valid_nexthop) is already evaluated identically just two lines above for the hook call, so there is no risk of computing it differently. The fix restores symmetry between the hook invocation and the bgp_process invocation, which is the logical correct behavior. No new variables or data structures are introduced.
  • No files require special attention.

Important Files Changed

Filename Overview
bgpd/bgp_nht.c Adds old_path_valid != bnc_is_valid_nexthop as a condition to trigger bgp_process(), ensuring path re-evaluation occurs whenever nexthop validity changes even if metric/nexthop content flags are not set.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[evaluate_paths: iterate paths on bnc] --> B[Record old_path_valid\nfrom BGP_PATH_VALID flag]
    B --> C{old_path_valid\n!= bnc_is_valid_nexthop?}
    C -- Yes --> D[Update BGP_PATH_VALID flag\nincrement/decrement aggregates\nEVPN import/unimport\nVPN leak update/withdraw]
    D --> E[hook_call bgp_nht_path_update]
    C -- No --> F[Skip flag update]
    E --> G{Trigger bgp_process?}
    F --> G
    G -- "old_path_valid != bnc_is_valid_nexthop\nOR BGP_NEXTHOP_METRIC_CHANGED\nOR BGP_NEXTHOP_CHANGED" --> H[bgp_process\nre-evaluate bestpath]
    G -- None of the above --> I[Skip bgp_process]

    style D fill:#d4edda
    style H fill:#d4edda
    style G fill:#fff3cd
Loading

Last reviewed commit: ae614f4

@ton31337

ton31337 commented Mar 3, 2026

Copy link
Copy Markdown
Member

@Mergifyio backport dev/10.6

@mergify

mergify Bot commented Mar 3, 2026

Copy link
Copy Markdown

backport dev/10.6

βœ… Backports have been created

Details

@ton31337 ton31337 added this to the 10.6 milestone Mar 3, 2026

@riw777 riw777 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@riw777
riw777 merged commit fc20023 into FRRouting:master Mar 3, 2026
22 checks passed
donaldsharp added a commit that referenced this pull request Mar 4, 2026
bgpd: Fix nht to properly notice a change (backport #20986)
@donaldsharp
donaldsharp deleted the bgp_nhc_problems_in_evpn branch April 29, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants