diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index d03c1dde08..dfe74e325e 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -249,8 +249,6 @@ static void isis_zebra_route_add_route(struct prefix *prefix, return; memset(&api, 0, sizeof(api)); - if (fabricd) - api.flags |= ZEBRA_FLAG_ONLINK; api.vrf_id = VRF_DEFAULT; api.type = PROTO_TYPE; api.safi = SAFI_UNICAST; @@ -275,6 +273,8 @@ static void isis_zebra_route_add_route(struct prefix *prefix, if (count >= MULTIPATH_NUM) break; api_nh = &api.nexthops[count]; + if (fabricd) + api_nh->onlink = true; api_nh->vrf_id = VRF_DEFAULT; /* FIXME: can it be ? */ if (nexthop->ip.s_addr != INADDR_ANY) { @@ -298,6 +298,8 @@ static void isis_zebra_route_add_route(struct prefix *prefix, } api_nh = &api.nexthops[count]; + if (fabricd) + api_nh->onlink = true; api_nh->vrf_id = VRF_DEFAULT; api_nh->gate.ipv6 = nexthop6->ip6; api_nh->ifindex = nexthop6->ifindex; diff --git a/lib/zclient.c b/lib/zclient.c index 0e58d97174..a01da77669 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -807,6 +807,7 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api) stream_putl(s, api_nh->vrf_id); stream_putc(s, api_nh->type); + stream_putc(s, api_nh->onlink); switch (api_nh->type) { case NEXTHOP_TYPE_BLACKHOLE: stream_putc(s, api_nh->bh_type); @@ -973,6 +974,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) STREAM_GETL(s, api_nh->vrf_id); STREAM_GETC(s, api_nh->type); + STREAM_GETC(s, api_nh->onlink); switch (api_nh->type) { case NEXTHOP_TYPE_BLACKHOLE: STREAM_GETC(s, api_nh->bh_type); diff --git a/lib/zclient.h b/lib/zclient.h index 8a3423cdd8..e00821f2f6 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -306,6 +306,7 @@ struct zapi_nexthop { enum nexthop_types_t type; vrf_id_t vrf_id; ifindex_t ifindex; + bool onlink; union { union g_addr gate; enum blackhole_type bh_type; diff --git a/lib/zebra.h b/lib/zebra.h index 09115951e9..43ab4309c2 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -446,11 +446,6 @@ extern const char *zserv_command_string(unsigned int command); * route entry. This mainly is used for backup static routes. */ #define ZEBRA_FLAG_RR_USE_DISTANCE 0x40 -/* - * This flag tells Zebra that the passed down route is ONLINK and the - * kernel install flag for it should be turned on - */ -#define ZEBRA_FLAG_ONLINK 0x80 #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */ diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c index d6db60d3ed..3f31177524 100644 --- a/staticd/static_zebra.c +++ b/staticd/static_zebra.c @@ -370,8 +370,6 @@ extern void static_zebra_route_add(struct route_node *rn, memcpy(&api.src_prefix, src_pp, sizeof(api.src_prefix)); } SET_FLAG(api.flags, ZEBRA_FLAG_RR_USE_DISTANCE); - if (si_changed->onlink) - SET_FLAG(api.flags, ZEBRA_FLAG_ONLINK); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); if (si_changed->distance) { SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE); @@ -397,6 +395,8 @@ extern void static_zebra_route_add(struct route_node *rn, continue; api_nh->vrf_id = si->nh_vrf_id; + api_nh->onlink = si->onlink; + switch (si->type) { case STATIC_IFNAME: if (si->ifindex == IFINDEX_INTERNAL) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index b6d0948d35..951a411f25 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1521,6 +1521,9 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) XFREE(MTYPE_RE, re); return; } + if (api_nh->onlink) + SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK); + /* MPLS labels for BGP-LU or Segment Routing */ if (CHECK_FLAG(api.message, ZAPI_MESSAGE_LABEL) && api_nh->type != NEXTHOP_TYPE_IFINDEX diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 0dc8a05e9c..99ddd438ea 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -277,8 +277,7 @@ struct nexthop *route_entry_nexthop_ipv4_ifindex_add(struct route_entry *re, There was a crash because ifp here was coming to be NULL */ if (ifp) if (connected_is_unnumbered(ifp) - || CHECK_FLAG(re->flags, ZEBRA_FLAG_EVPN_ROUTE) - || CHECK_FLAG(re->flags, ZEBRA_FLAG_ONLINK)) { + || CHECK_FLAG(re->flags, ZEBRA_FLAG_EVPN_ROUTE)) { SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK); } @@ -315,10 +314,8 @@ struct nexthop *route_entry_nexthop_ipv6_ifindex_add(struct route_entry *re, nexthop->type = NEXTHOP_TYPE_IPV6_IFINDEX; nexthop->gate.ipv6 = *ipv6; nexthop->ifindex = ifindex; - if (CHECK_FLAG(re->flags, ZEBRA_FLAG_EVPN_ROUTE) - || CHECK_FLAG(re->flags, ZEBRA_FLAG_ONLINK)) { + if (CHECK_FLAG(re->flags, ZEBRA_FLAG_EVPN_ROUTE)) SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK); - } route_entry_nexthop_add(re, nexthop); @@ -457,8 +454,15 @@ static int nexthop_active(afi_t afi, struct route_entry *re, */ if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK)) { ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id); - if ((ifp && connected_is_unnumbered(ifp)) - || CHECK_FLAG(re->flags, ZEBRA_FLAG_ONLINK)) { + if (!ifp) { + if (IS_ZEBRA_DEBUG_RIB_DETAILED) + zlog_debug( + "\t%s: Onlink and interface: %u[%u] does not exist", + __PRETTY_FUNCTION__, nexthop->ifindex, + nexthop->vrf_id); + return 0; + } + if (connected_is_unnumbered(ifp)) { if (if_is_operative(ifp)) return 1; else { @@ -468,7 +472,8 @@ static int nexthop_active(afi_t afi, struct route_entry *re, __PRETTY_FUNCTION__, ifp->name); return 0; } - } else { + } + if (!if_is_operative(ifp)) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug( "\t%s: Interface %s is not unnumbered",