From fe85601c961738e8867a7f2411054dcf4e34d0c3 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 26 Jan 2019 20:44:42 -0500 Subject: *: The onlink attribute should be owned by the nexthop not the route. The onlink attribute was being passed from upper level protocols as an attribute of the route *not* the individual nexthop. When we pass this data to the kernel, we treat the onlink as a attribute of the nexthop. This commit modifies the code base to allow us to pass the ONLINK attribute as an attribute of the nexthop. This commit also fixes static routes that have multiple nexthops some onlink and some not. ip route 4.5.6.7/32 192.168.41.1 eveth1 onlink ip route 4.5.6.7/32 192.168.42.2 S>* 4.5.6.7/32 [1/0] via 192.168.41.1, eveth1 onlink, 00:03:04 * via 192.168.42.2, eveth2, 00:03:04 sharpd@robot ~/frr2> sudo ip netns exec EVA ip route show 4.5.6.7 proto 196 metric 20 nexthop via 192.168.41.1 dev eveth1 weight 1 onlink nexthop via 192.168.42.2 dev eveth2 weight 1 Signed-off-by: Donald Sharp --- zebra/zebra_rib.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'zebra/zebra_rib.c') diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 0dc8a05e9..99ddd438e 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", -- cgit v1.2.3