summaryrefslogtreecommitdiff
path: root/zebra/zapi_msg.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zapi_msg.c')
-rw-r--r--zebra/zapi_msg.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index a578395ef8..761ba789b8 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -2034,7 +2034,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
struct nhg_backup_info *bnhg = NULL;
int ret;
vrf_id_t vrf_id;
- struct nhg_hash_entry nhe;
+ struct nhg_hash_entry nhe, *n = NULL;
s = msg;
if (zapi_route_decode(s, &api) < 0) {
@@ -2052,17 +2052,10 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
(int)api.message, api.flags);
/* Allocate new route. */
- re = XCALLOC(MTYPE_RE, sizeof(struct route_entry));
- re->type = api.type;
- re->instance = api.instance;
- re->flags = api.flags;
- re->uptime = monotime(NULL);
- re->vrf_id = vrf_id;
-
- if (api.tableid)
- re->table = api.tableid;
- else
- re->table = zvrf->table_id;
+ re = zebra_rib_route_entry_new(
+ vrf_id, api.type, api.instance, api.flags, api.nhgid,
+ api.tableid ? api.tableid : zvrf->table_id, api.metric, api.mtu,
+ api.distance, api.tag);
if (!CHECK_FLAG(api.message, ZAPI_MESSAGE_NHG)
&& (!CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)
@@ -2087,9 +2080,6 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
&api.prefix);
}
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NHG))
- re->nhe_id = api.nhgid;
-
if (!re->nhe_id
&& (!zapi_read_nexthops(client, &api.prefix, api.nexthops,
api.flags, api.message, api.nexthop_num,
@@ -2105,15 +2095,6 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
return;
}
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_DISTANCE))
- re->distance = api.distance;
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_METRIC))
- re->metric = api.metric;
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_TAG))
- re->tag = api.tag;
- if (CHECK_FLAG(api.message, ZAPI_MESSAGE_MTU))
- re->mtu = api.mtu;
-
if (CHECK_FLAG(api.message, ZAPI_MESSAGE_OPAQUE)) {
re->opaque =
XMALLOC(MTYPE_RE_OPAQUE,
@@ -2161,9 +2142,10 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
zebra_nhe_init(&nhe, afi, ng->nexthop);
nhe.nhg.nexthop = ng->nexthop;
nhe.backup_info = bnhg;
+ n = zebra_nhe_copy(&nhe, 0);
}
- ret = rib_add_multipath_nhe(afi, api.safi, &api.prefix, src_p,
- re, &nhe, false);
+ ret = rib_add_multipath_nhe(afi, api.safi, &api.prefix, src_p, re, n,
+ false);
/*
* rib_add_multipath_nhe only fails in a couple spots