From 78c568905724af785e90185fd89fa8717b3b35c2 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Wed, 16 May 2018 11:34:35 -0400 Subject: 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 --- src/vnet/unix/pcap.c | 7 +++++++ src/vnet/unix/pcap.h | 3 +++ 2 files changed, 10 insertions(+) (limited to 'src/vnet/unix') diff --git a/src/vnet/unix/pcap.c b/src/vnet/unix/pcap.c index 0832b16e753..473430a670e 100644 --- a/src/vnet/unix/pcap.c +++ b/src/vnet/unix/pcap.c @@ -216,6 +216,9 @@ pcap_read (pcap_main_t * pm) while ((n = read (fd, &ph, sizeof (ph))) != 0) { u8 *data; + u64 timestamp; + u32 timestamp_sec; + u32 timestamp_usec; if (need_swap) { @@ -242,7 +245,11 @@ pcap_read (pcap_main_t * pm) clib_max (pm->max_packet_bytes, ph.n_bytes_in_packet); } + timestamp_sec = ph.time_in_sec; + timestamp_usec = ph.time_in_usec; + timestamp = ((u64) timestamp_sec) * 1000000 + (u64) timestamp_usec; vec_add1 (pm->packets_read, data); + vec_add1 (pm->timestamps, timestamp); } done: diff --git a/src/vnet/unix/pcap.h b/src/vnet/unix/pcap.h index e3fac458af4..7d55db37979 100644 --- a/src/vnet/unix/pcap.h +++ b/src/vnet/unix/pcap.h @@ -151,6 +151,9 @@ typedef struct /** Packets read from file. */ u8 **packets_read; + /** Timestamps */ + u64 *timestamps; + /** Min/Max Packet bytes */ u32 min_packet_bytes, max_packet_bytes; } pcap_main_t; -- cgit 1.2.3-korg