From ce276d9ec35b7e1200d7946a5e30117ce1162950 Mon Sep 17 00:00:00 2001 From: Sylvain Rodon Date: Fri, 2 Aug 2019 10:57:24 +0200 Subject: [PATCH] net/pcap: propagate timestamp from header to mbuf Timestamp is always set in PCAP header, whether it reads a file or listen on an interface. This information can be important for some applications and it cannot be obtained otherwise (especially when reading a PCAP file, where the timestamp is not the current time). Timestamp here is the number of microseconds since epoch. Signed-off-by: Sylvain Rodon Acked-by: Ferruh Yigit --- drivers/net/pcap/rte_eth_pcap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 95d4b5bec2..5489010b64 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -265,6 +265,9 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } mbuf->pkt_len = (uint16_t)header.caplen; + mbuf->timestamp = (uint64_t)header.ts.tv_sec * 1000000 + + header.ts.tv_usec; + mbuf->ol_flags |= PKT_RX_TIMESTAMP; mbuf->port = pcap_q->port_id; bufs[num_rx] = mbuf; num_rx++; -- 2.20.1