summaryrefslogtreecommitdiffstats
path: root/src/vnet/pg
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-05-16 11:34:35 -0400
committerDamjan Marion <dmarion.lists@gmail.com>2018-05-17 06:27:34 +0000
commit78c568905724af785e90185fd89fa8717b3b35c2 (patch)
tree85f5c35f4cef17be2490b4d3033ff07c71414556 /src/vnet/pg
parent26d6fd7f4deb67480c54eeff81aca36a8182dc0d (diff)
Packet generator: preserve pcap file timestamps
Set vnet_buffer2(b0)->pg_replay_timestamp, for use when desired. Fix a memory leak in pg_stream_free(...), which wasn't freeing the replay packet templates. Change-Id: I01822a9e91a52de4774d2b95cf0c2ee254a915e9 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/pg')
-rw-r--r--src/vnet/pg/cli.c1
-rw-r--r--src/vnet/pg/input.c1
-rw-r--r--src/vnet/pg/pg.h6
3 files changed, 8 insertions, 0 deletions
diff --git a/src/vnet/pg/cli.c b/src/vnet/pg/cli.c
index 3c249a7b5f1..745b9b2bf69 100644
--- a/src/vnet/pg/cli.c
+++ b/src/vnet/pg/cli.c
@@ -228,6 +228,7 @@ pg_pcap_read (pg_stream_t * s, char *file_name)
pm.file_name = file_name;
error = pcap_read (&pm);
s->replay_packet_templates = pm.packets_read;
+ s->replay_packet_timestamps = pm.timestamps;
s->min_packet_bytes = pm.min_packet_bytes;
s->max_packet_bytes = pm.max_packet_bytes;
s->buffer_bytes = pm.max_packet_bytes;
diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c
index a7430822c9b..a9510b7c9c9 100644
--- a/src/vnet/pg/input.c
+++ b/src/vnet/pg/input.c
@@ -1083,6 +1083,7 @@ init_replay_buffers_inline (vlib_main_t * vm,
vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
d0 = vec_elt (s->replay_packet_templates, i);
+ vnet_buffer2 (b0)->pg_replay_timestamp = s->replay_packet_timestamps[i];
n0 = n_data;
if (data_offset + n_data >= vec_len (d0))
diff --git a/src/vnet/pg/pg.h b/src/vnet/pg/pg.h
index 20852ba18d1..b2b5798eb22 100644
--- a/src/vnet/pg/pg.h
+++ b/src/vnet/pg/pg.h
@@ -169,6 +169,7 @@ typedef struct pg_stream_t
pg_buffer_index_t *buffer_indices;
u8 **replay_packet_templates;
+ u64 *replay_packet_timestamps;
u32 current_replay_packet_index;
} pg_stream_t;
@@ -192,6 +193,7 @@ pg_edit_group_free (pg_edit_group_t * g)
always_inline void
pg_stream_free (pg_stream_t * s)
{
+ int i;
pg_edit_group_t *g;
pg_edit_t *e;
vec_foreach (e, s->non_fixed_edits) pg_edit_free (e);
@@ -201,6 +203,10 @@ pg_stream_free (pg_stream_t * s)
vec_free (s->fixed_packet_data);
vec_free (s->fixed_packet_data_mask);
vec_free (s->name);
+ for (i = 0; i < vec_len (s->replay_packet_templates); i++)
+ vec_free (s->replay_packet_templates[i]);
+ vec_free (s->replay_packet_templates);
+ vec_free (s->replay_packet_timestamps);
{
pg_buffer_index_t *bi;