summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnet/vnet/pg/cli.c19
-rw-r--r--vnet/vnet/pg/stream.c3
2 files changed, 18 insertions, 4 deletions
diff --git a/vnet/vnet/pg/cli.c b/vnet/vnet/pg/cli.c
index 428a3b61967..201e4fb9d5e 100644
--- a/vnet/vnet/pg/cli.c
+++ b/vnet/vnet/pg/cli.c
@@ -182,6 +182,10 @@ pg_pcap_read (pg_stream_t * s, char * file_name)
s->buffer_bytes = pm.max_packet_bytes;
/* For PCAP buffers we never re-use buffers. */
s->flags |= PG_STREAM_FLAGS_DISABLE_BUFFER_RECYCLE;
+
+ if (s->n_packets_limit == 0)
+ s->n_packets_limit = vec_len (pm.packets_read);
+
return error;
#endif /* CLIB_UNIX */
}
@@ -314,8 +318,16 @@ new_stream (vlib_main_t * vm,
if (s.node_index == ~0)
{
- error = clib_error_create ("output interface or node not given");
- goto done;
+ if (pcap_file_name != 0)
+ {
+ vlib_node_t * n = vlib_get_node_by_name(vm, (u8 *) "ethernet-input");
+ s.node_index = n->index;
+ }
+ else
+ {
+ error = clib_error_create ("output interface or node not given");
+ goto done;
+ }
}
{
@@ -368,7 +380,8 @@ VLIB_CLI_COMMAND (new_stream_cli, static) = {
"name STRING sets stream name\n"
"interface STRING interface for stream output \n"
"node NODE-NAME node for stream output\n"
- "data STRING specifies packet data\n",
+ "data STRING specifies packet data\n"
+ "pcap FILENAME read packet data from pcap file\n",
};
static clib_error_t *
diff --git a/vnet/vnet/pg/stream.c b/vnet/vnet/pg/stream.c
index 5883817ced5..769fce1a70c 100644
--- a/vnet/vnet/pg/stream.c
+++ b/vnet/vnet/pg/stream.c
@@ -369,7 +369,8 @@ void pg_stream_add (pg_main_t * pg, pg_stream_t * s_init)
hash_set_mem (pg->stream_index_by_name, s->name, s - pg->streams);
/* Get fixed part of buffer data. */
- perform_fixed_edits (s);
+ if (s->edit_groups)
+ perform_fixed_edits (s);
/* Determine packet size. */
switch (s->packet_size_edit_type)