zebra: use link scope for interface routes
In linux, 'scope' is a hint of distance of the IP. And this is
evident from the fact that only lower scope can be used as recursive
via lookup result. This changes all interface routes scope to link
so kernel will allow regular routes to use it as via. Then we do
not need to use the 'onlink' attribute.
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 4625cea..6e22d63 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -1638,7 +1638,7 @@
req.r.rtm_table = rib->table;
req.r.rtm_dst_len = p->prefixlen;
req.r.rtm_protocol = RTPROT_ZEBRA;
- req.r.rtm_scope = RT_SCOPE_UNIVERSE;
+ req.r.rtm_scope = RT_SCOPE_LINK;
if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT))
discard = 1;
@@ -1706,6 +1706,10 @@
if (cmd == RTM_DELROUTE && !CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
continue;
+ if (nexthop->type != NEXTHOP_TYPE_IFINDEX &&
+ nexthop->type != NEXTHOP_TYPE_IFNAME)
+ req.r.rtm_scope = RT_SCOPE_UNIVERSE;
+
nexthop_num++;
}