summaryrefslogtreecommitdiff
path: root/zebra/zapi_msg.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-02-13 16:06:48 -0500
committerStephen Worley <sworley@cumulusnetworks.com>2019-10-25 11:13:36 -0400
commit6b46851168ef37eaacba28a2a655e15ae5934cd0 (patch)
tree8e77f5c84e8fc6d9f564a6b33fb2008e6bf5f234 /zebra/zapi_msg.c
parent79580b5ac4ba584baf2a50825949abff18c77f91 (diff)
zebra: Replace nexthop_group with pointer in route entry
In the route_entry we are keeping a non pointer based nexthop group, switch the code to use a pointer for all operations here and ensure we create and delete the memory. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/zapi_msg.c')
-rw-r--r--zebra/zapi_msg.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index e61e68b7fe..d207ee4046 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -564,7 +564,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client,
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;
@@ -665,7 +665,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 +1423,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 +1436,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 +1536,8 @@ 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);
+ nexthops_free(re->ng->nexthop);
+ nexthop_group_delete(&re->ng);
XFREE(MTYPE_RE, re);
return;
}
@@ -1573,7 +1579,8 @@ 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);
+ nexthops_free(re->ng->nexthop);
+ nexthop_group_delete(&re->ng);
XFREE(MTYPE_RE, re);
return;
}