]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: clarify when the vpnv6 nexthop length must be modified
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 13 Feb 2023 11:18:33 +0000 (12:18 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 15 Feb 2023 16:02:15 +0000 (17:02 +0100)
Using a route-map to update the local ipv6 address has to be
better clarified. Actually, when a VPN SAFI is used, the nexthop
length must be changed to 48 bytes. Other cases, the length will
be 32 bytes.

Fixes: 9795e9f23465 ("bgpd: fix when route-map changes the link local
nexthop for vpnv6")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_routemap.c

index 5aa3ec4fd168b53b298cde1433ec59f6b9fe86af..4a2029c026b420cb1ec299ff148d9938fb8e0e9a 100644 (file)
@@ -3650,17 +3650,29 @@ route_set_ipv6_nexthop_local(void *rule, const struct prefix *p, void *object)
 {
        struct in6_addr *address;
        struct bgp_path_info *path;
+       struct bgp_dest *dest;
+       struct bgp_table *table = NULL;
 
        /* Fetch routemap's rule information. */
        address = rule;
        path = object;
+       dest = path->net;
+
+       if (!dest)
+               return RMAP_OKAY;
+
+       table = bgp_dest_table(dest);
+       if (!table)
+               return RMAP_OKAY;
 
        /* Set next hop value. */
        path->attr->mp_nexthop_local = *address;
 
        /* Set nexthop length. */
-       if (path->attr->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL &&
-           path->attr->mp_nexthop_len != BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL)
+       if (table->safi == SAFI_MPLS_VPN || table->safi == SAFI_ENCAP ||
+           table->safi == SAFI_EVPN)
+               path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL;
+       else
                path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
 
        SET_FLAG(path->attr->rmap_change_flags,