bgpd: add advertisement-delay to hold route advertisements after startup - #21430
Conversation
|
What's the motivation for this knob? If the local FIB is already updated, delaying the route advertisement would mean stales routes on the receiver, right? |
Greptile SummaryThis PR introduces The core state-machine logic, the dual-timer coordination in
Confidence Score: 4/5Not safe to merge as-is: removing advertisement-delay while the timer is active permanently blocks peer route advertisements until a hard clear One P1 defect: the bgpd/bgp_vty.c β both Important Files Changed
Sequence DiagramsequenceDiagram
participant Peer as First Peer
participant FSM as bgp_fsm.c
participant Timer as advertisement-delay timer
participant Route as bgp_route.c
participant Adv as Route Advertisements
Note over FSM: startup / clear ip bgp *
Peer->>FSM: reaches Established
FSM->>FSM: bgp_advertisement_delay_begin()<br/>main_peers_update_hold = 1
FSM->>Timer: start timer (v_advertisement_delay seconds)
Note over Route: (update-delay also running? update-delay end fires first)
Route->>Route: bgp_process_main_one() EOIU path<br/>advertisement-delay still active?<br/>YES β keep holding
Timer->>FSM: bgp_advertisement_delay_timer() fires
alt update-delay still active or main_zebra_update_hold
FSM-->>Route: set advertisement_delay_over=1, return<br/>(release deferred to EOIU path)
Route->>Route: EOIU: advertisement_delay_active=false<br/>β main_peers_update_hold=0
Route->>Adv: bgp_start_routeadv()
else advertisement-delay is the last hold
FSM->>FSM: main_peers_update_hold = 0
FSM->>Adv: bgp_start_routeadv()
end
Note over FSM,Adv: BUG: no advertisement-delay cancels timer<br/>but leaves main_peers_update_hold=1 β Adv permanently blocked
|
0ce3c40 to
6906d2d
Compare
With update-delay, both FIB programming and advertisements are deferred -- this means the restarting router cannot forward local traffic until the delay completes. advertisement-delay allows FIB programming to proceed normally so local forwarding works immediately, while holding only the advertisements to prevent the router from attracting remote traffic before it has a complete routing state. Regarding stale routes: after a non-graceful restart, peers detect the session loss and withdraw routes to this router, so the receiver has no routes -- not stale ones. The advertisement-delay controls when this router re-announces itself, ensuring it only attracts traffic once it has fully converged. When graceful-restart is active, advertisement-delay is not started -- the GR restarter path handles route retention separately. |
6906d2d to
423bcf9
Compare
ton31337
left a comment
There was a problem hiding this comment.
Please update the documentation on what is the motivation for this new command (like you answered in the comments).
| uint8_t advertisement_delay_over; | ||
| uint8_t advertisement_delay_started; | ||
| uint16_t v_advertisement_delay; | ||
| char advertisement_delay_resume_time[64]; |
There was a problem hiding this comment.
Followed same pattern as the existing update_delay_*_time fields (bgpd.h#L673-L676) -- char[64] populated by frr_timestamp() for display in show bgp summary.
| bgp->main_peers_update_hold = 1; | ||
| event_add_timer(bm->master, bgp_advertisement_delay_timer, bgp, bgp->v_advertisement_delay, | ||
| &bgp->t_advertisement_delay); | ||
| zlog_info("Advertisement delay started - %d seconds for %s", bgp->v_advertisement_delay, |
There was a problem hiding this comment.
Same, put it under zlog_debug().
There was a problem hiding this comment.
This fires once when the first peer reaches Established, same pattern as update-delay's zlog_info("Begin read-only mode ..."). Can I keep this at zlog_info? I'd like it in frr.log without requiring debugs.
423bcf9 to
bf336ba
Compare
Updated in the bgp.rst documentation section. |
|
In general, I like this "feature", and I agree we should rename an existing "update-delay" to something else more reflective in the future. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
riw777
left a comment
There was a problem hiding this comment.
looks good ... this is a good feature
Add advertisement-delay CLI and logic that holds route advertisements to peers for a configured number of seconds after the first peer reaches Established state. - Global: bgp advertisement-delay (1-3600) - Per-instance: advertisement-delay (1-3600) - With update-delay: both timers start at T0 (first peer Established). Advertisements released at max(time_FIB_ready, T0 + A). - Without update-delay: at first peer Established, set hold and start advertisement-delay timer; best-path and FIB are programmed as routes arrive from peers; advertisements released when timer expires. - Re-triggers on clear ip bgp *, following the same pattern as update-delay. - show bgp summary: when update-delay is in progress, show advertisement delay state (e.g. remaining seconds or resumed time) when the advertisement-delay timer is running or has completed. Signed-off-by: Karthikeya Venkat Muppalla <kmuppalla@nvidia.com> Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bf336ba to
8ddd740
Compare
Document the bgp advertisement-delay CLI (global and per-vrf). Clarify that the delay applies to all AFI/SAFI, re-triggers on clear ip bgp *, and is unrelated to the per-neighbor advertisement-interval. Signed-off-by: Karthikeya Venkat Muppalla <kmuppalla@nvidia.com> Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Add topotest exercising the advertisement-delay feature with a simple r1--r2--r3 topology where r2 is the UUT. Test cases: - Initial convergence without any delay configured - show bgp router json / show bgp summary json show configured value - advertisement-delay in progress: peers Established, pfxSnt=0 - RIB is populated during delay (only advertisements are held) - delay completes: pfxSnt>0, advertisementDelayResumeTime set - r3 learns route from r1 via r2 after delay ends - update-delay + advertisement-delay (ad > ud): ads held until ad-delay - re-trigger on clear ip bgp * - removal: routes advertised promptly without delay Signed-off-by: Karthikeya Venkat Muppalla <kmuppalla@nvidia.com>
8ddd740 to
cfb792a
Compare
Summary
Add a new
advertisement-delayCLI that holds route advertisements to peersfor a configured number of seconds after the first peer reaches Established
state. Unlike
update-delay, which defers best-path and FIB programming,advertisement-delayallows best-path selection and FIB installation toproceed normally -- only peer advertisements are held.
Available as both a global command (
bgp advertisement-delay <1-3600>) anda per-instance command (
advertisement-delay <1-3600>underrouter bgp).Behavior
update-delay).
Only advertisements to peers are held (pfxSnt remains 0).
are released at max(update-delay result, T0 + advertisement-delay).
clear ip bgp *, following the same pattern as update-delay.advertisement-delay apply to cold start and clear events.
show bgp summary jsonshowsadvertisementDelay,advertisementDelayInProgress,advertisementDelayRemainingSeconds, andadvertisementDelayResumeTime.show bgp router jsonshowsbgpAdvertisementDelayTime.