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);
}
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);
}
}
+ /* 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);