From 9a0d4dd39be7cbed048e45b5a27ceb81608d76f6 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 15 Feb 2019 11:39:12 -0500 Subject: [PATCH] zebra: Remove nexthop_active_num from route entry The nexthop_active_num data structure is a property of the nexthop group. Move the keeping of this data to that. Signed-off-by: Donald Sharp --- zebra/rib.h | 3 --- zebra/zapi_msg.c | 13 +++++++------ zebra/zebra_fpm_dt.c | 2 +- zebra/zebra_nhg.c | 16 +++++++++------- zebra/zebra_rib.c | 3 ++- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/zebra/rib.h b/zebra/rib.h index 4bef6e0543..5b5bd4c279 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -135,9 +135,6 @@ struct route_entry { /* Route has Failed installation into the Data Plane in some manner */ #define ROUTE_ENTRY_FAILED 0x20 - /* Nexthop information. */ - uint8_t nexthop_active_num; - /* Sequence value incremented for each dataplane operation */ uint32_t dplane_sequence; diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index d207ee4046..ecbf39dda0 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -522,7 +522,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client, struct zapi_route api; struct zapi_nexthop *api_nh; struct nexthop *nexthop; - int count = 0; + uint8_t count = 0; afi_t afi; size_t stream_size = MAX(ZEBRA_MAX_PACKET_SIZ, sizeof(struct zapi_route)); @@ -559,11 +559,6 @@ int zsend_redistribute_route(int cmd, struct zserv *client, memcpy(&api.src_prefix, src_p, sizeof(api.src_prefix)); } - /* Nexthops. */ - if (re->nexthop_active_num) { - SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); - api.nexthop_num = re->nexthop_active_num; - } for (nexthop = re->ng->nexthop; nexthop; nexthop = nexthop->next) { if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE)) continue; @@ -595,6 +590,12 @@ int zsend_redistribute_route(int cmd, struct zserv *client, count++; } + /* Nexthops. */ + if (count) { + SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); + api.nexthop_num = count; + } + /* Attributes. */ SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE); api.distance = re->distance; diff --git a/zebra/zebra_fpm_dt.c b/zebra/zebra_fpm_dt.c index e87fa0ad71..debcf60ee5 100644 --- a/zebra/zebra_fpm_dt.c +++ b/zebra/zebra_fpm_dt.c @@ -90,7 +90,7 @@ static int zfpm_dt_find_route(rib_dest_t **dest_p, struct route_entry **re_p) if (!re) continue; - if (re->nexthop_active_num <= 0) + if (nexthop_group_active_nexthop_num(re->ng) == 0) continue; *dest_p = dest; diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 407e29f8c3..569bc6e5ec 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -644,9 +644,8 @@ static unsigned nexthop_active_check(struct route_node *rn, /* * Iterate over all nexthops of the given RIB entry and refresh their - * ACTIVE flag. re->nexthop_active_num is updated accordingly. If any - * nexthop is found to toggle the ACTIVE flag, the whole re structure - * is flagged with ROUTE_ENTRY_CHANGED. + * ACTIVE flag. If any nexthop is found to toggle the ACTIVE flag, + * the whole re structure is flagged with ROUTE_ENTRY_CHANGED. * * Return value is the new number of active nexthops. */ @@ -656,8 +655,8 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re) union g_addr prev_src; unsigned int prev_active, new_active; ifindex_t prev_index; + uint8_t curr_active = 0; - re->nexthop_active_num = 0; UNSET_FLAG(re->status, ROUTE_ENTRY_CHANGED); for (nexthop = re->ng->nexthop; nexthop; nexthop = nexthop->next) { @@ -674,12 +673,15 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re) */ new_active = nexthop_active_check(rn, re, nexthop); if (new_active - && re->nexthop_active_num >= zrouter.multipath_num) { + && nexthop_group_active_nexthop_num(re->ng) + >= zrouter.multipath_num) { UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); new_active = 0; } + if (new_active) - re->nexthop_active_num++; + curr_active++; + /* Don't allow src setting on IPv6 addr for now */ if (prev_active != new_active || prev_index != nexthop->ifindex || ((nexthop->type >= NEXTHOP_TYPE_IFINDEX @@ -694,5 +696,5 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re) SET_FLAG(re->status, ROUTE_ENTRY_CHANGED); } - return re->nexthop_active_num; + return curr_active; } diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index c56c953618..d3c6f5ba11 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2481,7 +2481,8 @@ 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, - nexthop_group_nexthop_num(re->ng), re->nexthop_active_num); + nexthop_group_nexthop_num(re->ng), + nexthop_group_active_nexthop_num(re->ng)); for (ALL_NEXTHOPS_PTR(re->ng, nexthop)) { struct interface *ifp; -- 2.39.5