]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Only use passed afi for blackhole/ifindex nexthops
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 20 Aug 2019 19:08:01 +0000 (15:08 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:43 +0000 (11:13 -0400)
Only used the afi passed into `zebra_nhg_find()` for nexthops
that are blackhole/ifindex. Others should use the type actually declared
in the nexthop struct itself.

Basically, nexthop objects of type blackhole/ifindex in the kernel must
have an address family, they cannot be ambigious and be shared.

This is some requirement in the linux ip core code.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/zebra_nhg.c

index 4130365f2d0a371dce27ed34f07c524fcb7a184d..8cc18771065b6aafe43ff930b60e6506d0ee0113 100644 (file)
@@ -481,7 +481,29 @@ static bool zebra_nhg_find(struct nhg_hash_entry **nhe, uint32_t id,
                lookup.afi = AFI_UNSPEC;
                lookup.vrf_id = 0;
        } else {
-               lookup.afi = afi;
+               switch (lookup.nhg->nexthop->type) {
+               case (NEXTHOP_TYPE_IFINDEX):
+               case (NEXTHOP_TYPE_BLACKHOLE):
+                       /*
+                        * This switch case handles setting the afi different
+                        * for ipv4/v6 routes. Ifindex/blackhole nexthop
+                        * objects cannot be ambiguous, they must be Address
+                        * Family specific. If we get here, we will either use
+                        * the AF of the route, or the one we got passed from
+                        * here from the kernel.
+                        */
+                       lookup.afi = afi;
+                       break;
+               case (NEXTHOP_TYPE_IPV4_IFINDEX):
+               case (NEXTHOP_TYPE_IPV4):
+                       lookup.afi = AFI_IP;
+                       break;
+               case (NEXTHOP_TYPE_IPV6_IFINDEX):
+               case (NEXTHOP_TYPE_IPV6):
+                       lookup.afi = AFI_IP6;
+                       break;
+               }
+
                lookup.vrf_id = vrf_id;
        }