aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/fib/fib_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/fib/fib_api.c')
-rw-r--r--src/vnet/fib/fib_api.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/vnet/fib/fib_api.c b/src/vnet/fib/fib_api.c
index 0254c551411..07d6699d87a 100644
--- a/src/vnet/fib/fib_api.c
+++ b/src/vnet/fib/fib_api.c
@@ -65,13 +65,11 @@ static void
fib_api_next_hop_decode (const vl_api_fib_path_t *in,
ip46_address_t *out)
{
- if (in->proto == FIB_API_PATH_NH_PROTO_IP4)
- clib_memcpy (&out->ip4, &in->nh.address.ip4, sizeof (out->ip4));
- else if (in->proto == FIB_API_PATH_NH_PROTO_IP6)
- clib_memcpy (&out->ip6, &in->nh.address.ip6, sizeof (out->ip6));
+ ASSERT (FIB_API_PATH_NH_PROTO_IP4 == in->proto || FIB_API_PATH_NH_PROTO_IP6 == in->proto);
+ *out = to_ip46 (FIB_API_PATH_NH_PROTO_IP6 == in->proto, (void *)&in->nh.address);
}
-static vl_api_fib_path_nh_proto_t
+vl_api_fib_path_nh_proto_t
fib_api_path_dpo_proto_to_nh (dpo_proto_t dproto)
{
switch (dproto)
@@ -110,7 +108,7 @@ fib_api_next_hop_encode (const fib_route_path_t *rpath,
sizeof (rpath->frp_addr.ip6));
}
-static int
+int
fib_api_path_nh_proto_to_dpo (vl_api_fib_path_nh_proto_t pp,
dpo_proto_t *dproto)
{
@@ -296,22 +294,17 @@ fib_api_path_decode (vl_api_fib_path_t *in,
if (!(out->frp_flags & FIB_ROUTE_PATH_BIER_IMP))
{
- fib_api_next_hop_decode(in, &out->frp_addr);
+ index_t bdti;
+
+ bdti = bier_disp_table_find(ntohl(in->table_id));
- if (ip46_address_is_zero(&out->frp_addr))
+ if (INDEX_INVALID != bdti)
+ {
+ out->frp_fib_index = bdti;
+ }
+ else
{
- index_t bdti;
-
- bdti = bier_disp_table_find(ntohl(in->table_id));
-
- if (INDEX_INVALID != bdti)
- {
- out->frp_fib_index = bdti;
- }
- else
- {
- return (VNET_API_ERROR_NO_SUCH_FIB);
- }
+ return (VNET_API_ERROR_NO_SUCH_FIB);
}
}
break;
@@ -455,6 +448,9 @@ fib_api_route_add_del (u8 is_add,
fib_entry_flag_t entry_flags,
fib_route_path_t *rpaths)
{
+ if (!fib_prefix_validate(prefix)) {
+ return (VNET_API_ERROR_INVALID_PREFIX_LENGTH);
+ }
if (is_multipath)
{
if (vec_len(rpaths) == 0)