summaryrefslogtreecommitdiffstats
path: root/src/vnet/lisp-gpe
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/lisp-gpe')
-rw-r--r--src/vnet/lisp-gpe/decap.c49
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.c83
2 files changed, 132 insertions, 0 deletions
diff --git a/src/vnet/lisp-gpe/decap.c b/src/vnet/lisp-gpe/decap.c
index 687697105a4..e59a353df30 100644
--- a/src/vnet/lisp-gpe/decap.c
+++ b/src/vnet/lisp-gpe/decap.c
@@ -545,6 +545,55 @@ gpe_decap_init (vlib_main_t * vm)
return 0;
}
+static uword
+lisp_gpe_nsh_dummy_input (vlib_main_t * vm, vlib_node_runtime_t * node,
+ vlib_frame_t * from_frame)
+{
+ vlib_node_increment_counter (vm, node->node_index, 0, 1);
+ return from_frame->n_vectors;
+}
+
+static char *lisp_gpe_nsh_dummy_error_strings[] = {
+ "lisp gpe dummy nsh decap",
+};
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (lisp_gpe_nsh_dummy_input_node) = {
+ .function = lisp_gpe_nsh_dummy_input,
+ .name = "lisp-gpe-nsh-dummy-input",
+ .vector_size = sizeof (u32),
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_next_nodes = 1,
+
+ .n_errors = 1,
+ .error_strings = lisp_gpe_nsh_dummy_error_strings,
+
+ .next_nodes = {
+ [0] = "error-drop",
+ },
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+lisp_add_dummy_nsh_node_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
+ vlib_node_add_next (lgm->vlib_main, lisp_gpe_ip4_input_node.index,
+ lisp_gpe_nsh_dummy_input_node.index);
+ next_proto_to_next_index[LISP_GPE_NEXT_PROTO_NSH] =
+ LISP_GPE_INPUT_NEXT_NSH_INPUT;
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (lisp_add_dummy_nsh_node_command, static) = {
+ .path = "test one nsh add-dummy-decap-node",
+ .function = lisp_add_dummy_nsh_node_command_fn,
+};
+/* *INDENT-ON* */
+
VLIB_INIT_FUNCTION (gpe_decap_init);
/*
diff --git a/src/vnet/lisp-gpe/lisp_gpe.c b/src/vnet/lisp-gpe/lisp_gpe.c
index d274818d46f..0acc73491b9 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.c
+++ b/src/vnet/lisp-gpe/lisp_gpe.c
@@ -631,6 +631,89 @@ vnet_gpe_get_encap_mode (void)
return lgm->encap_mode;
}
+static clib_error_t *
+lisp_gpe_test_send_nsh_packet (u8 * file_name)
+{
+ vlib_frame_t *f;
+ vlib_buffer_t *b;
+ lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
+ pcap_main_t pm;
+ clib_error_t *error = 0;
+
+ if (!file_name)
+ return clib_error_create ("no pcap file specified!");
+
+ memset (&pm, 0, sizeof (pm));
+ pm.file_name = (char *) file_name;
+ error = pcap_read (&pm);
+ if (error)
+ return error;
+
+ u32 bi;
+ if (vlib_buffer_alloc (lgm->vlib_main, &bi, 1) != 1)
+ return clib_error_create ("cannot allocate memory!");
+
+ b = vlib_get_buffer (lgm->vlib_main, bi);
+ tunnel_lookup_t *nsh_ifaces = &lgm->nsh_ifaces;
+ uword *hip;
+ vnet_hw_interface_t *hi;
+
+ hip = hash_get (nsh_ifaces->hw_if_index_by_dp_table, 0);
+ if (hip == 0)
+ return clib_error_create ("The NSH 0 interface doesn't exist");
+
+ hi = vnet_get_hw_interface (lgm->vnet_main, hip[0]);
+
+ vnet_buffer (b)->sw_if_index[VLIB_TX] = hi->sw_if_index;
+ u8 *p = vlib_buffer_put_uninit (b, vec_len (pm.packets_read[0]));
+ clib_memcpy (p, pm.packets_read[0], vec_len (pm.packets_read[0]));
+ vlib_buffer_pull (b, sizeof (ethernet_header_t));
+
+ vlib_node_t *n = vlib_get_node_by_name (lgm->vlib_main,
+ (u8 *) "interface-tx");
+ f = vlib_get_frame_to_node (lgm->vlib_main, n->index);
+ u32 *to_next = vlib_frame_vector_args (f);
+ to_next[0] = bi;
+ f->n_vectors = 1;
+ vlib_put_frame_to_node (lgm->vlib_main, n->index, f);
+
+ return error;
+}
+
+static clib_error_t *
+lisp_test_nsh_command_fn (vlib_main_t * vm, unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ clib_error_t *error = 0;
+ u8 *file_name = 0;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "pcap %v", &file_name))
+ {
+ error = lisp_gpe_test_send_nsh_packet (file_name);
+ goto done;
+ }
+ else
+ {
+ error = clib_error_create ("unknown input `%U'",
+ format_unformat_error, input);
+ goto done;
+ }
+ }
+
+done:
+ return error;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (lisp_test_nsh_command, static) = {
+ .path = "test one nsh",
+ .short_help = "test gpe nsh pcap <path-to-pcap-file>",
+ .function = lisp_test_nsh_command_fn,
+};
+/* *INDENT-ON* */
+
VLIB_INIT_FUNCTION (lisp_gpe_init);
/*