Skip to content

server: support Enhanced Route Refresh (RFC 7313) - #3868

Open
MaxRink wants to merge 1 commit into
osrg:masterfrom
MaxRink:enhanced-route-refresh
Open

MaxRink wants to merge 1 commit into
osrg:masterfrom
MaxRink:enhanced-route-refresh

Conversation

@MaxRink

@MaxRink MaxRink commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Support Enhanced Route Refresh (RFC 7313). Fixes #3647: GoBGP did not remove the routes that a peer left out of a refresh.

  • Send the capability next to route refresh. When both sides sent it, answer a route refresh request with BoRR, the routes of the family, and EoRR (a raw message in the outgoing queue keeps its order relative to the queued UPDATEs, also when the send loop coalesces paths).
  • A BoRR marks the peer's routes of the family stale; at EoRR the routes that it did not send again are withdrawn.
  • Graceful restart uses the same stale mark, so an EoRR without a BoRR is ignored (Section 4 "MAY ignore") and cannot remove routes that graceful restart keeps. A BoRR from a graceful restart peer before its End-of-RIB is ignored (Section 4 "MUST ignore").
  • Stale routes are removed when no EoRR follows within the neighbor's graceful restart stale-routes-time, or 360 s (FRR's default stalepath-time), as Section 4 allows.
  • Other subtypes, and BoRR/EoRR without the capability, are ignored and logged (Section 5).

Behaviour change: the capability is now always sent, like route refresh. A peer that advertises it and then does not re-send a route after its BoRR loses that route at EoRR or after the bound. I can add a per-neighbor knob if you prefer.

Not covered yet: the Section 5 length check of BoRR/EoRR (NOTIFICATION 7/1), and BoRR/EoRR around a locally initiated refresh (soft reset out). I would send those separately.

Tests: TestEnhancedRouteRefresh (BoRR/routes/EoRR both ways), TestEnhancedRouteRefreshNoEoRR (bound), TestEnhancedRouteRefreshBoRRBeforeEoR, TestEnhancedRouteRefreshEoRRWithoutBoRR (fails without the gate), and TestSendMessageloop_MessageKeepsOrder; they pass with -race. Four pkg/server tests fail on my machine with and without this change (TestDisableMrt, TestEBGPRouteStuck, TestRTCDeferralTimerRaceCondition, TestTcpAoUpdatePeerWithClosedConnection, macOS).

Did you use an AI tool?

Yes. Claude Opus 5.5 helped write and review the change (the review found the EoRR/graceful restart interaction fixed above); the commit has an Assisted-by trailer. I have reviewed it and can answer questions about it.

@MaxRink

MaxRink commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

The embedded job failed while downloading golang.org/x/sys from proxy.golang.org (stream error ... INTERNAL_ERROR), not in the build itself; all other checks pass. Could someone re-run it? I lack the rights.

@MaxRink
MaxRink force-pushed the enhanced-route-refresh branch 2 times, most recently from 70b3785 to f27d1c9 Compare December 2, 2026 01:42
Copilot AI balanced review requested due to automatic review settings December 2, 2026 01:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved graceful-restart ordering and capability-gating issues can trigger premature refresh handling and route deletion, while stale-route cleanup leaves pre-policy BMP collectors out of sync.

3 open issues
What changed in this PR

Adds Enhanced Route Refresh support to GoBGP, addressing #3647 by removing routes a peer omits during refresh.

Changes:

  • Advertises the capability and preserves BoRR/UPDATE/EoRR ordering.
  • Adds stale-route cleanup, timeout handling, and graceful-restart guards.
  • Tests refresh behavior and outgoing message ordering.
File Description
pkg/​server/​server.go Handles refresh markers, cleanup, and timers.
pkg/​server/​server_test.go Tests refresh cleanup and graceful-restart guards.
pkg/​server/​peer.go Adds per-family timers and End-of-RIB checks.
pkg/​server/​fsm.go Advertises support and preserves queued message ordering.
pkg/​server/​fsm_test.go Tests marker ordering around UPDATEs.
pkg/​packet/​bgp/​bgp.go Defines route-refresh subtype constants.

Review effort: Balanced

Comment thread pkg/server/peer.go Resolved
Comment thread pkg/server/server.go Resolved
Comment thread pkg/server/server.go Resolved
GoBGP did not send the Enhanced Route Refresh capability, so a peer
refreshed its routes without the begin and end markers, and GoBGP did not
remove the routes that a peer left out of a refresh (osrg#3647). FRR sends the
capability by default.

- The OPEN carries the capability next to route refresh.
- When both sides sent it, a route refresh request is answered with BoRR,
  the routes of the family, and EoRR. A raw message in the outgoing queue
  goes out after the UPDATEs queued before it, also when the send loop
  coalesces paths. While our initial advertisement of the family is
  deferred (our own graceful restart, or the route target membership
  deferral), the request is left to that advertisement, which follows
  with its End-of-RIB: no BoRR before the End-of-RIB (Section 4).
- A BoRR marks the peer's routes of the family stale in the Adj-RIB-In;
  at EoRR the routes that it did not send again are withdrawn and, as
  when the Adj-RIB-In is dropped, reported to the pre-policy Adj-RIB-In
  watchers (BMP).
- RFC 7313 Section 4: "A BGP speaker MAY ignore any EoRR message received
  without a prior receipt of an associated BoRR message." Graceful
  restart marks routes stale in the same Adj-RIB-In, so such an EoRR is
  ignored and does not remove them. A BoRR from a peer that sent the
  graceful restart capability is ignored before its End-of-RIB for the
  family ("MUST ignore"), also when graceful restart is not configured
  on our side.
- "An implementation MAY impose a locally configurable upper bound on how
  long it would retain any stale routes": when no EoRR follows within the
  neighbor's graceful restart stale-routes-time, or 360 s (FRR's default
  stalepath-time), the routes that are still stale are removed. An EoRR,
  the end of the session and the removal of the neighbor stop the timer.
- Other subtypes, and BoRR/EoRR without the capability, are ignored and
  logged (Section 5).

Not covered yet: the Section 5 length check of BoRR/EoRR messages, and
BoRR/EoRR around a locally initiated refresh (soft reset out).

Fixes osrg#3647

Signed-off-by: Maximilian Rink <maximilian.rink@telekom.de>
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
@MaxRink
MaxRink force-pushed the enhanced-route-refresh branch from f27d1c9 to 03bfbd7 Compare December 2, 2026 15:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Enhanced Route Refresh keeps routes omitted between BoRR and EoRR

2 participants