Skip to content

Commit

Permalink
bgpd: do not insert link-local with local unchanged
Browse files Browse the repository at this point in the history
Do not add an IPv6 link-local nexthop if the originating peer does not
provide one and the nexthop-local unchanged setting is enabled.

Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
louis-6wind committed Oct 10, 2024
1 parent 38ad215 commit 34c1dd0
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
bool nh_reset = false;
uint64_t cum_bw;
mpls_label_t label;
bool global_and_ll = false;

if (DISABLE_BGP_ANNOUNCE)
return false;
Expand Down Expand Up @@ -2465,22 +2466,26 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
* we do not announce LL address as `::`.
*/
if (NEXTHOP_IS_V6) {
attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
if ((CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)
&& IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_local))
|| (!reflect && !transparent
&& IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_local)
&& peer->shared_network
&& (from == bgp->peer_self
|| peer->sort == BGP_PEER_EBGP))) {
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) {
/* nexthop local unchanged: only include the link-local nexthop if it
* was already present.
*/
if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_local))
global_and_ll = true;
} else if (!reflect && !transparent &&
IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_local) && peer->shared_network &&
(from == bgp->peer_self || peer->sort == BGP_PEER_EBGP))
global_and_ll = true;

if (global_and_ll) {
if (safi == SAFI_MPLS_VPN)
attr->mp_nexthop_len =
BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL;
else
attr->mp_nexthop_len =
BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
}
} else
attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;

/* Clear off link-local nexthop in source, whenever it is not
* needed to
Expand Down

0 comments on commit 34c1dd0

Please sign in to comment.