aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-01-26 01:18:23 -0800
committerFlorin Coras <florin.coras@gmail.com>2017-02-20 09:54:49 +0000
commit5a8123bda0261158457e38bfb4922aa5961389ff (patch)
treedf221814e21d30ea5d63620504c73e64371a5780 /src/vnet/ip
parent90c55724b583434957cf83555a084770f2efdd7a (diff)
Python test IP and MPLS objects conform to infra.
Add IP[46] MFIB dump. Change-Id: I4a2821f65e67a5416b291e4912c84f64989883b8 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/ip.api56
-rw-r--r--src/vnet/ip/ip_api.c254
2 files changed, 308 insertions, 2 deletions
diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api
index 0a4a9c9773c..d982b04cdfd 100644
--- a/src/vnet/ip/ip.api
+++ b/src/vnet/ip/ip.api
@@ -430,6 +430,62 @@ define ip_mroute_add_del_reply
i32 retval;
};
+/** \brief Dump IP multicast fib table
+ @param client_index - opaque cookie to identify the sender
+*/
+define ip_mfib_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+/** \brief IP Multicast FIB table response
+ @param table_id - IP fib table id
+ @address_length - mask length
+ @grp_address - Group address/prefix
+ @src_address - Source address
+ @param count - the number of fib_path in path
+ @param path - array of of fib_path structures
+*/
+manual_endian manual_print define ip_mfib_details
+{
+ u32 context;
+ u32 table_id;
+ u8 address_length;
+ u8 grp_address[4];
+ u8 src_address[4];
+ u32 count;
+ vl_api_fib_path_t path[count];
+};
+
+/** \brief Dump IP6 multicast fib table
+ @param client_index - opaque cookie to identify the sender
+*/
+define ip6_mfib_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+/** \brief IP6 Multicast FIB table response
+ @param table_id - IP fib table id
+ @address_length - mask length
+ @grp_address - Group address/prefix
+ @src_address - Source address
+ @param count - the number of fib_path in path
+ @param path - array of of fib_path structures
+*/
+manual_endian manual_print define ip6_mfib_details
+{
+ u32 context;
+ u32 table_id;
+ u8 address_length;
+ u8 grp_address[16];
+ u8 src_address[16];
+ u32 count;
+ vl_api_fib_path_t path[count];
+};
+
define ip_address_details
{
u32 client_index;
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 1cc712eb3e7..49d941c2a8a 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -33,9 +33,10 @@
#include <vnet/dpo/classify_dpo.h>
#include <vnet/dpo/ip_null_dpo.h>
#include <vnet/ethernet/arp_packet.h>
-//#include <vnet/mfib/ip6_mfib.h>
+#include <vnet/mfib/ip6_mfib.h>
#include <vnet/mfib/ip4_mfib.h>
#include <vnet/mfib/mfib_signal.h>
+#include <vnet/mfib/mfib_entry.h>
#include <vnet/vnet_msg_enum.h>
@@ -55,14 +56,19 @@
#include <vlibapi/api_helper_macros.h>
+
#define foreach_ip_api_msg \
_(IP_FIB_DUMP, ip_fib_dump) \
_(IP_FIB_DETAILS, ip_fib_details) \
_(IP6_FIB_DUMP, ip6_fib_dump) \
_(IP6_FIB_DETAILS, ip6_fib_details) \
+_(IP_MFIB_DUMP, ip_mfib_dump) \
+_(IP_MFIB_DETAILS, ip_mfib_details) \
+_(IP6_MFIB_DUMP, ip6_mfib_dump) \
+_(IP6_MFIB_DETAILS, ip6_mfib_details) \
_(IP_NEIGHBOR_DUMP, ip_neighbor_dump) \
_(IP_MROUTE_ADD_DEL, ip_mroute_add_del) \
-_(MFIB_SIGNAL_DUMP, mfib_signal_dump) \
+_(MFIB_SIGNAL_DUMP, mfib_signal_dump) \
_(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
_(IP_ADDRESS_DUMP, ip_address_dump) \
_(IP_DUMP, ip_dump) \
@@ -464,6 +470,250 @@ vl_api_ip6_fib_dump_t_handler (vl_api_ip6_fib_dump_t * mp)
}
static void
+vl_api_ip_mfib_details_t_handler (vl_api_ip_mfib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+vl_api_ip_mfib_details_t_endian (vl_api_ip_mfib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+vl_api_ip_mfib_details_t_print (vl_api_ip_mfib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+send_ip_mfib_details (vpe_api_main_t * am,
+ unix_shared_memory_queue_t * q,
+ u32 table_id,
+ mfib_prefix_t * pfx,
+ fib_route_path_encode_t * api_rpaths, u32 context)
+{
+ vl_api_ip_mfib_details_t *mp;
+ fib_route_path_encode_t *api_rpath;
+ vl_api_fib_path_t *fp;
+ int path_count;
+
+ path_count = vec_len (api_rpaths);
+ mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
+ if (!mp)
+ return;
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_IP_FIB_DETAILS);
+ mp->context = context;
+
+ mp->table_id = htonl (table_id);
+ mp->address_length = pfx->fp_len;
+ memcpy (mp->grp_address, &pfx->fp_grp_addr.ip4,
+ sizeof (pfx->fp_grp_addr.ip4));
+ memcpy (mp->src_address, &pfx->fp_src_addr.ip4,
+ sizeof (pfx->fp_src_addr.ip4));
+
+ mp->count = htonl (path_count);
+ fp = mp->path;
+ vec_foreach (api_rpath, api_rpaths)
+ {
+ memset (fp, 0, sizeof (*fp));
+
+ fp->weight = 0;
+ fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
+ copy_fib_next_hop (api_rpath, fp);
+ fp++;
+ }
+
+ vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
+typedef struct vl_api_ip_mfib_dump_ctc_t_
+{
+ fib_node_index_t *entries;
+} vl_api_ip_mfib_dump_ctc_t;
+
+static int
+vl_api_ip_mfib_table_dump_walk (fib_node_index_t fei, void *arg)
+{
+ vl_api_ip_mfib_dump_ctc_t *ctx = arg;
+
+ vec_add1 (ctx->entries, fei);
+
+ return (0);
+}
+
+static void
+vl_api_ip_mfib_dump_t_handler (vl_api_ip_mfib_dump_t * mp)
+{
+ vpe_api_main_t *am = &vpe_api_main;
+ unix_shared_memory_queue_t *q;
+ ip4_main_t *im = &ip4_main;
+ mfib_table_t *mfib_table;
+ fib_node_index_t *mfeip;
+ mfib_prefix_t pfx;
+ fib_route_path_encode_t *api_rpaths = NULL;
+ vl_api_ip_mfib_dump_ctc_t ctx = {
+ .entries = NULL,
+ };
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0)
+ return;
+
+
+ /* *INDENT-OFF* */
+ pool_foreach (mfib_table, im->mfibs,
+ ({
+ ip4_mfib_table_walk(&mfib_table->v4,
+ vl_api_ip_mfib_table_dump_walk,
+ &ctx);
+
+ vec_sort_with_function (ctx.entries, mfib_entry_cmp_for_sort);
+
+ vec_foreach (mfeip, ctx.entries)
+ {
+ mfib_entry_get_prefix (*mfeip, &pfx);
+ mfib_entry_encode (*mfeip, &api_rpaths);
+ send_ip_mfib_details (am, q,
+ mfib_table->mft_table_id,
+ &pfx, api_rpaths,
+ mp->context);
+ }
+ vec_reset_length (api_rpaths);
+ vec_reset_length (ctx.entries);
+
+ }));
+ /* *INDENT-ON* */
+
+ vec_free (ctx.entries);
+ vec_free (api_rpaths);
+}
+
+static void
+vl_api_ip6_mfib_details_t_handler (vl_api_ip6_mfib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+vl_api_ip6_mfib_details_t_endian (vl_api_ip6_mfib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+vl_api_ip6_mfib_details_t_print (vl_api_ip6_mfib_details_t * mp)
+{
+ clib_warning ("BUG");
+}
+
+static void
+send_ip6_mfib_details (vpe_api_main_t * am,
+ unix_shared_memory_queue_t * q,
+ u32 table_id,
+ mfib_prefix_t * pfx,
+ fib_route_path_encode_t * api_rpaths, u32 context)
+{
+ vl_api_ip6_mfib_details_t *mp;
+ fib_route_path_encode_t *api_rpath;
+ vl_api_fib_path_t *fp;
+ int path_count;
+
+ path_count = vec_len (api_rpaths);
+ mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
+ if (!mp)
+ return;
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_IP6_FIB_DETAILS);
+ mp->context = context;
+
+ mp->table_id = htonl (table_id);
+ mp->address_length = pfx->fp_len;
+ memcpy (mp->grp_address, &pfx->fp_grp_addr.ip6,
+ sizeof (pfx->fp_grp_addr.ip6));
+ memcpy (mp->src_address, &pfx->fp_src_addr.ip6,
+ sizeof (pfx->fp_src_addr.ip6));
+
+ mp->count = htonl (path_count);
+ fp = mp->path;
+ vec_foreach (api_rpath, api_rpaths)
+ {
+ memset (fp, 0, sizeof (*fp));
+
+ fp->weight = 0;
+ fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
+ copy_fib_next_hop (api_rpath, fp);
+ fp++;
+ }
+
+ vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
+typedef struct vl_api_ip6_mfib_dump_ctc_t_
+{
+ fib_node_index_t *entries;
+} vl_api_ip6_mfib_dump_ctc_t;
+
+static int
+vl_api_ip6_mfib_table_dump_walk (fib_node_index_t fei, void *arg)
+{
+ vl_api_ip6_mfib_dump_ctc_t *ctx = arg;
+
+ vec_add1 (ctx->entries, fei);
+
+ return (0);
+}
+
+static void
+vl_api_ip6_mfib_dump_t_handler (vl_api_ip6_mfib_dump_t * mp)
+{
+ vpe_api_main_t *am = &vpe_api_main;
+ unix_shared_memory_queue_t *q;
+ ip6_main_t *im = &ip6_main;
+ mfib_table_t *mfib_table;
+ fib_node_index_t *mfeip;
+ mfib_prefix_t pfx;
+ fib_route_path_encode_t *api_rpaths = NULL;
+ vl_api_ip6_mfib_dump_ctc_t ctx = {
+ .entries = NULL,
+ };
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0)
+ return;
+
+
+ /* *INDENT-OFF* */
+ pool_foreach (mfib_table, im->mfibs,
+ ({
+ ip6_mfib_table_walk(&mfib_table->v6,
+ vl_api_ip6_mfib_table_dump_walk,
+ &ctx);
+
+ vec_sort_with_function (ctx.entries, mfib_entry_cmp_for_sort);
+
+ vec_foreach(mfeip, ctx.entries)
+ {
+ mfib_entry_get_prefix (*mfeip, &pfx);
+ mfib_entry_encode (*mfeip, &api_rpaths);
+ send_ip6_mfib_details (am, q,
+ mfib_table->mft_table_id,
+ &pfx, api_rpaths,
+ mp->context);
+ }
+ vec_reset_length (api_rpaths);
+ vec_reset_length (ctx.entries);
+
+ }));
+ /* *INDENT-ON* */
+
+ vec_free (ctx.entries);
+ vec_free (api_rpaths);
+}
+
+static void
vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp,
vlib_main_t * vm)
{