diff --git a/zebra/rib.h b/zebra/rib.h index 9b1ce23b08..4cc69377d8 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -45,9 +45,6 @@ struct route_entry { /* Nexthop structure */ struct nexthop *nexthop; - /* Refrence count. */ - unsigned long refcnt; - /* Tag */ route_tag_t tag; diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index c58a7aa2fa..f05025e630 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -491,17 +491,26 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl, size_t sz = (afi == AFI_IP) ? 4 : 16; memset(&nh, 0, sizeof(nh)); - if (index && !gate) - nh.type = NEXTHOP_TYPE_IFINDEX; - else if (index && gate) - nh.type = (afi == AFI_IP) - ? NEXTHOP_TYPE_IPV4_IFINDEX - : NEXTHOP_TYPE_IPV6_IFINDEX; - else if (!index && gate) - nh.type = (afi == AFI_IP) ? NEXTHOP_TYPE_IPV4 + if (bh_type == BLACKHOLE_UNSPEC) { + if (index && !gate) + nh.type = NEXTHOP_TYPE_IFINDEX; + else if (index && gate) + nh.type = + (afi == AFI_IP) + ? NEXTHOP_TYPE_IPV4_IFINDEX + : NEXTHOP_TYPE_IPV6_IFINDEX; + else if (!index && gate) + nh.type = (afi == AFI_IP) + ? NEXTHOP_TYPE_IPV4 : NEXTHOP_TYPE_IPV6; - else + else { + nh.type = NEXTHOP_TYPE_BLACKHOLE; + nh.bh_type = BLACKHOLE_UNSPEC; + } + } else { nh.type = NEXTHOP_TYPE_BLACKHOLE; + nh.bh_type = bh_type; + } nh.ifindex = index; if (gate) memcpy(&nh.gate, gate, sz); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index bcf21783ae..deb434bd35 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2061,10 +2061,9 @@ void _route_entry_dump(const char *func, union prefixconstptr pp, is_srcdst ? prefix2str(src_pp, srcaddr, sizeof(srcaddr)) : "", re->vrf_id); - zlog_debug( - "%s: refcnt == %lu, uptime == %lu, type == %u, instance == %d, table == %d", - func, re->refcnt, (unsigned long)re->uptime, re->type, - re->instance, re->table); + zlog_debug("%s: uptime == %lu, type == %u, instance == %d, table == %d", + func, (unsigned long)re->uptime, re->type, re->instance, + re->table); zlog_debug( "%s: metric == %u, mtu == %u, distance == %u, flags == %u, status == %u", func, re->metric, re->mtu, re->distance, re->flags, re->status); @@ -2335,12 +2334,6 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, && rtnh->type == NEXTHOP_TYPE_IFINDEX && nh) { if (rtnh->ifindex != nh->ifindex) continue; - if (re->refcnt) { - re->refcnt--; - route_unlock_node(rn); - route_unlock_node(rn); - return; - } same = re; break; } @@ -2476,13 +2469,16 @@ int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, break; } /* Duplicate system route comes in. */ - else if ((rtnh = re->nexthop) - && rtnh->type == NEXTHOP_TYPE_IFINDEX - && rtnh->ifindex == nh->ifindex - && !CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED)) { - re->refcnt++; + rtnh = re->nexthop; + if (nexthop_same_no_recurse(rtnh, nh)) return 0; - } + /* + * Nexthop is different. Remove the old route unless it's + * a link-local route. + */ + else if (afi != AFI_IP6 + || !IN6_IS_ADDR_LINKLOCAL(&p->u.prefix6)) + same = re; } /* Allocate new re structure. */ diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 98ce985344..95ba19b1f6 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -402,8 +402,6 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn, } if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)) vty_out(vty, ", best"); - if (re->refcnt) - vty_out(vty, ", refcnt %ld", re->refcnt); vty_out(vty, "\n"); if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF