pg: A Tunnel mode variant of a pg interface
Type: feature
this allows VPP to simulate linux tun devices.
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I3adf38b49a254804370f78edd5d275d192fd00a6
diff --git a/src/vnet/pg/cli.c b/src/vnet/pg/cli.c
index 9da0f8d..e57e725 100644
--- a/src/vnet/pg/cli.c
+++ b/src/vnet/pg/cli.c
@@ -333,6 +333,23 @@
return 0;
}
+const char *
+pg_interface_get_input_node (pg_interface_t *pi)
+{
+ switch (pi->mode)
+ {
+ case PG_MODE_ETHERNET:
+ return ("ethernet-input");
+ case PG_MODE_IP4:
+ return ("ip4-input");
+ case PG_MODE_IP6:
+ return ("ip6-input");
+ }
+
+ ASSERT (0);
+ return ("ethernet-input");
+}
+
static clib_error_t *
new_stream (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
@@ -351,7 +368,7 @@
s.node_index = ~0;
s.max_packet_bytes = s.min_packet_bytes = 64;
s.buffer_bytes = vlib_buffer_get_default_data_size (vm);
- s.if_id = 0;
+ s.if_id = ~0;
s.n_max_frame = VLIB_FRAME_SIZE;
pcap_file_name = 0;
@@ -427,8 +444,15 @@
{
if (pcap_file_name != 0)
{
- vlib_node_t *n =
- vlib_get_node_by_name (vm, (u8 *) "ethernet-input");
+ vlib_node_t *n;
+
+ ASSERT (s.if_id != ~0);
+
+ if (s.if_id != ~0)
+ n = vlib_get_node_by_name (vm, (u8 *) pg_interface_get_input_node (
+ &pg->interfaces[s.if_id]));
+ else
+ n = vlib_get_node_by_name (vm, (u8 *) "ethernet-input");
s.node_index = n->index;
}
else
@@ -694,8 +718,8 @@
}
}
- pg_interface_add_or_get (pg, if_id, gso_enabled, gso_size,
- coalesce_enabled);
+ pg_interface_add_or_get (pg, if_id, gso_enabled, gso_size, coalesce_enabled,
+ PG_MODE_ETHERNET);
done:
unformat_free (line_input);