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 <srn@nexatech.fr>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
This commit is contained in:
Sylvain Rodon 2019-08-02 10:57:24 +02:00 committed by Ferruh Yigit
parent a9b28a4391
commit ce276d9ec3

View File

@ -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++;