Skip to content

Commit

Permalink
bgpd: optimize bgp_interface_address_add
Browse files Browse the repository at this point in the history
Move common checks outside of the loop.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
  • Loading branch information
louis-6wind committed Apr 23, 2024
1 parent d346d1a commit 8599fe2
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 8599fe2

Please sign in to comment.