Skip to content

Commit

Permalink
bgpd: replace ipv4-mapped ipv6 at update forwarding
Browse files Browse the repository at this point in the history
Replace IPv4-mapped IPv6 at update forwarding because the peer may not
be able to create a route with the IPv4-mapped IPv6.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
  • Loading branch information
louis-6wind committed Oct 7, 2024
1 parent ff37609 commit 929a070
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bgpd/bgp_updgrp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
gnh_modified = 1;
}
} else if (IN6_IS_ADDR_UNSPECIFIED(&v6nhglobal)) {
/* the UPDATE is originating from the local router.
* Build the global nexthop.
*/
mod_v6nhg = &peer->nexthop.v6_global;
gnh_modified = 1;
} else if ((peer->sort == BGP_PEER_EBGP)
Expand All @@ -521,6 +524,14 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
*/
mod_v6nhg = &peer->nexthop.v6_global;
gnh_modified = 1;
} else if (IS_MAPPED_IPV6(&v6nhglobal) &&
!IN6_IS_ADDR_LINKLOCAL(&peer->nexthop.v6_global)) {
/* prefer a IPv6 native global address over
* an IPv4-mapped IPv6 address as nexthop when
* forwarding UPDATEs.
*/
mod_v6nhg = &peer->nexthop.v6_global;
gnh_modified = 1;
}

if (peer->nexthop.v4.s_addr != INADDR_ANY &&
Expand All @@ -535,6 +546,10 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
}

if (IS_MAPPED_IPV6(&peer->nexthop.v6_global)) {
/* If the interface to the peer has no global IPv6
* address, replace the nexthop in UPDATE with
* the IPv4-mapped IPv6 address if any.
*/
mod_v6nhg = &peer->nexthop.v6_global;
gnh_modified = 1;
}
Expand Down

0 comments on commit 929a070

Please sign in to comment.