]> git.proxmox.com Git - mirror_frr.git/commitdiff
pbrd: fix detection of inconsistent nexthop groups
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 14 Feb 2019 22:00:15 +0000 (20:00 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 15 Feb 2019 00:57:39 +0000 (22:57 -0200)
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>
pbrd/pbr_nht.c

index bc40caf1a01e2cba7cbf416910a7d659fd5e56ba..e196b4fe2ce66114ab8c21ebcaa8f172807a7d4a 100644 (file)
@@ -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,