From 8599fe2b5e34b2ac1a46a14983ddcc2336e9116d Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Thu, 28 Mar 2024 11:07:23 +0100 Subject: [PATCH] bgpd: optimize bgp_interface_address_add Move common checks outside of the loop. Signed-off-by: Louis Scalbert --- bgpd/bgp_zebra.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 9a819657734e..520b01b768f1 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -335,13 +335,11 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS) if (IN6_IS_ADDR_LINKLOCAL(&ifc->address->u.prefix6) && !list_isempty(ifc->ifp->nbr_connected)) bgp_start_interface_nbrs(bgp, ifc->ifp); - else { + else if (ifc->address->family == AF_INET6 && + !IN6_IS_ADDR_LINKLOCAL(&ifc->address->u.prefix6)) { addr = ifc->address; for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { - if (addr->family == AF_INET) - continue; - /* * If the Peer's interface name matches the * interface name for which BGP received the @@ -355,7 +353,6 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS) if ((peer->conf_if && (strcmp(peer->conf_if, ifc->ifp->name) == 0)) && - !IN6_IS_ADDR_LINKLOCAL(&addr->u.prefix6) && ((IS_MAPPED_IPV6( &peer->nexthop.v6_global)) || IN6_IS_ADDR_LINKLOCAL(