summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/af_packet/af_packet.api18
-rw-r--r--src/vnet/devices/af_packet/af_packet.c25
-rw-r--r--src/vnet/devices/af_packet/af_packet.h9
-rw-r--r--src/vnet/devices/af_packet/af_packet_api.c47
4 files changed, 98 insertions, 1 deletions
diff --git a/src/vnet/devices/af_packet/af_packet.api b/src/vnet/devices/af_packet/af_packet.api
index d7637da670c..1399011e870 100644
--- a/src/vnet/devices/af_packet/af_packet.api
+++ b/src/vnet/devices/af_packet/af_packet.api
@@ -69,6 +69,24 @@ autoreply define af_packet_set_l4_cksum_offload
u8 set;
};
+/** \brief Dump af_packet interfaces request */
+define af_packet_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+/** \brief Reply for af_packet dump request
+ @param sw_if_index - software index of af_packet interface
+ @param host_if_name - interface name
+*/
+define af_packet_details
+{
+ u32 context;
+ u32 sw_if_index;
+ u8 host_if_name[64];
+};
+
/*
* Local Variables:
* eval: (c-set-style "gnu")
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index 2e2c8e64dc3..f1a7b6ad21c 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -471,6 +471,31 @@ af_packet_set_l4_cksum_offload (vlib_main_t * vm, u32 sw_if_index, u8 set)
return 0;
}
+int
+af_packet_dump_ifs (af_packet_if_detail_t ** out_af_packet_ifs)
+{
+ af_packet_main_t *apm = &af_packet_main;
+ af_packet_if_t *apif;
+ af_packet_if_detail_t *r_af_packet_ifs = NULL;
+ af_packet_if_detail_t *af_packet_if = NULL;
+
+ vec_foreach (apif, apm->interfaces)
+ {
+ vec_add2 (r_af_packet_ifs, af_packet_if, 1);
+ af_packet_if->sw_if_index = apif->sw_if_index;
+ if (apif->host_if_name)
+ {
+ clib_memcpy (af_packet_if->host_if_name, apif->host_if_name,
+ MIN (ARRAY_LEN (af_packet_if->host_if_name) - 1,
+ strlen ((const char *) apif->host_if_name)));
+ }
+ }
+
+ *out_af_packet_ifs = r_af_packet_ifs;
+
+ return 0;
+}
+
static clib_error_t *
af_packet_init (vlib_main_t * vm)
{
diff --git a/src/vnet/devices/af_packet/af_packet.h b/src/vnet/devices/af_packet/af_packet.h
index 1136be6b871..b4621f6f6d4 100644
--- a/src/vnet/devices/af_packet/af_packet.h
+++ b/src/vnet/devices/af_packet/af_packet.h
@@ -23,6 +23,12 @@
typedef struct
{
+ u32 sw_if_index;
+ u8 host_if_name[64];
+} af_packet_if_detail_t;
+
+typedef struct
+{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
clib_spinlock_t lockp;
u8 *host_if_name;
@@ -70,9 +76,12 @@ int af_packet_create_if (vlib_main_t * vm, u8 * host_if_name,
int af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name);
int af_packet_set_l4_cksum_offload (vlib_main_t * vm, u32 sw_if_index,
u8 set);
+int af_packet_dump_ifs (af_packet_if_detail_t ** out_af_packet_ifs);
format_function_t format_af_packet_device_name;
+#define MIN(x,y) (((x)<(y))?(x):(y))
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/devices/af_packet/af_packet_api.c b/src/vnet/devices/af_packet/af_packet_api.c
index c7dfabc2ebd..3e03b5917fe 100644
--- a/src/vnet/devices/af_packet/af_packet_api.c
+++ b/src/vnet/devices/af_packet/af_packet_api.c
@@ -45,7 +45,8 @@
#define foreach_vpe_api_msg \
_(AF_PACKET_CREATE, af_packet_create) \
_(AF_PACKET_DELETE, af_packet_delete) \
-_(AF_PACKET_SET_L4_CKSUM_OFFLOAD, af_packet_set_l4_cksum_offload)
+_(AF_PACKET_SET_L4_CKSUM_OFFLOAD, af_packet_set_l4_cksum_offload) \
+_(AF_PACKET_DUMP, af_packet_dump)
static void
vl_api_af_packet_create_t_handler (vl_api_af_packet_create_t * mp)
@@ -103,6 +104,50 @@ static void
REPLY_MACRO (VL_API_AF_PACKET_SET_L4_CKSUM_OFFLOAD_REPLY);
}
+static void
+af_packet_send_details (vpe_api_main_t * am,
+ vl_api_registration_t * reg,
+ af_packet_if_detail_t * af_packet_if, u32 context)
+{
+ vl_api_af_packet_details_t *mp;
+ mp = vl_msg_api_alloc (sizeof (*mp));
+ memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = htons (VL_API_AF_PACKET_DETAILS);
+ mp->sw_if_index = htonl (af_packet_if->sw_if_index);
+ clib_memcpy (mp->host_if_name, af_packet_if->host_if_name,
+ MIN (ARRAY_LEN (mp->host_if_name) - 1,
+ strlen ((const char *) af_packet_if->host_if_name)));
+
+ mp->context = context;
+ vl_api_send_msg (reg, (u8 *) mp);
+}
+
+
+static void
+vl_api_af_packet_dump_t_handler (vl_api_af_packet_dump_t * mp)
+{
+ int rv;
+ vpe_api_main_t *am = &vpe_api_main;
+ vl_api_registration_t *reg;
+ af_packet_if_detail_t *out_af_packet_ifs = NULL;
+ af_packet_if_detail_t *af_packet_if = NULL;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ rv = af_packet_dump_ifs (&out_af_packet_ifs);
+ if (rv)
+ return;
+
+ vec_foreach (af_packet_if, out_af_packet_ifs)
+ {
+ af_packet_send_details (am, reg, af_packet_if, mp->context);
+ }
+
+ vec_free (out_af_packet_ifs);
+}
+
/*
* af_packet_api_hookup
* Add vpe's API message handlers to the table.