Page MenuHomeVyOS Platform

bgp: 'reset ip bgp peer-group' clears the members one by one, with a full table walk each
Open, NormalPublicBUG

Description

reset ip bgp peer-group <name> is sent to FRR as clear ip bgp peer-group <name> (src/op_mode/bgp.py, reset()). The literal ip makes FRR treat it as an IPv4-only clear, and for that case bgp_clear() does not use its batched path: every member is cleared one after another, each with a full walk of the routing table, on bgpd's main thread. reset bgp peer-group <name> (without ip) reaches FRR as clear bgp peer-group <name> and clears the whole group in one batched walk.

Measured on VyOS 1.5.1 (FRR 10.5.2), about 1M IPv4 paths, bgpd time for the clear (show event cpu, bgp_event):

membersreset ip bgp peer-groupreset bgp peer-group
201.0-3.6 s7-21 ms
809.2-12.6 s7-21 ms
80, 2.25M paths26.7 s17 ms

While the unbatched clear runs, bgpd answers nothing: a commit issued one second after the reset with 80 members was blocked 29-34 s. The same holds for the other hard clears that carry ip without an address family (reset ip bgp all, external, <as>), by code.

Cause in FRR (10.5.2 and 10.6.1): clear_ip_bgp_all sets afi = AFI_IP when the ip token is present (bgp_vty.c, 10.5.2 lines 11582-11583), so bgp_clear()'s afi_safi_unspec check (line 1154) is false and the peer-group branch clears each peer inline instead of in one batch.

Possible fix.

  • VyOS: for hard clears with no address family given, send clear bgp ... instead of clear ip bgp ... (op-mode reset()).
  • or FRR: use the batched path for every hard clear (a hard clear resets every AFI/SAFI anyway).

Details

Version
1.5.1, 1.5-rolling-20261014
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

I looked at this in the FRR source (stable/10.5 and master, same code), and the cause is a bit wider than the ip token.

bgp_clear() only batches the clear (bgp_clearing_batch_begin() / ..._end_event_start()) when afi_safi_unspec is true, so when neither an address family nor a SAFI is given. As soon as one is given, each member is cleared on its own with its own table walk. ip sets afi = AFI_IP in clear_ip_bgp_all, but the VyOS commands with an explicit
family have the same problem:

reset ip bgp peer-group NAME -> clear ip bgp peer-group NAME (slow)
reset bgp ipv4 unicast peer-group NAME -> clear bgp ipv4 unicast peer-group NAME (slow)
reset bgp ipv6 unicast peer-group NAME -> clear bgp ipv6 unicast peer-group NAME (slow)
reset bgp peer-group NAME -> clear bgp peer-group NAME (batched, fast)

So the proposed VyOS-side change (send clear bgp ... instead of clear ip bgp ...) would also change behavior: clear ip bgp peer-group only touches members that have IPv4, clear bgp peer-group also resets members that only have IPv6. For a hard clear the family does not limit the reset, peer_clear() resets the whole session either way, it only selects which members take part. Only soft, in and out are really per family.

Because of that I think the fix belongs in FRR: batch a hard clear (BGP_CLEAR_SOFT_NONE) also when a family is given. Then clearing a group with a family filter is fast as well. I opened it upstream: https://github.com/FRRouting/frr/issues/23771. A downstream VyOS patch in vyos-build is possible as a stopgap, I did not look into the effort yet.

Until then reset bgp peer-group NAME without a family is the fast way to reset a whole group. On the VyOS side I would only document that, and not change the existing commands.

Because of that the fix belongs in FRR: batch a hard clear (BGP_CLEAR_SOFT_NONE) also when a family is given. Then clearing a group with a family filter is fast as well.
FRR issue: https://github.com/FRRouting/frr/issues/23771. I also opened a patch with a topotest: https://github.com/FRRouting/frr/pull/23779.

Until that lands, reset bgp peer-group NAME without a family is the fast way to reset a whole group. On the VyOS side I would only document that and not change the
existing commands. A downstream FRR patch in vyos-build is possible as a stopgap, I did not look into the effort yet.

Viacheslav triaged this task as Normal priority.Mon, Oct 19, 2:48 PM