summaryrefslogtreecommitdiffstats
path: root/nsh-plugin
diff options
context:
space:
mode:
authorHongjun Ni <hongjun.ni@intel.com>2016-08-02 00:06:40 +0800
committerHongjun Ni <hongjun.ni@intel.com>2016-08-02 00:06:40 +0800
commitb8812f176859d958fc09217bd827ef7382502fb7 (patch)
treee04d686506868a421815f93f0cea2f5abaf54e5e /nsh-plugin
parented5a133ef8debf7580d6c5bc16187222244c8b0e (diff)
Add nsh entry dump API
Change-Id: I6664c9929b8332eb8f4d7bc33f0f99b458a71908 Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
Diffstat (limited to 'nsh-plugin')
-rw-r--r--nsh-plugin/nsh/nsh.api20
-rw-r--r--nsh-plugin/nsh/nsh.c44
-rw-r--r--nsh-plugin/nsh/nsh_test.c41
3 files changed, 105 insertions, 0 deletions
diff --git a/nsh-plugin/nsh/nsh.api b/nsh-plugin/nsh/nsh.api
index 67d04e2..ed9f2fd 100644
--- a/nsh-plugin/nsh/nsh.api
+++ b/nsh-plugin/nsh/nsh.api
@@ -40,6 +40,26 @@ define nsh_add_del_entry_reply {
i32 retval;
};
+
+define nsh_entry_dump {
+ u32 client_index;
+ u32 context;
+};
+
+define nsh_entry_details {
+ u32 context;
+ u32 nsp_nsi;
+ u8 md_type;
+ u8 ver_o_c;
+ u8 length;
+ u8 next_protocol;
+ u32 c1;
+ u32 c2;
+ u32 c3;
+ u32 c4;
+ u32 tlvs[0];
+};
+
/** \brief Set or delete a mapping from one NSH header to another and its egress (decap to inner packet, encap NSH with outer header)
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
diff --git a/nsh-plugin/nsh/nsh.c b/nsh-plugin/nsh/nsh.c
index 3c30af7..3e0da8a 100644
--- a/nsh-plugin/nsh/nsh.c
+++ b/nsh-plugin/nsh/nsh.c
@@ -74,6 +74,7 @@
#define foreach_nsh_plugin_api_msg \
_(NSH_ADD_DEL_ENTRY, nsh_add_del_entry) \
+ _(NSH_ENTRY_DUMP, nsh_entry_dump) \
_(NSH_ADD_DEL_MAP, nsh_add_del_map)
clib_error_t *
@@ -585,6 +586,49 @@ static void vl_api_nsh_add_del_entry_t_handler
REPLY_MACRO(VL_API_NSH_ADD_DEL_ENTRY_REPLY);
}
+static void send_nsh_entry_details
+(nsh_header_t * t, unix_shared_memory_queue_t * q, u32 context)
+{
+ vl_api_nsh_entry_details_t * rmp;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+
+ rmp->_vl_msg_id = ntohs(VL_API_NSH_ENTRY_DETAILS);
+ rmp->ver_o_c = t->ver_o_c;
+ rmp->length = t->length;
+ rmp->md_type = t->md_type;
+ rmp->next_protocol = t->next_protocol;
+ rmp->nsp_nsi = t->nsp_nsi;
+ rmp->c1 = t->c1;
+ rmp->c2 = t->c2;
+ rmp->c3 = t->c3;
+ rmp->c4 = t->c4;
+
+ rmp->context = context;
+
+ vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
+static void vl_api_nsh_entry_dump_t_handler
+(vl_api_nsh_entry_dump_t * mp)
+{
+ unix_shared_memory_queue_t * q;
+ nsh_main_t * nm = &nsh_main;
+ nsh_header_t * t;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0) {
+ return;
+ }
+
+ pool_foreach (t, nm->nsh_entries,
+ ({
+ send_nsh_entry_details(t, q, mp->context);
+ }));
+}
+
+
static clib_error_t *
show_nsh_entry_command_fn (vlib_main_t * vm,
unformat_input_t * input,
diff --git a/nsh-plugin/nsh/nsh_test.c b/nsh-plugin/nsh/nsh_test.c
index a2978d5..aaea522 100644
--- a/nsh-plugin/nsh/nsh_test.c
+++ b/nsh-plugin/nsh/nsh_test.c
@@ -83,6 +83,7 @@ foreach_standard_reply_retval_handler;
*/
#define foreach_vpe_api_reply_msg \
_(NSH_ADD_DEL_ENTRY_REPLY, nsh_add_del_entry_reply) \
+_(NSH_ENTRY_DETAILS, nsh_entry_details) \
_(NSH_ADD_DEL_MAP_REPLY, nsh_add_del_map_reply)
@@ -214,6 +215,45 @@ static int api_nsh_add_del_entry (vat_main_t * vam)
W;
}
+static void vl_api_nsh_entry_details_t_handler
+(vl_api_nsh_entry_details_t * mp)
+{
+ vat_main_t * vam = &vat_main;
+
+ fformat(vam->ofp, "%11d%11d%11d%11d%14d%14d%14d%14d%14d\n",
+ mp->ver_o_c,
+ mp->length,
+ mp->md_type,
+ mp->next_protocol,
+ ntohl(mp->nsp_nsi),
+ ntohl(mp->c1),
+ ntohl(mp->c2),
+ ntohl(mp->c3),
+ ntohl(mp->c4));
+}
+
+static int api_nsh_entry_dump (vat_main_t * vam)
+{
+ nsh_test_main_t * sm = &nsh_test_main;
+ vl_api_nsh_entry_dump_t *mp;
+ f64 timeout;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%11s%11s%15s%14s%14s%13s%13s%13s%13s\n",
+ "ver_o_c", "length", "md_type", "next_protocol",
+ "nsp_nsi", "c1", "c2", "c3", "c4");
+ }
+
+ /* Get list of nsh entries */
+ M(NSH_ENTRY_DUMP, nsh_entry_dump);
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+}
+
static int api_nsh_add_del_map (vat_main_t * vam)
{
nsh_test_main_t * sm = &nsh_test_main;
@@ -282,6 +322,7 @@ static int api_nsh_add_del_map (vat_main_t * vam)
*/
#define foreach_vpe_api_msg \
_(nsh_add_del_entry, "{nsp <nn> nsi <nn>} c1 <nn> c2 <nn> c3 <nn> c4 <nn> [md-type <nn>] [tlv <xx>] [del]") \
+_(nsh_entry_dump, "") \
_(nsh_add_del_map, "nsp <nn> nsi <nn> [del] map-nsp <nn> map-nsi <nn> [encap-gre-intf <nn> | encap-vxlan-gpe-intf <nn> | encap-none]")
void vat_api_hookup (vat_main_t *vam)