Skip to content

Commit ed7710f

Browse files
committed
bgpd: fix sending ipv6 local nexthop if global present
bgpd keeps on advertising IPv6 prefixes with a IPv6 link-local nexthop after a valid IPv6 global appears. At bgpd startup, the IPv6 global is announced by zebra after the link-local. Only the link-local is advertised. Clearing the BGP sessions make the global to to be announced. Update the nexthops with the global IPv6 when available. Signed-off-by: Louis Scalbert <[email protected]>
1 parent 4623483 commit ed7710f

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

bgpd/bgp_zebra.c

+23-4
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,12 @@ static int bgp_ifp_down(struct interface *ifp)
302302

303303
static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS)
304304
{
305-
struct connected *ifc;
305+
struct connected *ifc, *connected;
306306
struct bgp *bgp;
307307
struct peer *peer;
308308
struct prefix *addr;
309309
struct listnode *node, *nnode;
310+
bool v6_ll_in_nh_global;
310311
afi_t afi;
311312
safi_t safi;
312313

@@ -341,6 +342,23 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS)
341342
addr = ifc->address;
342343

343344
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
345+
v6_ll_in_nh_global = false;
346+
347+
if (IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_global)) {
348+
frr_each (if_connected, ifc->ifp->connected, connected) {
349+
if (connected->address->family != AF_INET6)
350+
continue;
351+
if (!IPV6_ADDR_SAME(&connected->address->u.prefix6,
352+
&peer->nexthop.v6_global))
353+
continue;
354+
/* peer->nexthop.v6_global contains a link-local address
355+
* that needs to be replaced by the global address.
356+
*/
357+
v6_ll_in_nh_global = true;
358+
break;
359+
}
360+
}
361+
344362
/*
345363
* If the Peer's interface name matches the
346364
* interface name for which BGP received the
@@ -351,9 +369,10 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS)
351369
* into peer's v6_global and send updates out
352370
* with new nexthop addr.
353371
*/
354-
if ((peer->conf_if && (strcmp(peer->conf_if, ifc->ifp->name) == 0)) &&
355-
((IS_MAPPED_IPV6(&peer->nexthop.v6_global)) ||
356-
IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_global))) {
372+
if (v6_ll_in_nh_global ||
373+
(peer->conf_if && strcmp(peer->conf_if, ifc->ifp->name) == 0 &&
374+
(IS_MAPPED_IPV6(&peer->nexthop.v6_global) ||
375+
IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_global)))) {
357376
if (bgp_debug_zebra(ifc->address)) {
358377
zlog_debug("Update peer %pBP's current intf global addr from %pI6 to %pI6 and send updates",
359378
peer, &peer->nexthop.v6_global, &addr->u.prefix6);

0 commit comments

Comments
 (0)