diff options
author | Damjan Marion <damarion@cisco.com> | 2016-07-08 22:08:16 +0200 |
---|---|---|
committer | Chris Luke <chris_luke@comcast.com> | 2016-07-09 00:54:52 +0000 |
commit | ddbdd4f993677eb6bee5dd06af04a5107502e188 (patch) | |
tree | 2a534f946c0453ba25099d9af912f760a4b67f8e /vnet | |
parent | 8a7fb0cf6844ed09173fd58224f7753a1b504cf4 (diff) |
packet-generator: fix pcap stream support
Change-Id: I494280964deda1d9448540cb5c6e7a8b750fff93
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r-- | vnet/vnet/pg/cli.c | 19 | ||||
-rw-r--r-- | vnet/vnet/pg/stream.c | 3 |
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) |