]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Fix nhg ifindex setting and checking
authorStephen Worley <sworley@cumulusnetworks.com>
Mon, 22 Apr 2019 19:42:10 +0000 (15:42 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:40 +0000 (11:13 -0400)
We were only setting and checking the ifindex if
the nexthop had an *_IFINDEX type. However, when nexthop
active checking is done, the non-*_IFINDEX types can also
obtain a nexthop with an ifindex and are thus valid too.

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

index 419e8ffb6e2a1e495dc2d69b4f073e0416ddad5a..83e3fd558b1259b0cf6817b4ce53829310ccd326 100644 (file)
@@ -1962,10 +1962,12 @@ static int netlink_nexthop(int cmd, struct zebra_dplane_ctx *ctx)
                                req.nhm.nh_family = AF_INET6;
 
                        switch (nh->type) {
+                       case NEXTHOP_TYPE_IPV4:
                        case NEXTHOP_TYPE_IPV4_IFINDEX:
                                addattr_l(&req.n, sizeof(req), NHA_GATEWAY,
                                          &nh->gate.ipv4, IPV4_MAX_BYTELEN);
                                break;
+                       case NEXTHOP_TYPE_IPV6:
                        case NEXTHOP_TYPE_IPV6_IFINDEX:
                                addattr_l(&req.n, sizeof(req), NHA_GATEWAY,
                                          &nh->gate.ipv6, IPV6_MAX_BYTELEN);
@@ -1978,13 +1980,13 @@ static int netlink_nexthop(int cmd, struct zebra_dplane_ctx *ctx)
                        case NEXTHOP_TYPE_IFINDEX:
                                /* Don't need anymore info for this */
                                break;
-                       case NEXTHOP_TYPE_IPV4:
-                       case NEXTHOP_TYPE_IPV6:
+                       }
+
+                       if (!nh->ifindex) {
                                flog_err(
                                        EC_ZEBRA_NHG_FIB_UPDATE,
                                        "Context received for kernel nexthop update without an interface");
                                return -1;
-                               break;
                        }
 
                        addattr32(&req.n, sizeof(req), NHA_OIF, nh->ifindex);
index 67f72d1e8283408bc91342d0c238947ba9e84e17..94d41ba24611f3c63c3b3463d43c762caa0427e2 100644 (file)
@@ -312,22 +312,13 @@ static void *zebra_nhg_alloc(void *arg)
        }
 
        /* Add the ifp now if its not a group or recursive and has ifindex */
-       if (zebra_nhg_depends_is_empty(nhe) && nhe->nhg->nexthop) {
+       if (zebra_nhg_depends_is_empty(nhe) && nhe->nhg->nexthop
+           && nhe->nhg->nexthop->ifindex) {
                struct interface *ifp = NULL;
 
-               switch (nhe->nhg->nexthop->type) {
-               case NEXTHOP_TYPE_IPV4_IFINDEX:
-               case NEXTHOP_TYPE_IPV6_IFINDEX:
-               case NEXTHOP_TYPE_IFINDEX:
-                       ifp = if_lookup_by_index(nhe->nhg->nexthop->ifindex,
-                                                nhe->vrf_id);
-                       zebra_nhg_set_if(nhe, ifp);
-                       break;
-               case NEXTHOP_TYPE_BLACKHOLE:
-               case NEXTHOP_TYPE_IPV4:
-               case NEXTHOP_TYPE_IPV6:
-                       break;
-               }
+               ifp = if_lookup_by_index(nhe->nhg->nexthop->ifindex,
+                                        nhe->vrf_id);
+               zebra_nhg_set_if(nhe, ifp);
        }
 
        /* Add to id table as well */