]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fix nexthop comparison for v6 859/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 26 Jul 2017 13:41:36 +0000 (09:41 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 26 Jul 2017 18:18:30 +0000 (14:18 -0400)
When we have both a LL and a Global address,
use what the attribute wants for comparison
instead of assuming Global than LL.

This was causing BGP to install v6 routes
that used the LL as the nexthop, where
the global address was different and
being used as the basis for comparison.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_mpath.c

index 6dc6dc6769dbfd47af13982bd1467cc786aa1bb3..d3ee140bb412a0946dc7614498cac03c4c52d6bf 100644 (file)
@@ -102,6 +102,7 @@ int bgp_maximum_paths_unset(struct bgp *bgp, afi_t afi, safi_t safi,
 int bgp_info_nexthop_cmp(struct bgp_info *bi1, struct bgp_info *bi2)
 {
        int compare;
+       struct in6_addr addr1, addr2;
 
        compare = IPV4_ADDR_CMP(&bi1->attr->nexthop, &bi2->attr->nexthop);
        if (!compare) {
@@ -120,13 +121,18 @@ int bgp_info_nexthop_cmp(struct bgp_info *bi1, struct bgp_info *bi2)
                                        &bi2->attr->mp_nexthop_global);
                                break;
                        case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
-                               compare = IPV6_ADDR_CMP(
-                                       &bi1->attr->mp_nexthop_global,
-                                       &bi2->attr->mp_nexthop_global);
+                               addr1 = (bi1->attr->mp_nexthop_prefer_global) ?
+                                       bi1->attr->mp_nexthop_global
+                                       : bi1->attr->mp_nexthop_local;
+                               addr2 = (bi2->attr->mp_nexthop_prefer_global) ?
+                                       bi2->attr->mp_nexthop_global
+                                       : bi2->attr->mp_nexthop_local;
+
+                               if (!bi1->attr->mp_nexthop_prefer_global &&
+                                   !bi2->attr->mp_nexthop_prefer_global)
+                                       compare = !(bi1->peer->ifindex == bi2->peer->ifindex);
                                if (!compare)
-                                       compare = IPV6_ADDR_CMP(
-                                               &bi1->attr->mp_nexthop_local,
-                                               &bi2->attr->mp_nexthop_local);
+                                       compare = IPV6_ADDR_CMP(&addr1, &addr2);
                                break;
                        }
                }