diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index db8e28cea0..4407167521 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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); } diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 376d07535d..cacbce1785 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -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);