From: Kohei Enju <kohei@enjuk.jp>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
Willem de Bruijn <willemb@google.com>,
David Ahern <dsahern@kernel.org>,
Neal Cardwell <ncardwell@google.com>,
Gerhard Engleder <gerhard@engleder-embedded.com>,
Jonathan Lemon <jonathan.lemon@gmail.com>,
Richard Cochran <richardcochran@gmail.com>,
Kohei Enju <kohei@enjuk.jp>
Subject: [PATCH net v1 2/3] af_packet: use skb_get_hwtstamp() for hardware timestamps
Date: Wed, 29 Apr 2026 09:16:18 +0000 [thread overview]
Message-ID: <20260429091632.26509-3-kohei@enjuk.jp> (raw)
In-Reply-To: <20260429091632.26509-1-kohei@enjuk.jp>
Since commit 97dc7cd92ac6 ("ptp: Support late timestamp determination"),
skb_shared_hwtstamps may contain netdev_data instead of hwtstamp.
tpacket_get_timestamp() unconditionally interprets skb_shared_hwtstamps
as a resolved hardware timestamp, and can report bogus hardware
timestamps to userspace.
Use skb_get_hwtstamp() instead of reading hwtstamp directly, so packet
sockets follow the same hardware timestamp resolution path as the socket
layer.
Note that skb_get_hwtstamp() is called with cycles == false, since
AF_PACKET hasn't honored SOF_TIMESTAMPING_BIND_PHC so far, and this
patch doesn't change that behavior.
Fixes: 97dc7cd92ac6 ("ptp: Support late timestamp determination")
Signed-off-by: Kohei Enju <kohei@enjuk.jp>
---
net/packet/af_packet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 8e6f3a734ba0..e88bc3f1156f 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -458,7 +458,7 @@ static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec64 *ts,
if (shhwtstamps &&
(flags & SOF_TIMESTAMPING_RAW_HARDWARE) &&
- ktime_to_timespec64_cond(shhwtstamps->hwtstamp, ts))
+ ktime_to_timespec64_cond(skb_get_hwtstamp(skb, false, NULL), ts))
return TP_STATUS_TS_RAW_HARDWARE;
if ((flags & SOF_TIMESTAMPING_SOFTWARE) &&
--
2.53.0
next prev parent reply other threads:[~2026-04-29 9:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 9:16 [PATCH net v1 0/3] af_packet/tcp: fix late hardware timestamp handling Kohei Enju
2026-04-29 9:16 ` [PATCH net v1 1/3] net: introduce helper to resolve hardware timestamps from skb Kohei Enju
2026-04-29 21:04 ` Willem de Bruijn
2026-04-30 4:50 ` Kohei Enju
2026-05-01 20:25 ` Gerhard Engleder
2026-04-29 9:16 ` Kohei Enju [this message]
2026-04-29 9:16 ` [PATCH net v1 3/3] tcp: use skb_get_hwtstamp() for hardware timestamps Kohei Enju
2026-04-29 21:09 ` Willem de Bruijn
2026-04-30 5:07 ` Kohei Enju
2026-04-30 6:09 ` Eric Dumazet
2026-04-30 6:52 ` Kohei Enju
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=20260429091632.26509-3-kohei@enjuk.jp \
--to=kohei@enjuk.jp \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=gerhard@engleder-embedded.com \
--cc=horms@kernel.org \
--cc=jonathan.lemon@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=willemb@google.com \
/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