diff options
Diffstat (limited to 'zebra/zapi_msg.c')
| -rw-r--r-- | zebra/zapi_msg.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index e61e68b7fe..d6ade783cf 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,12 +559,7 @@ 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) { + 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; @@ -665,7 +666,8 @@ static int zsend_ipv4_nexthop_lookup_mrib(struct zserv *client, * nexthop we are looking up. Therefore, we will just iterate * over the top chain of nexthops. */ - for (nexthop = re->ng.nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->ng->nexthop; nexthop; + nexthop = nexthop->next) if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE)) num += zserv_encode_nexthop(s, nexthop); @@ -1422,6 +1424,8 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) re->flags = api.flags; re->uptime = monotime(NULL); re->vrf_id = vrf_id; + re->ng = nexthop_group_new(); + if (api.tableid) re->table = api.tableid; else @@ -1433,6 +1437,8 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) "%s: received a route without nexthops for prefix %pFX from client %s", __func__, &api.prefix, zebra_route_string(client->proto)); + + nexthop_group_delete(&re->ng); XFREE(MTYPE_RE, re); return; } @@ -1531,7 +1537,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) EC_ZEBRA_NEXTHOP_CREATION_FAILED, "%s: Nexthops Specified: %d but we failed to properly create one", __PRETTY_FUNCTION__, api.nexthop_num); - nexthops_free(re->ng.nexthop); + nexthop_group_delete(&re->ng); XFREE(MTYPE_RE, re); return; } @@ -1573,7 +1579,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) flog_warn(EC_ZEBRA_RX_SRCDEST_WRONG_AFI, "%s: Received SRC Prefix but afi is not v6", __PRETTY_FUNCTION__); - nexthops_free(re->ng.nexthop); + nexthop_group_delete(&re->ng); XFREE(MTYPE_RE, re); return; } @@ -1627,7 +1633,7 @@ static void zread_route_del(ZAPI_HANDLER_ARGS) table_id = zvrf->table_id; rib_delete(afi, api.safi, zvrf_id(zvrf), api.type, api.instance, - api.flags, &api.prefix, src_p, NULL, table_id, api.metric, + api.flags, &api.prefix, src_p, NULL, 0, table_id, api.metric, api.distance, false); /* Stats */ |
