From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Reshma Pattan <reshma.pattan@intel.com>
Subject: [PATCH 3/4] app/dumpcap: fix pcap timestamps
Date: Tue, 17 Nov 2026 08:06:21 -0800 [thread overview]
Message-ID: <20261117160727.388470-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20261117160727.388470-1-stephen@networkplumber.org>
The pcap output file is opened with nanosecond timestamp
precision, but the timestamp was set with gettimeofday()
which gives microseconds. This caused the fractional part
of the timestamps to be 1000 times too small.
Use clock_gettime() to get the timestamp in nanoseconds.
Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/dumpcap/main.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index 2808f77add..1f9f03c7a3 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -916,10 +916,18 @@ pcap_write_packets(pcap_dumper_t *dumper,
{
uint8_t temp_data[RTE_ETHER_MAX_JUMBO_FRAME_LEN];
struct pcap_pkthdr header;
+ struct timespec ts;
uint16_t i;
size_t total = 0;
- gettimeofday(&header.ts, NULL);
+ /*
+ * The use of tv_usec as nanoseconds is not a bug here.
+ * Output is opened with PCAP_TSTAMP_PRECISION_NANO in create_output(),
+ * and that is how the pcap API bodged in nanosecond support.
+ */
+ clock_gettime(CLOCK_REALTIME, &ts);
+ header.ts.tv_sec = ts.tv_sec;
+ header.ts.tv_usec = ts.tv_nsec;
for (i = 0; i < n; i++) {
struct rte_mbuf *m = pkts[i];
--
2.53.0
next prev parent reply other threads:[~2026-11-17 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 16:06 [PATCH 0/4] app/dumpcap: assorted fixes Stephen Hemminger
2026-11-17 16:06 ` [PATCH 1/4] app/dumpcap: fix packet count overshoot Stephen Hemminger
2026-11-17 16:06 ` [PATCH 2/4] app/dumpcap: fix capture duration Stephen Hemminger
2026-11-17 16:06 ` Stephen Hemminger [this message]
2026-11-17 16:06 ` [PATCH 4/4] app/dumpcap: do not use rte_exit before EAL init Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117160727.388470-4-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=reshma.pattan@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox