From: Stephen Worley Date: Tue, 20 Aug 2019 19:08:01 +0000 (-0400) Subject: zebra: Only use passed afi for blackhole/ifindex nexthops X-Git-Tag: base_7.3~219^2~30 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=4d21c7c0868e16d37a795dd4da999a1707812c56;p=matthieu%2Ffrr.git zebra: Only use passed afi for blackhole/ifindex nexthops 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 --- diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 4130365f2d..8cc1877106 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -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; }