zebra: Remove re->nexthop_num from re

The nexthop_num is not a function of the re.  It is owned
by the nexthop group.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2019-02-15 11:16:22 -05:00 committed by Stephen Worley
parent 6b46851168
commit eecacedc3b
5 changed files with 8 additions and 15 deletions

View File

@ -676,7 +676,6 @@ int zebra_add_import_table_entry(struct zebra_vrf *zvrf, struct route_node *rn,
newre->metric = re->metric;
newre->mtu = re->mtu;
newre->table = zvrf->table_id;
newre->nexthop_num = 0;
newre->uptime = monotime(NULL);
newre->instance = re->table;
newre->ng = nexthop_group_new();

View File

@ -136,7 +136,6 @@ struct route_entry {
#define ROUTE_ENTRY_FAILED 0x20
/* Nexthop information. */
uint8_t nexthop_num;
uint8_t nexthop_active_num;
/* Sequence value incremented for each dataplane operation */

View File

@ -609,7 +609,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
&src_p, &nh, table, metric, mtu, distance, tag);
} else {
/* This is a multipath route */
uint8_t nhop_num;
struct route_entry *re;
struct rtnexthop *rtnh =
(struct rtnexthop *)RTA_DATA(tb[RTA_MULTIPATH]);
@ -624,7 +624,6 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
re->mtu = mtu;
re->vrf_id = vrf_id;
re->table = table;
re->nexthop_num = 0;
re->uptime = monotime(NULL);
re->tag = tag;
re->ng = nexthop_group_new();
@ -720,10 +719,10 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
rtnh = RTNH_NEXT(rtnh);
}
zserv_nexthop_num_warn(__func__,
(const struct prefix *)&p,
re->nexthop_num);
if (re->nexthop_num == 0) {
nhop_num = nexthop_group_nexthop_num(re->ng);
zserv_nexthop_num_warn(
__func__, (const struct prefix *)&p, nhop_num);
if (nhop_num == 0) {
nexthop_group_delete(&re->ng);
XFREE(MTYPE_RE, re);
} else

View File

@ -197,7 +197,6 @@ int zebra_check_addr(const struct prefix *p)
void route_entry_nexthop_add(struct route_entry *re, struct nexthop *nexthop)
{
_nexthop_group_add_sorted(re->ng, nexthop);
re->nexthop_num++;
}
@ -208,8 +207,6 @@ void route_entry_copy_nexthops(struct route_entry *re, struct nexthop *nh)
{
assert(!re->ng->nexthop);
copy_nexthops(&re->ng->nexthop, nh, NULL);
for (struct nexthop *nexthop = nh; nexthop; nexthop = nexthop->next)
re->nexthop_num++;
}
/* Delete specified nexthop from the list. */
@ -221,7 +218,6 @@ void route_entry_nexthop_delete(struct route_entry *re, struct nexthop *nexthop)
nexthop->prev->next = nexthop->next;
else
re->ng->nexthop = nexthop->next;
re->nexthop_num--;
}
@ -2485,7 +2481,7 @@ void _route_entry_dump(const char *func, union prefixconstptr pp,
"%s: metric == %u, mtu == %u, distance == %u, flags == %u, status == %u",
straddr, re->metric, re->mtu, re->distance, re->flags, re->status);
zlog_debug("%s: nexthop_num == %u, nexthop_active_num == %u", straddr,
re->nexthop_num, re->nexthop_active_num);
nexthop_group_nexthop_num(re->ng), re->nexthop_active_num);
for (ALL_NEXTHOPS_PTR(re->ng, nexthop)) {
struct interface *ifp;
@ -2959,7 +2955,6 @@ int rib_add(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
re->mtu = mtu;
re->table = table_id;
re->vrf_id = vrf_id;
re->nexthop_num = 0;
re->uptime = monotime(NULL);
re->tag = tag;
re->ng = nexthop_group_new();

View File

@ -984,7 +984,8 @@ static int compare_state(struct route_entry *r1, struct route_entry *r2)
if (r1->metric != r2->metric)
return 1;
if (r1->nexthop_num != r2->nexthop_num)
if (nexthop_group_nexthop_num(r1->ng)
!= nexthop_group_nexthop_num(r2->ng))
return 1;
if (nexthop_group_hash(r1->ng) != nexthop_group_hash(r2->ng))