]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Put nhe ifp setting inside alloc
authorStephen Worley <sworley@cumulusnetworks.com>
Thu, 11 Apr 2019 16:11:49 +0000 (12:11 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:39 +0000 (11:13 -0400)
Put the setting of the ifp on a nexthop group hash
entry into the zebra_nhg_alloc() function. It should
only be added if its not a group/recursive (it doesn't
have any depends) and its nexthop type has an ifindex.

This also provides functionality for proto-side ifp
setting.

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

index db8e28cea0c6a4c9e5abf677ead82b5fcd43f6db..4407167521c272e5cfd1095e8af762dc22bfb441 100644 (file)
@@ -2447,12 +2447,6 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
                                        id);
                                nhg_connected_head_free(&nhg_depends);
                        } else {
-                               /* Add the nhe to the interface's tree
-                                * of connected nhe's
-                                */
-                               if (ifp)
-                                       zebra_nhg_set_if(nhe, ifp);
-
                                SET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
                                SET_FLAG(nhe->flags, NEXTHOP_GROUP_VALID);
                        }
index 376d07535db2bc88df1c3de1e518c30048e51e2a..cacbce1785ac026a631a69cbd15e38496738a73f 100644 (file)
@@ -308,7 +308,6 @@ static void *zebra_nhg_alloc(void *arg)
        nhe->refcnt = 0;
        nhe->is_kernel_nh = copy->is_kernel_nh;
        nhe->dplane_ref = zebra_router_get_next_sequence();
-       nhe->ifp = NULL;
 
        /* Attach backpointer to anything that it depends on */
        zebra_nhg_dependents_init(nhe);
@@ -319,6 +318,25 @@ 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) {
+               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;
+               }
+       }
+
        /* Add to id table as well */
        zebra_nhg_insert_id(nhe);