Skip to content

bgpd: fix premature deletion of already-stale routes during GR clearing - #20768

Merged
ton31337 merged 2 commits into
FRRouting:masterfrom
miteshkanjariya:mkanjariya/bgp_gr_stale_flag_fix
Feb 13, 2026
Merged

bgpd: fix premature deletion of already-stale routes during GR clearing#20768
ton31337 merged 2 commits into
FRRouting:masterfrom
miteshkanjariya:mkanjariya/bgp_gr_stale_flag_fix

Conversation

@miteshkanjariya

Copy link
Copy Markdown
Contributor
When a peer goes down with GR enabled, routes already marked
BGP_PATH_STALE were incorrectly deleted instead of being preserved
for the current GR cycle. Remove the BGP_PATH_STALE check from both
bgp_clear_route_node() and clearing_clear_one_pi() so that stale
routes are re-marked rather than removed. Stale route cleanup remains
handled by bgp_clear_stale_route() on timer expiry.

Signed-off-by: Mitesh Kanjariyamkanjariya@nvidia.com

@miteshkanjariya
miteshkanjariya force-pushed the mkanjariya/bgp_gr_stale_flag_fix branch 2 times, most recently from 9094a1b to 76a130c Compare February 10, 2026 21:21
@greptile-apps

greptile-apps Bot commented Feb 10, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

Fixed premature deletion of already-stale BGP routes during Graceful Restart (GR) clearing by removing BGP_PATH_STALE checks from bgp_clear_route_node() and clearing_clear_one_pi().

Key changes:

  • Routes already marked BGP_PATH_STALE (from prior enhanced refresh or GR cycles) are now re-marked stale instead of being deleted during a new GR cycle
  • Stale route cleanup remains properly handled by bgp_clear_stale_route() on timer expiry
  • Added comprehensive test case that triggers enhanced-refresh (BoRR) to mark routes stale, then kills bgpd to verify already-stale routes are preserved during GR
  • Test configurations added for routers r5 and r6 with GR enabled

Impact:
This fix ensures correct behavior when a peer goes down with GR enabled - routes that were already stale are preserved for the current GR cycle rather than being prematurely removed.

Confidence Score: 5/5

  • This PR is safe to merge - it fixes a clear bug in GR handling with minimal, well-understood changes
  • The fix is surgical and correct: removing the BGP_PATH_STALE check allows already-stale routes to be re-marked rather than deleted during GR cycles. The logic is sound - stale route cleanup is properly delegated to bgp_clear_stale_route() on timer expiry. Comprehensive test coverage validates the fix.
  • No files require special attention - all changes are straightforward and well-tested

Important Files Changed

Filename Overview
bgpd/bgp_route.c Removes BGP_PATH_STALE check from two functions to prevent premature deletion of already-stale routes during GR cycles
tests/topotests/bgp_gr_restart_retain_routes/test_bgp_gr_preserve_already_stale_routes.py Adds test case that triggers enhanced-refresh to mark routes stale, then kills bgpd to verify already-stale routes are preserved during GR

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@miteshkanjariya
miteshkanjariya force-pushed the mkanjariya/bgp_gr_stale_flag_fix branch 3 times, most recently from 6582868 to b340234 Compare February 10, 2026 22:26
@miteshkanjariya

Copy link
Copy Markdown
Contributor Author

ci:rerun

1 similar comment
@miteshkanjariya

Copy link
Copy Markdown
Contributor Author

ci:rerun

@ton31337 ton31337 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.

Is this broken after c527882?

@miteshkanjariya

Copy link
Copy Markdown
Contributor Author

Is this broken after c527882?

yes, this surfaced as a result of the batch clearing fix. I had created another MR in that code path: #20738.

But this fix should be made regardless of that issue, as we are deleting a route in the GR code flow if it was previously marked stale.

Add a topotest which test that already stale paths are preserved during
bgp gr.

Ticket: RM#4856402

Signed-off-by: Mitesh Kanjariya <mkanjariya@nvidia.com>
When a peer goes down with GR enabled, routes already marked
BGP_PATH_STALE were incorrectly deleted instead of being preserved
for the current GR cycle. Remove the BGP_PATH_STALE check from both
bgp_clear_route_node() and clearing_clear_one_pi() so that stale
routes are re-marked rather than removed. Stale route cleanup remains
handled by bgp_clear_stale_route() on timer expiry.

Ticket: RM#4866286

Signed-off-by: Mitesh Kanjariya <mkanjariya@nvidia.com>
@miteshkanjariya
miteshkanjariya force-pushed the mkanjariya/bgp_gr_stale_flag_fix branch from b340234 to 968ccc4 Compare February 12, 2026 23:00
@ton31337

Copy link
Copy Markdown
Member

@Mergifyio backport dev/10.6 stable/10.5 stable/10.4

@mergify

mergify Bot commented Feb 13, 2026

Copy link
Copy Markdown

backport dev/10.6 stable/10.5 stable/10.4

βœ… Backports have been created

Details

Cherry-pick of 968ccc4 has failed:

On branch mergify/bp/stable/10.5/pr-20768
Your branch is ahead of 'origin/stable/10.5' by 1 commit.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit 968ccc471.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   bgpd/bgp_route.c

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Cherry-pick of 968ccc4 has failed:

On branch mergify/bp/stable/10.4/pr-20768
Your branch is ahead of 'origin/stable/10.4' by 1 commit.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit 968ccc471.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   bgpd/bgp_route.c

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@ton31337
ton31337 merged commit b49d57f into FRRouting:master Feb 13, 2026
19 checks passed
donaldsharp added a commit that referenced this pull request Feb 13, 2026
bgpd: fix premature deletion of already-stale routes during GR clearing (backport #20768)
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.

2 participants