From: Richard Sanger <rsanger@wand.net.nz>
To: netdev@vger.kernel.org
Cc: Richard Sanger <rsanger@wand.net.nz>
Subject: [PATCH] net: packetmmap: fix only tx timestamp on request
Date: Tue, 4 May 2021 11:46:19 +1200 [thread overview]
Message-ID: <1620085579-5646-1-git-send-email-rsanger@wand.net.nz> (raw)
The packetmmap tx ring should only return timestamps if requested,
as documented. This allows compatibility with non-timestamp aware
user-space code which checks tp_status == TP_STATUS_AVAILABLE;
not expecting additional timestamp flags to be set.
Signed-off-by: Richard Sanger <rsanger@wand.net.nz>
---
net/packet/af_packet.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index ba96db1..b69805e 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -422,7 +422,8 @@ static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec64 *ts,
ktime_to_timespec64_cond(shhwtstamps->hwtstamp, ts))
return TP_STATUS_TS_RAW_HARDWARE;
- if (ktime_to_timespec64_cond(skb->tstamp, ts))
+ if ((flags & SOF_TIMESTAMPING_SOFTWARE) &&
+ ktime_to_timespec64_cond(skb->tstamp, ts))
return TP_STATUS_TS_SOFTWARE;
return 0;
@@ -2340,7 +2341,10 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
skb_copy_bits(skb, 0, h.raw + macoff, snaplen);
- if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp)))
+ /* always timestamp; prefer an existing software timestamp */
+ ts_status = tpacket_get_timestamp(skb, &ts,
+ po->tp_tstamp | SOF_TIMESTAMPING_SOFTWARE);
+ if (!ts_status)
ktime_get_real_ts64(&ts);
status |= ts_status;
--
2.7.4
next reply other threads:[~2021-05-04 0:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-03 23:46 Richard Sanger [this message]
2021-05-04 0:36 ` [PATCH] net: packetmmap: fix only tx timestamp on request Willem de Bruijn
2021-05-04 1:22 ` Richard Sanger
2021-05-04 14:45 ` Willem de Bruijn
2021-05-05 4:29 ` Richard Sanger
2021-05-05 5:09 ` Richard Sanger
2021-05-06 1:23 ` Willem de Bruijn
2021-05-11 22:11 ` Richard Sanger
2021-05-11 22:56 ` Willem de Bruijn
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=1620085579-5646-1-git-send-email-rsanger@wand.net.nz \
--to=rsanger@wand.net.nz \
--cc=netdev@vger.kernel.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