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