]> git.puffer.fish Git - mirror/frr.git/commit
bgpd: Clear capabilities field when resetting a bgp neighbor 9263/head
authorAlexander Skorichenko <askorichenko@netgate.com>
Wed, 14 Jul 2021 20:43:37 +0000 (16:43 -0400)
committermergify-bot <noreply@mergify.io>
Tue, 3 Aug 2021 11:00:54 +0000 (11:00 +0000)
commit182c8e9bbfab1ef2148fc0b1351b5d2ca849bc3a
tree5126dd31fae4d2ffd05a8090d1f68d5c550d917e
parentcf3e953c653d47ff42792c78286c14e1d44ed245
bgpd: Clear capabilities field when resetting a bgp neighbor

Currently, the following sequence of events between peers could
result in erroneous capability reports on the peer
with enabled dont-capability-negotiate option:
- having some of the capabilities advertised to a bgp neighbor,
- then disabling capability negotiation to that neighbor,
- then resetting connection to it,
- and no capabilities are actually sent to the neighbor,
- but "show bgp neighbors" on the host still displays them
as advertised to the neighbor.

There are two possibilities for establishing a new connection
- the established connection was initiated by us with bgp_start(),
- the connection was initiated on the neighbor side and processed by
us via bgp_accept() in bgp_network.c.
The former case results in "show bgp neighbors" displaying only
"received" in capabilities, as the peer's cap is initiated to zero
in bgp_start().
In the latter case, if bgp_accept() happens before bgp_start()
is called, then new peer capabilities are being transferred
from its previous record before being zeroed in bgp_start().
This results in "show bgp neighbors" still displaying
"advertised and received" in capabilities.

Following the logic of a similar af_cap field clearing,
treated correctly in both cases, we
- reset peer's capability during bgp_stop()
- don't pass it over to a new peer structure in bgp_accept().
This fix prevents transferring of the previous capabilities record
to a new peer instance in arbitrary reconnect scenario.

Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com>
(cherry picked from commit 24f569e9ccea56695ff57be71a6e108f9a7867b2)
bgpd/bgp_fsm.c
bgpd/bgpd.c