diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2019-02-14 23:00:15 +0100 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2019-02-15 01:57:39 +0100 |
commit | 268c24ee9ee2510d6b4922053285254644609a0f (patch) | |
tree | 152cb2d779c93cea444d230a934200f8d68d4370 /pbrd | |
parent | pbrd: rename nh_afi variables to nh_type to better convey their meaning (diff) | |
download | frr-268c24ee9ee2510d6b4922053285254644609a0f.tar.xz frr-268c24ee9ee2510d6b4922053285254644609a0f.zip |
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 <renato@opensourcerouting.org>
Diffstat (limited to 'pbrd')
-rw-r--r-- | pbrd/pbr_nht.c | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index bc40caf1a..e196b4fe2 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, |