From e7db872b819b6be70dccf0c6e710e80124c4f86a Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 10 Mar 2020 09:20:09 +0100 Subject: [PATCH 1/2] bgpd: upon reconfiguration or bgp exchange failure, stop bfd. When bgp is updated with local source, the bgp session is reset; bfd also must be reset. The bgp_stop() handler handles all kind of unexpected failures, so the placeholder to deregister from bfd should be ok, providing that when bgp establishes, a similar function in bgp will recreate bfd context. Note that the bfd session is not reset on one specific case, where BFD down event is the last reset. In that case, we must let BFD to monitor the link. Signed-off-by: Philippe Guibert --- bgpd/bgp_fsm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index a44effaac5..2a2e238799 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1128,6 +1128,10 @@ int bgp_stop(struct peer *peer) peer->nsf_af_count = 0; + /* deregister peer */ + if (peer->last_reset != PEER_DOWN_BFD_DOWN) + bgp_bfd_deregister_peer(peer); + if (peer_dynamic_neighbor(peer) && !(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) { if (bgp_debug_neighbor_events(peer)) From bd540576afc47e3babbb87454a2303ba2382a80f Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 10 Mar 2020 14:34:36 +0100 Subject: [PATCH 2/2] bgpd: reset bfd session when bgp comes up This scenario has been seen against microtik virtual machine with bfd enabled. When remote microtik bgp reestablishes the bgp session after a bgp reset, the bgp establishment comes first, then bfd is initialising. The second point is true for microtik, but not for frrouting, as the frrouting, when receiving bfd down messages, is not at init state. Actually, bfd state is up, and sees the first bfd down packet from bfd as an issue. Consequently, the BGP session is cleared. The fix consists in resetting the BFD session, once BGP comes up. That permits to align state machines of both local and remote bfd. Signed-off-by: Philippe Guibert --- bgpd/bgp_fsm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 2a2e238799..86e1c8dacc 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1935,6 +1935,7 @@ static int bgp_establish(struct peer *peer) hash_release(peer->bgp->peerhash, peer); hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); + bgp_bfd_deregister_peer(peer); bgp_bfd_register_peer(peer); return ret; }