From 2fb2f5cfaed0eb33406fe6e24bb4a7adf5a0d203 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 May 2015 18:03:54 -0700 Subject: [PATCH] Ensure that if 'update-source ' is specified, that interface is chosen as the source for the local nexthops. Otherwise, do a complete match on the local IP address of the connection to determine the source interface for the local nexthops; this will handle scenarios where there is an overlap of subnets between interfaces (e.g., loopback and another interface). Signed-off-by: Vivek Venkatraman --- bgpd/bgp_zebra.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index c78b4fc30e..8a97bd5f64 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -778,7 +778,10 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, if (local->sa.sa_family == AF_INET) { nexthop->v4 = local->sin.sin_addr; - ifp = if_lookup_by_ipv4 (&local->sin.sin_addr); + if (peer->update_if) + ifp = if_lookup_by_name (peer->update_if); + else + ifp = if_lookup_by_ipv4_exact (&local->sin.sin_addr); } #ifdef HAVE_IPV6 if (local->sa.sa_family == AF_INET6) @@ -788,8 +791,10 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, if (peer->conf_if || peer->ifname) ifp = if_lookup_by_index (if_nametoindex (peer->conf_if ? peer->conf_if : peer->ifname)); } + else if (peer->update_if) + ifp = if_lookup_by_name (peer->update_if); else - ifp = if_lookup_by_ipv6 (&local->sin6.sin6_addr); + ifp = if_lookup_by_ipv6_exact (&local->sin6.sin6_addr); } #endif /* HAVE_IPV6 */ -- 2.39.5