summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vnet/CMakeLists.txt5
-rw-r--r--src/vnet/fib/fib.api52
-rw-r--r--src/vnet/fib/fib_api.c119
-rw-r--r--src/vnet/fib/fib_api.h1
-rw-r--r--src/vnet/fib/fib_table.c36
-rw-r--r--src/vnet/fib/fib_table.h11
-rw-r--r--src/vnet/fib/fib_types.api2
-rw-r--r--src/vnet/ip/ip.api62
-rw-r--r--src/vnet/ip/ip_api.c218
-rw-r--r--src/vnet/mpls/mpls_api.c12
10 files changed, 486 insertions, 32 deletions
diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt
index eecb18c937b..1ff2a8c7e58 100644
--- a/src/vnet/CMakeLists.txt
+++ b/src/vnet/CMakeLists.txt
@@ -1214,7 +1214,10 @@ list(APPEND VNET_HEADERS
fib/fib_source.h
)
-list(APPEND VNET_API_FILES fib/fib_types.api)
+list(APPEND VNET_API_FILES
+ fib/fib_types.api
+ fib/fib.api
+)
##############################################################################
# ADJ
diff --git a/src/vnet/fib/fib.api b/src/vnet/fib/fib.api
new file mode 100644
index 00000000000..ad83b7402f8
--- /dev/null
+++ b/src/vnet/fib/fib.api
@@ -0,0 +1,52 @@
+/* Hey Emacs use -*- mode: C -*- */
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+option version = "1.0.0";
+
+import "vnet/fib/fib_types.api";
+
+typedef fib_source
+{
+ u8 priority;
+ u8 id;
+ string name[64];
+};
+
+define fib_source_add
+{
+ u32 client_index;
+ u32 context;
+ vl_api_fib_source_t src;
+};
+
+define fib_source_add_reply
+{
+ u32 context;
+ i32 retval;
+ u8 id;
+};
+
+define fib_source_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+define fib_source_details
+{
+ u32 context;
+ vl_api_fib_source_t src;
+};
diff --git a/src/vnet/fib/fib_api.c b/src/vnet/fib/fib_api.c
index d626ae24502..0254c551411 100644
--- a/src/vnet/fib/fib_api.c
+++ b/src/vnet/fib/fib_api.c
@@ -22,23 +22,13 @@
#include <vnet/bier/bier_disp_table.h>
#include <vpp/api/types.h>
#include <vnet/classify/vnet_classify.h>
+#include <vnet/ip/ip_format_fns.h>
-#include <vnet/vnet_msg_enum.h>
-
-#define vl_typedefs /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <vnet/vnet_all_api_h.h>
-#undef vl_printfun
+#include <vnet/fib/fib.api_enum.h>
+#include <vnet/fib/fib.api_types.h>
+static u16 fib_base_msg_id;
+#define REPLY_MSG_ID_BASE fib_base_msg_id
#include <vlibapi/api_helper_macros.h>
int
@@ -461,6 +451,7 @@ fib_api_route_add_del (u8 is_add,
u8 is_multipath,
u32 fib_index,
const fib_prefix_t * prefix,
+ fib_source_t src,
fib_entry_flag_t entry_flags,
fib_route_path_t *rpaths)
{
@@ -473,13 +464,13 @@ fib_api_route_add_del (u8 is_add,
if (is_add)
fib_table_entry_path_add2 (fib_index,
prefix,
- FIB_SOURCE_API,
+ src,
entry_flags,
rpaths);
else
fib_table_entry_path_remove2 (fib_index,
prefix,
- FIB_SOURCE_API,
+ src,
rpaths);
}
else
@@ -492,7 +483,7 @@ fib_api_route_add_del (u8 is_add,
/* path replacement */
fib_table_entry_update (fib_index,
prefix,
- FIB_SOURCE_API,
+ src,
entry_flags,
rpaths);
}
@@ -500,7 +491,7 @@ fib_api_route_add_del (u8 is_add,
/* entry delete */
fib_table_entry_delete (fib_index,
prefix,
- FIB_SOURCE_API);
+ src);
}
return (0);
@@ -569,3 +560,93 @@ fib_proto_to_api_address_family (fib_protocol_t fproto)
ASSERT(0);
return (ADDRESS_IP4);
}
+
+void
+vl_api_fib_source_add_t_handler (vl_api_fib_source_add_t * mp)
+{
+ vl_api_fib_source_add_reply_t *rmp;
+ fib_source_t src;
+ int rv = 0;
+ u8 *name;
+
+ name = format (0, "%s", mp->src.name);
+ vec_add1 (name, 0);
+
+ src = fib_source_allocate((const char *)name,
+ mp->src.priority,
+ FIB_SOURCE_BH_API);
+
+ vec_free(name);
+
+ REPLY_MACRO2 (VL_API_FIB_SOURCE_ADD_REPLY,
+ ({
+ rmp->id = src;
+ }));
+}
+
+typedef struct fib_source_dump_ctx_t_
+{
+ vl_api_registration_t * reg;
+ u32 context;
+} fib_source_dump_ctx_t;
+
+static walk_rc_t
+send_fib_source (fib_source_t id,
+ const char *name,
+ fib_source_priority_t prio,
+ fib_source_behaviour_t bh,
+ void *data)
+{
+ vl_api_fib_source_details_t *mp;
+ fib_source_dump_ctx_t *ctx;
+
+ ctx = data;
+ mp = vl_msg_api_alloc_zero (sizeof (*mp));
+ if (!mp)
+ return WALK_STOP;
+
+ mp->_vl_msg_id = ntohs (VL_API_FIB_SOURCE_DETAILS + REPLY_MSG_ID_BASE);
+ mp->context = ctx->context;
+
+ mp->src.priority = prio;
+ mp->src.id = id;
+ clib_memcpy(mp->src.name, name,
+ clib_min(strlen(name), ARRAY_LEN(mp->src.name)));
+
+ vl_api_send_msg (ctx->reg, (u8 *) mp);
+
+ return (WALK_CONTINUE);
+}
+
+void
+vl_api_fib_source_dump_t_handler (vl_api_fib_source_dump_t * mp)
+{
+ vl_api_registration_t *reg;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ fib_source_dump_ctx_t ctx = {
+ .reg = reg,
+ .context = mp->context,
+ };
+
+ fib_source_walk(send_fib_source, &ctx);
+}
+
+
+#include <vnet/fib/fib.api.c>
+
+static clib_error_t *
+fib_api_hookup (vlib_main_t * vm)
+{
+ /*
+ * Set up the (msg_name, crc, message-id) table
+ */
+ fib_base_msg_id = setup_message_id_table ();
+
+ return (NULL);
+}
+
+VLIB_API_INIT_FUNCTION (fib_api_hookup);
diff --git a/src/vnet/fib/fib_api.h b/src/vnet/fib/fib_api.h
index caa993b78d0..7fd7d16cb33 100644
--- a/src/vnet/fib/fib_api.h
+++ b/src/vnet/fib/fib_api.h
@@ -45,6 +45,7 @@ extern int fib_api_route_add_del (u8 is_add,
u8 is_multipath,
u32 fib_index,
const fib_prefix_t * prefix,
+ fib_source_t src,
fib_entry_flag_t entry_flags,
fib_route_path_t *rpaths);
diff --git a/src/vnet/fib/fib_table.c b/src/vnet/fib/fib_table.c
index e71e6c36bfb..eaeee5bb921 100644
--- a/src/vnet/fib/fib_table.c
+++ b/src/vnet/fib/fib_table.c
@@ -1255,6 +1255,42 @@ fib_table_walk (u32 fib_index,
}
}
+typedef struct fib_table_walk_w_src_ctx_t_
+{
+ fib_table_walk_fn_t fn;
+ void *data;
+ fib_source_t src;
+} fib_table_walk_w_src_cxt_t;
+
+static fib_table_walk_rc_t
+fib_table_walk_w_src_cb (fib_node_index_t fei,
+ void *arg)
+{
+ fib_table_walk_w_src_cxt_t *ctx = arg;
+
+ if (ctx->src == fib_entry_get_best_source(fei))
+ {
+ return (ctx->fn(fei, ctx->data));
+ }
+ return (FIB_TABLE_WALK_CONTINUE);
+}
+
+void
+fib_table_walk_w_src (u32 fib_index,
+ fib_protocol_t proto,
+ fib_source_t src,
+ fib_table_walk_fn_t fn,
+ void *data)
+{
+ fib_table_walk_w_src_cxt_t ctx = {
+ .fn = fn,
+ .src = src,
+ .data = data,
+ };
+
+ fib_table_walk(fib_index, proto, fib_table_walk_w_src_cb, &ctx);
+}
+
void
fib_table_sub_tree_walk (u32 fib_index,
fib_protocol_t proto,
diff --git a/src/vnet/fib/fib_table.h b/src/vnet/fib/fib_table.h
index 201170707a8..11137e173cf 100644
--- a/src/vnet/fib/fib_table.h
+++ b/src/vnet/fib/fib_table.h
@@ -941,6 +941,17 @@ extern void fib_table_walk(u32 fib_index,
void *ctx);
/**
+ * @brief Walk all entries in a FIB table
+ * N.B: This is NOT safe to deletes. If you need to delete walk the whole
+ * table and store elements in a vector, then delete the elements
+ */
+extern void fib_table_walk_w_src(u32 fib_index,
+ fib_protocol_t proto,
+ fib_source_t src,
+ fib_table_walk_fn_t fn,
+ void *ctx);
+
+/**
* @brief Walk all entries in a sub-tree FIB table. The 'root' paraneter
* is the prefix at the root of the sub-tree.
* N.B: This is NOT safe to deletes. If you need to delete walk the whole
diff --git a/src/vnet/fib/fib_types.api b/src/vnet/fib/fib_types.api
index 4a5cea79064..c5fbcf8fc29 100644
--- a/src/vnet/fib/fib_types.api
+++ b/src/vnet/fib/fib_types.api
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-option version = "2.0.0";
+option version = "2.0.1";
import "vnet/ip/ip_types.api";
/** \brief MPLS label
diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api
index f49fc16bc1d..c8d4c397182 100644
--- a/src/vnet/ip/ip.api
+++ b/src/vnet/ip/ip.api
@@ -20,7 +20,7 @@
called through a shared memory interface.
*/
-option version = "3.0.3";
+option version = "3.1.0";
import "vnet/interface_types.api";
import "vnet/fib/fib_types.api";
@@ -135,6 +135,8 @@ define ip_table_details
@param stats_index The index of the route in the stats segment
@param prefix the prefix for the route
@param n_paths The number of paths the route has
+ @param src The entity adding the route. either 0 for default
+ or a value returned from fib_source_sdd.
@param paths The paths of the route
*/
typedef ip_route
@@ -145,6 +147,15 @@ typedef ip_route
u8 n_paths;
vl_api_fib_path_t paths[n_paths];
};
+typedef ip_route_v2
+{
+ u32 table_id;
+ u32 stats_index;
+ vl_api_prefix_t prefix;
+ u8 n_paths;
+ u8 src;
+ vl_api_fib_path_t paths[n_paths];
+};
/** \brief Add / del route request
@param client_index - opaque cookie to identify the sender
@@ -163,15 +174,33 @@ define ip_route_add_del
bool is_multipath;
vl_api_ip_route_t route;
};
+define ip_route_add_del_v2
+{
+ option in_progress;
+ u32 client_index;
+ u32 context;
+ bool is_add [default=true];
+ bool is_multipath;
+ vl_api_ip_route_v2_t route;
+};
define ip_route_add_del_reply
{
u32 context;
i32 retval;
u32 stats_index;
};
+define ip_route_add_del_v2_reply
+{
+ option in_progress;
+ u32 context;
+ i32 retval;
+ u32 stats_index;
+};
/** \brief Dump IP routes from a table
@param client_index - opaque cookie to identify the sender
+ @param src The entity adding the route. either 0 for default
+ or a value returned from fib_source_sdd.
@param table - The table from which to dump routes (ony ID an AF are needed)
*/
define ip_route_dump
@@ -180,6 +209,15 @@ define ip_route_dump
u32 context;
vl_api_ip_table_t table;
};
+define ip_route_v2_dump
+{
+ option in_progress;
+ u32 client_index;
+ u32 context;
+ /* vl_api_fib_source_t src; */
+ u8 src;
+ vl_api_ip_table_t table;
+};
/** \brief IP FIB table entry response
@param route The route entry in the table
@@ -189,6 +227,12 @@ define ip_route_details
u32 context;
vl_api_ip_route_t route;
};
+define ip_route_v2_details
+{
+ option in_progress;
+ u32 context;
+ vl_api_ip_route_v2_t route;
+};
/** \brief Lookup IP route from a table
@param client_index - opaque cookie to identify the sender
@@ -204,6 +248,15 @@ define ip_route_lookup
u8 exact;
vl_api_prefix_t prefix;
};
+define ip_route_lookup_v2
+{
+ option in_progress;
+ u32 client_index;
+ u32 context;
+ u32 table_id;
+ u8 exact;
+ vl_api_prefix_t prefix;
+};
/** \brief IP FIB table lookup response
@param retval - return code of the lookup
@@ -215,6 +268,13 @@ define ip_route_lookup_reply
i32 retval;
vl_api_ip_route_t route;
};
+define ip_route_lookup_v2_reply
+{
+ option in_progress;
+ u32 context;
+ i32 retval;
+ vl_api_ip_route_v2_t route;
+};
/** \brief Set the ip flow hash config for a fib request
@param client_index - opaque cookie to identify the sender
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 5b87f7cc86a..91b12e5896a 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -72,6 +72,7 @@
_ (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable) \
_ (IP_TABLE_DUMP, ip_table_dump) \
_ (IP_ROUTE_DUMP, ip_route_dump) \
+ _ (IP_ROUTE_V2_DUMP, ip_route_v2_dump) \
_ (IP_MTABLE_DUMP, ip_mtable_dump) \
_ (IP_MROUTE_DUMP, ip_mroute_dump) \
_ (IP_MROUTE_ADD_DEL, ip_mroute_add_del) \
@@ -83,7 +84,9 @@
_ (IP_TABLE_REPLACE_END, ip_table_replace_end) \
_ (IP_TABLE_FLUSH, ip_table_flush) \
_ (IP_ROUTE_ADD_DEL, ip_route_add_del) \
+ _ (IP_ROUTE_ADD_DEL_V2, ip_route_add_del_v2) \
_ (IP_ROUTE_LOOKUP, ip_route_lookup) \
+ _ (IP_ROUTE_LOOKUP_V2, ip_route_lookup_v2) \
_ (IP_TABLE_ADD_DEL, ip_table_add_del) \
_ (IP_PUNT_POLICE, ip_punt_police) \
_ (IP_PUNT_REDIRECT, ip_punt_redirect) \
@@ -235,6 +238,47 @@ send_ip_route_details (vpe_api_main_t * am,
vec_free (rpaths);
}
+static void
+send_ip_route_v2_details (vpe_api_main_t *am, vl_api_registration_t *reg,
+ u32 context, fib_node_index_t fib_entry_index)
+{
+ fib_route_path_t *rpaths, *rpath;
+ vl_api_ip_route_v2_details_t *mp;
+ const fib_prefix_t *pfx;
+ vl_api_fib_path_t *fp;
+ int path_count;
+
+ rpaths = NULL;
+ pfx = fib_entry_get_prefix (fib_entry_index);
+ rpaths = fib_entry_encode (fib_entry_index);
+
+ path_count = vec_len (rpaths);
+ mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
+ if (!mp)
+ return;
+ clib_memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_IP_ROUTE_V2_DETAILS);
+ mp->context = context;
+
+ ip_prefix_encode (pfx, &mp->route.prefix);
+ mp->route.table_id = htonl (fib_table_get_table_id (
+ fib_entry_get_fib_index (fib_entry_index), pfx->fp_proto));
+ mp->route.n_paths = path_count;
+ mp->route.src = fib_entry_get_best_source (fib_entry_index);
+ mp->route.stats_index = htonl (fib_table_entry_get_stats_index (
+ fib_entry_get_fib_index (fib_entry_index), pfx));
+
+ fp = mp->route.paths;
+ vec_foreach (rpath, rpaths)
+ {
+ fib_api_path_encode (rpath, fp);
+ fp++;
+ }
+
+ vl_api_send_msg (reg, (u8 *) mp);
+ vec_free (rpaths);
+}
+
typedef struct apt_ip6_fib_show_ctx_t_
{
fib_node_index_t *entries;
@@ -274,6 +318,45 @@ vl_api_ip_route_dump_t_handler (vl_api_ip_route_dump_t * mp)
}
static void
+vl_api_ip_route_v2_dump_t_handler (vl_api_ip_route_v2_dump_t *mp)
+{
+ vpe_api_main_t *am = &vpe_api_main;
+ fib_node_index_t *fib_entry_index;
+ vl_api_registration_t *reg;
+ fib_protocol_t fproto;
+ fib_source_t src;
+ u32 fib_index;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ vl_api_ip_fib_dump_walk_ctx_t ctx = {
+ .feis = NULL,
+ };
+
+ fproto = (mp->table.is_ip6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
+ fib_index = fib_table_find (fproto, ntohl (mp->table.table_id));
+ src = mp->src;
+
+ if (INDEX_INVALID == fib_index)
+ return;
+
+ if (src)
+ fib_table_walk_w_src (fib_index, fproto, src, vl_api_ip_fib_dump_walk,
+ &ctx);
+ else
+ fib_table_walk (fib_index, fproto, vl_api_ip_fib_dump_walk, &ctx);
+
+ vec_foreach (fib_entry_index, ctx.feis)
+ {
+ send_ip_route_v2_details (am, reg, mp->context, *fib_entry_index);
+ }
+
+ vec_free (ctx.feis);
+}
+
+static void
send_ip_mtable_details (vl_api_registration_t * reg,
u32 context, const mfib_table_t * mfib_table)
{
@@ -584,9 +667,60 @@ ip_route_add_del_t_handler (vl_api_ip_route_add_del_t * mp, u32 * stats_index)
goto out;
}
- rv = fib_api_route_add_del (mp->is_add,
- mp->is_multipath,
- fib_index, &pfx, entry_flags, rpaths);
+ rv = fib_api_route_add_del (mp->is_add, mp->is_multipath, fib_index, &pfx,
+ FIB_SOURCE_API, entry_flags, rpaths);
+
+ if (mp->is_add && 0 == rv)
+ *stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);
+
+out:
+ vec_free (rpaths);
+
+ return (rv);
+}
+
+static int
+ip_route_add_del_v2_t_handler (vl_api_ip_route_add_del_v2_t *mp,
+ u32 *stats_index)
+{
+ fib_route_path_t *rpaths = NULL, *rpath;
+ fib_entry_flag_t entry_flags;
+ vl_api_fib_path_t *apath;
+ fib_source_t src;
+ fib_prefix_t pfx;
+ u32 fib_index;
+ int rv, ii;
+
+ entry_flags = FIB_ENTRY_FLAG_NONE;
+ ip_prefix_decode (&mp->route.prefix, &pfx);
+
+ rv = fib_api_table_id_decode (pfx.fp_proto, ntohl (mp->route.table_id),
+ &fib_index);
+ if (0 != rv)
+ goto out;
+
+ if (0 != mp->route.n_paths)
+ vec_validate (rpaths, mp->route.n_paths - 1);
+
+ for (ii = 0; ii < mp->route.n_paths; ii++)
+ {
+ apath = &mp->route.paths[ii];
+ rpath = &rpaths[ii];
+
+ rv = fib_api_path_decode (apath, rpath);
+
+ if ((rpath->frp_flags & FIB_ROUTE_PATH_LOCAL) &&
+ (~0 == rpath->frp_sw_if_index))
+ entry_flags |= (FIB_ENTRY_FLAG_CONNECTED | FIB_ENTRY_FLAG_LOCAL);
+
+ if (0 != rv)
+ goto out;
+ }
+
+ src = (0 == mp->route.src ? FIB_SOURCE_API : mp->route.src);
+
+ rv = fib_api_route_add_del (mp->is_add, mp->is_multipath, fib_index, &pfx,
+ src, entry_flags, rpaths);
if (mp->is_add && 0 == rv)
*stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);
@@ -615,6 +749,23 @@ vl_api_ip_route_add_del_t_handler (vl_api_ip_route_add_del_t * mp)
}
void
+vl_api_ip_route_add_del_v2_t_handler (vl_api_ip_route_add_del_v2_t *mp)
+{
+ vl_api_ip_route_add_del_v2_reply_t *rmp;
+ u32 stats_index = ~0;
+ int rv;
+
+ rv = ip_route_add_del_v2_t_handler (mp, &stats_index);
+
+ /* clang-format off */
+ REPLY_MACRO2 (VL_API_IP_ROUTE_ADD_DEL_V2_REPLY,
+ ({
+ rmp->stats_index = htonl (stats_index);
+ }))
+ /* clang-format on */
+}
+
+void
vl_api_ip_route_lookup_t_handler (vl_api_ip_route_lookup_t * mp)
{
vl_api_ip_route_lookup_reply_t *rmp = NULL;
@@ -671,6 +822,65 @@ vl_api_ip_route_lookup_t_handler (vl_api_ip_route_lookup_t * mp)
}
void
+vl_api_ip_route_lookup_v2_t_handler (vl_api_ip_route_lookup_v2_t *mp)
+{
+ vl_api_ip_route_lookup_v2_reply_t *rmp = NULL;
+ fib_route_path_t *rpaths = NULL, *rpath;
+ const fib_prefix_t *pfx = NULL;
+ fib_prefix_t lookup;
+ vl_api_fib_path_t *fp;
+ fib_node_index_t fib_entry_index;
+ u32 fib_index;
+ int npaths = 0;
+ fib_source_t src = 0;
+ int rv;
+
+ ip_prefix_decode (&mp->prefix, &lookup);
+ rv = fib_api_table_id_decode (lookup.fp_proto, ntohl (mp->table_id),
+ &fib_index);
+ if (PREDICT_TRUE (!rv))
+ {
+ if (mp->exact)
+ fib_entry_index = fib_table_lookup_exact_match (fib_index, &lookup);
+ else
+ fib_entry_index = fib_table_lookup (fib_index, &lookup);
+ if (fib_entry_index == FIB_NODE_INDEX_INVALID)
+ rv = VNET_API_ERROR_NO_SUCH_ENTRY;
+ else
+ {
+ pfx = fib_entry_get_prefix (fib_entry_index);
+ rpaths = fib_entry_encode (fib_entry_index);
+ npaths = vec_len (rpaths);
+ src = fib_entry_get_best_source (fib_entry_index);
+ }
+ }
+
+ /* clang-format off */
+ REPLY_MACRO3_ZERO(VL_API_IP_ROUTE_LOOKUP_V2_REPLY,
+ npaths * sizeof (*fp),
+ ({
+ if (!rv)
+ {
+ ip_prefix_encode (pfx, &rmp->route.prefix);
+ rmp->route.table_id = mp->table_id;
+ rmp->route.n_paths = npaths;
+ rmp->route.src = src;
+ rmp->route.stats_index = fib_table_entry_get_stats_index (fib_index, pfx);
+ rmp->route.stats_index = htonl (rmp->route.stats_index);
+
+ fp = rmp->route.paths;
+ vec_foreach (rpath, rpaths)
+ {
+ fib_api_path_encode (rpath, fp);
+ fp++;
+ }
+ }
+ }));
+ /* clang-format on */
+ vec_free (rpaths);
+}
+
+void
ip_table_create (fib_protocol_t fproto,
u32 table_id, u8 is_api, const u8 * name)
{
@@ -1797,6 +2007,8 @@ ip_api_hookup (vlib_main_t * vm)
*/
am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL] = 1;
am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL_REPLY] = 1;
+ am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL_V2] = 1;
+ am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL_V2_REPLY] = 1;
/*
* Set up the (msg_name, crc, message-id) table
diff --git a/src/vnet/mpls/mpls_api.c b/src/vnet/mpls/mpls_api.c
index 25bd353c62b..97928a744d8 100644
--- a/src/vnet/mpls/mpls_api.c
+++ b/src/vnet/mpls/mpls_api.c
@@ -192,13 +192,11 @@ mpls_route_add_del_t_handler (vnet_main_t * vnm,
goto out;
}
- rv = fib_api_route_add_del (mp->mr_is_add,
- mp->mr_is_multipath,
- fib_index,
- &pfx,
- (mp->mr_route.mr_is_multicast ?
- FIB_ENTRY_FLAG_MULTICAST :
- FIB_ENTRY_FLAG_NONE), rpaths);
+ rv = fib_api_route_add_del (
+ mp->mr_is_add, mp->mr_is_multipath, fib_index, &pfx, FIB_SOURCE_API,
+ (mp->mr_route.mr_is_multicast ? FIB_ENTRY_FLAG_MULTICAST :
+ FIB_ENTRY_FLAG_NONE),
+ rpaths);
if (mp->mr_is_add && 0 == rv)
*stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);