summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_updgrp_packet.c
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2024-03-29 16:14:14 +0100
committerLouis Scalbert <louis.scalbert@6wind.com>2024-04-23 11:28:36 +0200
commitfc5a738409eac9ca938cbb398872ea77d9cc5023 (patch)
treea0575ea83862b53a8a48e72e347c061eb0dc2d99 /bgpd/bgp_updgrp_packet.c
parenttests: ipv6 global removal in bgp_nexthop_mp_ipv4_6 (diff)
downloadfrr-fc5a738409eac9ca938cbb398872ea77d9cc5023.tar.xz
frr-fc5a738409eac9ca938cbb398872ea77d9cc5023.zip
bgpd: set ipv4-mapped ipv6 for ipv4 with ipv6 nexthop
The code was expected that no IPv6 global address was present but the previous commit was replacing nexthop.v6global by the link-local address instead of un-setting it in case of removal of the IPv6 global. Set also ipv4-mapped ipv6 address as nexthop when a link-local is found and it is an ipv4 prefix over ipv6 nexthop. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'bgpd/bgp_updgrp_packet.c')
-rw-r--r--bgpd/bgp_updgrp_packet.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 7502bf2ec..1f691b6a9 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -523,11 +523,13 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
gnh_modified = 1;
}
- if (IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg)) {
- if (peer->nexthop.v4.s_addr != INADDR_ANY) {
- ipv4_to_ipv4_mapped_ipv6(mod_v6nhg,
- peer->nexthop.v4);
- }
+ if (peer->nexthop.v4.s_addr != INADDR_ANY &&
+ (IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg) ||
+ (IN6_IS_ADDR_LINKLOCAL(mod_v6nhg) &&
+ peer->connection->su.sa.sa_family == AF_INET6 &&
+ paf->afi == AFI_IP))) {
+ ipv4_to_ipv4_mapped_ipv6(mod_v6nhg, peer->nexthop.v4);
+ gnh_modified = 1;
}
if (IS_MAPPED_IPV6(&peer->nexthop.v6_global)) {