Merge pull request #1090 from opensourcerouting/rib_issues

RIB issues
This commit is contained in:
Donald Sharp 2017-09-03 17:59:14 -04:00 committed by GitHub
commit 650e74d71a
4 changed files with 30 additions and 30 deletions

View File

@ -45,9 +45,6 @@ struct route_entry {
/* Nexthop structure */ /* Nexthop structure */
struct nexthop *nexthop; struct nexthop *nexthop;
/* Refrence count. */
unsigned long refcnt;
/* Tag */ /* Tag */
route_tag_t tag; route_tag_t tag;

View File

@ -491,17 +491,26 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
size_t sz = (afi == AFI_IP) ? 4 : 16; size_t sz = (afi == AFI_IP) ? 4 : 16;
memset(&nh, 0, sizeof(nh)); memset(&nh, 0, sizeof(nh));
if (index && !gate) if (bh_type == BLACKHOLE_UNSPEC) {
nh.type = NEXTHOP_TYPE_IFINDEX; if (index && !gate)
else if (index && gate) nh.type = NEXTHOP_TYPE_IFINDEX;
nh.type = (afi == AFI_IP) else if (index && gate)
? NEXTHOP_TYPE_IPV4_IFINDEX nh.type =
: NEXTHOP_TYPE_IPV6_IFINDEX; (afi == AFI_IP)
else if (!index && gate) ? NEXTHOP_TYPE_IPV4_IFINDEX
nh.type = (afi == AFI_IP) ? NEXTHOP_TYPE_IPV4 : NEXTHOP_TYPE_IPV6_IFINDEX;
else if (!index && gate)
nh.type = (afi == AFI_IP)
? NEXTHOP_TYPE_IPV4
: NEXTHOP_TYPE_IPV6; : NEXTHOP_TYPE_IPV6;
else else {
nh.type = NEXTHOP_TYPE_BLACKHOLE;
nh.bh_type = BLACKHOLE_UNSPEC;
}
} else {
nh.type = NEXTHOP_TYPE_BLACKHOLE; nh.type = NEXTHOP_TYPE_BLACKHOLE;
nh.bh_type = bh_type;
}
nh.ifindex = index; nh.ifindex = index;
if (gate) if (gate)
memcpy(&nh.gate, gate, sz); memcpy(&nh.gate, gate, sz);

View File

@ -2061,10 +2061,9 @@ void _route_entry_dump(const char *func, union prefixconstptr pp,
is_srcdst ? prefix2str(src_pp, srcaddr, sizeof(srcaddr)) is_srcdst ? prefix2str(src_pp, srcaddr, sizeof(srcaddr))
: "", : "",
re->vrf_id); re->vrf_id);
zlog_debug( zlog_debug("%s: uptime == %lu, type == %u, instance == %d, table == %d",
"%s: refcnt == %lu, uptime == %lu, type == %u, instance == %d, table == %d", func, (unsigned long)re->uptime, re->type, re->instance,
func, re->refcnt, (unsigned long)re->uptime, re->type, re->table);
re->instance, re->table);
zlog_debug( zlog_debug(
"%s: metric == %u, mtu == %u, distance == %u, flags == %u, status == %u", "%s: metric == %u, mtu == %u, distance == %u, flags == %u, status == %u",
func, re->metric, re->mtu, re->distance, re->flags, re->status); 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) { && rtnh->type == NEXTHOP_TYPE_IFINDEX && nh) {
if (rtnh->ifindex != nh->ifindex) if (rtnh->ifindex != nh->ifindex)
continue; continue;
if (re->refcnt) {
re->refcnt--;
route_unlock_node(rn);
route_unlock_node(rn);
return;
}
same = re; same = re;
break; 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; break;
} }
/* Duplicate system route comes in. */ /* Duplicate system route comes in. */
else if ((rtnh = re->nexthop) rtnh = re->nexthop;
&& rtnh->type == NEXTHOP_TYPE_IFINDEX if (nexthop_same_no_recurse(rtnh, nh))
&& rtnh->ifindex == nh->ifindex
&& !CHECK_FLAG(re->status, ROUTE_ENTRY_REMOVED)) {
re->refcnt++;
return 0; 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. */ /* Allocate new re structure. */

View File

@ -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)) if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED))
vty_out(vty, ", best"); vty_out(vty, ", best");
if (re->refcnt)
vty_out(vty, ", refcnt %ld", re->refcnt);
vty_out(vty, "\n"); vty_out(vty, "\n");
if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF if (re->type == ZEBRA_ROUTE_RIP || re->type == ZEBRA_ROUTE_OSPF