Ensure that if 'update-source <interface>' 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 <vivek@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2015-05-19 18:03:54 -07:00
parent 3fd6abdd13
commit 2fb2f5cfae

View file

@ -778,7 +778,10 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote,
if (local->sa.sa_family == AF_INET) if (local->sa.sa_family == AF_INET)
{ {
nexthop->v4 = local->sin.sin_addr; 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 #ifdef HAVE_IPV6
if (local->sa.sa_family == AF_INET6) 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) if (peer->conf_if || peer->ifname)
ifp = if_lookup_by_index (if_nametoindex (peer->conf_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 else
ifp = if_lookup_by_ipv6 (&local->sin6.sin6_addr); ifp = if_lookup_by_ipv6_exact (&local->sin6.sin6_addr);
} }
#endif /* HAVE_IPV6 */ #endif /* HAVE_IPV6 */