From 645a82ec6015b5fe0988f4de746a017a7a402061 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Dec 2024 10:13:51 -0500 Subject: [PATCH 1/3] tests: bfd_profiles_topo1 is taking a long time to reconnect Make it faster Signed-off-by: Donald Sharp --- tests/topotests/bfd_profiles_topo1/r2/bgpd.conf | 2 ++ tests/topotests/bfd_profiles_topo1/r3/bgpd.conf | 1 + tests/topotests/bfd_profiles_topo1/r4/bgpd.conf | 1 + 3 files changed, 4 insertions(+) diff --git a/tests/topotests/bfd_profiles_topo1/r2/bgpd.conf b/tests/topotests/bfd_profiles_topo1/r2/bgpd.conf index 1aab1d1372..0fe6f1c1c4 100644 --- a/tests/topotests/bfd_profiles_topo1/r2/bgpd.conf +++ b/tests/topotests/bfd_profiles_topo1/r2/bgpd.conf @@ -5,9 +5,11 @@ router bgp 100 no bgp ebgp-requires-policy neighbor 172.16.1.1 remote-as 100 neighbor 172.16.1.1 timers 3 10 + neighbor 172.16.1.1 timers connect 1 neighbor 172.16.1.1 bfd profile fasttx neighbor 2001:db8:2::2 remote-as 200 neighbor 2001:db8:2::2 timers 3 10 + neighbor 2001:db8:2::2 timers connect 1 neighbor 2001:db8:2::2 ebgp-multihop 2 neighbor 2001:db8:2::2 bfd profile slowtx address-family ipv4 unicast diff --git a/tests/topotests/bfd_profiles_topo1/r3/bgpd.conf b/tests/topotests/bfd_profiles_topo1/r3/bgpd.conf index 65647b39e5..d1168d93bc 100644 --- a/tests/topotests/bfd_profiles_topo1/r3/bgpd.conf +++ b/tests/topotests/bfd_profiles_topo1/r3/bgpd.conf @@ -2,6 +2,7 @@ router bgp 100 bgp router-id 10.254.254.3 neighbor 172.16.1.2 remote-as 100 neighbor 172.16.1.2 timers 3 10 + neighbor 172.16.1.2 timers connect 1 neighbor 172.16.1.2 bfd profile DOES_NOT_EXIST address-family ipv4 unicast redistribute connected diff --git a/tests/topotests/bfd_profiles_topo1/r4/bgpd.conf b/tests/topotests/bfd_profiles_topo1/r4/bgpd.conf index 12d68270f8..1a8e6bb94d 100644 --- a/tests/topotests/bfd_profiles_topo1/r4/bgpd.conf +++ b/tests/topotests/bfd_profiles_topo1/r4/bgpd.conf @@ -5,6 +5,7 @@ router bgp 200 no bgp ebgp-requires-policy neighbor 2001:db8:1::2 remote-as 100 neighbor 2001:db8:1::2 timers 3 10 + neighbor 2001:db8:1::2 timers connect 1 neighbor 2001:db8:1::2 ebgp-multihop 2 neighbor 2001:db8:1::2 bfd profile DOES_NOT_EXIST address-family ipv4 unicast From 7cde71a8e3ee53f4b332f5b66c7f009588c349d3 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Dec 2024 10:15:18 -0500 Subject: [PATCH 2/3] bgpd: shared_network is a bool, convert it to such Signed-off-by: Donald Sharp --- bgpd/bgp_zebra.c | 8 ++++---- bgpd/bgpd.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 688dfacaa0..ee1bdbc5bd 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -838,9 +838,9 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, if (!v6_ll_avail && !peer->conf_if) v6_ll_avail = true; if (if_lookup_by_ipv4(&remote->sin.sin_addr, peer->bgp->vrf_id)) - peer->shared_network = 1; + peer->shared_network = true; else - peer->shared_network = 0; + peer->shared_network = false; } /* IPv6 connection, fetch and store IPv4 local address if any. */ @@ -903,9 +903,9 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, || if_lookup_by_ipv6(&remote->sin6.sin6_addr, remote->sin6.sin6_scope_id, peer->bgp->vrf_id)) - peer->shared_network = 1; + peer->shared_network = true; else - peer->shared_network = 0; + peer->shared_network = false; } /* KAME stack specific treatment. */ diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index df55d879e7..bb56fd355a 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1330,7 +1330,7 @@ struct peer { union sockunion *su_local; /* Sockunion of local address. */ union sockunion *su_remote; /* Sockunion of remote address. */ - int shared_network; /* Is this peer shared same network. */ + bool shared_network; /* Is this peer shared same network. */ struct bgp_nexthop nexthop; /* Nexthop */ /* Roles in bgp session */ From 3b97cbf77e5ec72e37e7841af0cd535fdf140dfd Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Dec 2024 10:16:03 -0500 Subject: [PATCH 3/3] bgpd: When bgp notices a change to shared_network inform bfd of it When bgp is started up and reads the config in *before* it has received interface addresses from zebra, shared_network can be set to false in this case. Later on once bgp attempts to reconnect it will refigure out the shared_network again( because it has received the data from zebra now ). In this case tell bfd about it. Signed-off-by: Donald Sharp --- bgpd/bgp_zebra.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index ee1bdbc5bd..ac4a6bb03b 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -744,6 +744,7 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, int ret = 0; struct interface *ifp = NULL; bool v6_ll_avail = true; + bool shared_network_original = peer->shared_network; memset(nexthop, 0, sizeof(struct bgp_nexthop)); @@ -908,6 +909,9 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, peer->shared_network = false; } + if (shared_network_original != peer->shared_network) + bgp_peer_bfd_update_source(peer); + /* KAME stack specific treatment. */ #ifdef KAME if (IN6_IS_ADDR_LINKLOCAL(&nexthop->v6_global)