From 29eafd32c58c3b6e3ecb6f715aef74a17f22382a Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 11 Nov 2024 16:49:22 +0200 Subject: [PATCH] bgpd: Do not try to uninstall BFD session if the peer is not established Having something like: ``` neighbor 192.168.1.222 ebgp-multihop 32 neighbor 192.168.1.222 update-source 192.168.1.5 neighbor 192.168.1.222 bfd ``` Won't work and the result is (empty): ``` $ show bfd peers BFD Peers: ``` bgp_stop() is called in BGP FSM multiple times (even at startup) that causes intermediate session interruption when update-source/ebgp-multihop is triggered. With this fix, the ordering does not matter and the BFD session's parameters are updated correctly. Signed-off-by: Donatas Abraitis --- bgpd/bgp_fsm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 58e1ffa500..8c9050185b 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1344,11 +1344,6 @@ enum bgp_fsm_state_progress bgp_stop(struct peer_connection *connection) peer->nsf_af_count = 0; - /* deregister peer */ - if (peer->bfd_config - && peer->last_reset == PEER_DOWN_UPDATE_SOURCE_CHANGE) - bfd_sess_uninstall(peer->bfd_config->session); - if (peer_dynamic_neighbor_no_nsf(peer) && !(CHECK_FLAG(peer->flags, PEER_FLAG_DELETE))) { if (bgp_debug_neighbor_events(peer)) @@ -1368,6 +1363,10 @@ enum bgp_fsm_state_progress bgp_stop(struct peer_connection *connection) if (peer_established(connection)) { peer->dropped++; + if (peer->bfd_config && (peer->last_reset == PEER_DOWN_UPDATE_SOURCE_CHANGE || + peer->last_reset == PEER_DOWN_MULTIHOP_CHANGE)) + bfd_sess_uninstall(peer->bfd_config->session); + /* Notify BGP conditional advertisement process */ peer->advmap_table_change = true; -- 2.39.5