summaryrefslogtreecommitdiff
path: root/bgpd/bgp_bfd.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-11-12 13:09:09 +0200
committerDonatas Abraitis <donatas@opensourcerouting.org>2025-02-13 20:44:15 +0200
commit5eb7047e2798e56c89c650434d3c6e7dc7533328 (patch)
tree8ca0af8b9f806de13f5022b9cc3e298c8391b549 /bgpd/bgp_bfd.c
parent4f7e8c269dfb26ad8338aa118b6b7d504294821b (diff)
bgpd: Update source address for BFD session
If BFD is down, we should try to detect the source automatically from the given interface. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_bfd.c')
-rw-r--r--bgpd/bgp_bfd.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c
index 88ffb68206..3a1459b8a5 100644
--- a/bgpd/bgp_bfd.c
+++ b/bgpd/bgp_bfd.c
@@ -26,6 +26,7 @@
#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_vty.h"
#include "bgpd/bgp_packet.h"
+#include "bgpd/bgp_network.h"
DEFINE_MTYPE_STATIC(BGPD, BFD_CONFIG, "BFD configuration data");
@@ -158,16 +159,33 @@ void bgp_peer_bfd_update_source(struct peer *p)
struct in_addr v4;
struct in6_addr v6;
} src, dst;
+ struct interface *ifp;
+ union sockunion addr;
/* Nothing to do for groups. */
if (CHECK_FLAG(p->sflags, PEER_STATUS_GROUP))
return;
/* Figure out the correct source to use. */
- if (CHECK_FLAG(p->flags, PEER_FLAG_UPDATE_SOURCE) && p->update_source)
- source = p->update_source;
- else
+ if (CHECK_FLAG(p->flags, PEER_FLAG_UPDATE_SOURCE)) {
+ if (p->update_source) {
+ source = p->update_source;
+ } else if (p->update_if) {
+ ifp = if_lookup_by_name(p->update_if, p->bgp->vrf_id);
+ if (ifp) {
+ sockunion_init(&addr);
+ if (bgp_update_address(ifp, &p->connection->su, &addr)) {
+ if (BGP_DEBUG(bfd, BFD_LIB))
+ zlog_debug("%s: can't find the source address for interface %s",
+ __func__, p->update_if);
+ }
+
+ source = &addr;
+ }
+ }
+ } else {
source = p->su_local;
+ }
/* Update peer's source/destination addresses. */
bfd_sess_addresses(session, &family, &src.v6, &dst.v6);