]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: replace ipv4-mapped ipv6 at update forwarding
authorLouis Scalbert <louis.scalbert@6wind.com>
Tue, 23 Jul 2024 08:26:36 +0000 (10:26 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Wed, 24 Jul 2024 08:17:42 +0000 (10:17 +0200)
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>
bgpd/bgp_updgrp_packet.c

index 468bf4771518df0d694bfa25a0a0d3a11dd1075d..12feac8353854506a965fa25696c7bea9c9d1f6c 100644 (file)
@@ -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)
@@ -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 &&
@@ -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;
                }