From: Donald Sharp Date: Fri, 15 Feb 2019 16:16:22 +0000 (-0500) Subject: zebra: Remove re->nexthop_num from re X-Git-Tag: base_7.3~219^2~179 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=eecacedc3b9526b59ef690bce41f41158a137c9f;p=matthieu%2Ffrr.git 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 --- diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 65b62679e8..42f8c812b4 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -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(); diff --git a/zebra/rib.h b/zebra/rib.h index 455003c930..4bef6e0543 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -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 */ diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 9bc919463b..b36fbb2008 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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 diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index c8ba3f9e9d..c56c953618 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -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(); diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 1494e3bed3..af3c1b818f 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -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))