From: Renato Westphal Date: Thu, 14 Feb 2019 22:00:15 +0000 (-0200) Subject: pbrd: fix detection of inconsistent nexthop groups X-Git-Tag: 7.1_pulled~154^2~3 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=268c24ee9ee2510d6b4922053285254644609a0f;p=matthieu%2Ffrr.git pbrd: fix detection of inconsistent nexthop groups Commit ff9799c31 broke the detection of nexthop groups that contain both v4 and v6 nexthops. Move the switch statement back to the ALL_NEXTHOPS loop to fix this issue. Further, make pbr_nht_which_afi() return AFI_MAX only if all nexthops from the group are either NEXTHOP_TYPE_IFINDEX or NEXTHOP_TYPE_BLACKHOLE. Signed-off-by: Renato Westphal --- diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index bc40caf1a0..e196b4fe2c 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -378,33 +378,47 @@ static afi_t pbr_nht_which_afi(struct nexthop_group nhg, afi_t install_afi = AFI_MAX; bool v6, v4, bh; + if (nh_type) { + switch (nh_type) { + case NEXTHOP_TYPE_IPV4: + case NEXTHOP_TYPE_IPV4_IFINDEX: + return AFI_IP; + case NEXTHOP_TYPE_IPV6: + case NEXTHOP_TYPE_IPV6_IFINDEX: + return AFI_IP6; + case NEXTHOP_TYPE_IFINDEX: + case NEXTHOP_TYPE_BLACKHOLE: + return AFI_MAX; + } + } + v6 = v4 = bh = false; - if (!nh_type) { - for (ALL_NEXTHOPS(nhg, nexthop)) { - nh_type = nexthop->type; + for (ALL_NEXTHOPS(nhg, nexthop)) { + nh_type = nexthop->type; + + switch (nh_type) { + case NEXTHOP_TYPE_IFINDEX: + break; + case NEXTHOP_TYPE_IPV4: + case NEXTHOP_TYPE_IPV4_IFINDEX: + v6 = true; + install_afi = AFI_IP; + break; + case NEXTHOP_TYPE_IPV6: + case NEXTHOP_TYPE_IPV6_IFINDEX: + v4 = true; + install_afi = AFI_IP6; + break; + case NEXTHOP_TYPE_BLACKHOLE: + bh = true; break; } } - switch (nh_type) { - case NEXTHOP_TYPE_IFINDEX: - break; - case NEXTHOP_TYPE_IPV4: - case NEXTHOP_TYPE_IPV4_IFINDEX: - v6 = true; - install_afi = AFI_IP; - break; - case NEXTHOP_TYPE_IPV6: - case NEXTHOP_TYPE_IPV6_IFINDEX: - v4 = true; - install_afi = AFI_IP6; - break; - case NEXTHOP_TYPE_BLACKHOLE: - bh = true; + /* Interface and/or blackhole nexthops only. */ + if (!v4 && !v6) install_afi = AFI_MAX; - break; - } if (!bh && v6 && v4) DEBUGD(&pbr_dbg_nht,