Skip to content

Commit

Permalink
bgpd: split nexthop-local unchanged peer subgroup
Browse files Browse the repository at this point in the history
5bb99cc ("bgpd: reset ipv6 invalid link-local nexthop") now resets
the link-local when originating and destination peers are not on the
same network segment. However, it does not work all the time.

The fix compares the 'from' and 'peer' global IPv6 address. However,
'peer' refers to one of the peers of subgroup. The subgroup may contain
peers located on different network segment.

Split nexthop-local unchanged peer subgroup by network segment.

Fixes: 5bb99cc ("bgpd: reset ipv6 invalid link-local nexthop")
Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
louis-6wind committed Oct 11, 2024
1 parent da7b2d9 commit 91512c3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bgpd/bgp_updgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ static unsigned int updgrp_hash_key_make(const void *p)
key = jhash_1word(jhash(soo_str, strlen(soo_str), SEED1), key);
}

if (afi == AFI_IP6 &&
(CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)))
key = jhash(&peer->nexthop.v6_global, IPV6_MAX_BYTELEN, key);

/*
* ANY NEW ITEMS THAT ARE ADDED TO THE key, ENSURE DEBUG
* STATEMENT STAYS UP TO DATE
Expand Down Expand Up @@ -521,6 +525,12 @@ static unsigned int updgrp_hash_key_make(const void *p)
peer->soo[afi][safi]
? ecommunity_str(peer->soo[afi][safi])
: "(NONE)");
zlog_debug("%pBP Update Group Hash: IPv6 nexthop-local unchanged: %d IPv6 global %pI6",
peer,
afi == AFI_IP6 && (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)),
&peer->nexthop.v6_global);

zlog_debug("%pBP Update Group Hash key: %u", peer, key);
}
return key;
Expand Down Expand Up @@ -655,6 +665,12 @@ static bool updgrp_hash_cmp(const void *p1, const void *p2)
!sockunion_same(&pe1->connection->su, &pe2->connection->su))
return false;

if (afi == AFI_IP6 &&
(CHECK_FLAG(flags1, PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ||
CHECK_FLAG(flags2, PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) &&
!IPV6_ADDR_SAME(&pe1->nexthop.v6_global, &pe2->nexthop.v6_global))
return false;

return true;
}

Expand Down

0 comments on commit 91512c3

Please sign in to comment.