From: Jason Xing <kerneljasonxing@gmail.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, dsahern@kernel.org, willemb@google.com
Cc: netdev@vger.kernel.org, Jason Xing <kernelxing@tencent.com>
Subject: [PATCH net-next 0/2] timestamp: control SOF_TIMESTAMPING_RX_SOFTWARE feature per socket
Date: Sun, 25 Aug 2024 23:24:38 +0800 [thread overview]
Message-ID: <20240825152440.93054-1-kerneljasonxing@gmail.com> (raw)
From: Jason Xing <kernelxing@tencent.com>
Prior to this series, when one socket is set SOF_TIMESTAMPING_RX_SOFTWARE
which measn the whole system turns on this button, other sockets that only
have SOF_TIMESTAMPING_SOFTWARE will be affected and then print the rx
timestamp information even without SOF_TIMESTAMPING_RX_SOFTWARE flag.
In such a case, the rxtimestamp.c selftest surely fails, please see
testcase 6.
In a normal case, if we only set SOF_TIMESTAMPING_SOFTWARE flag, we
can't get the rx timestamp because there is no path leading to turn on
netstamp_needed_key button in net_enable_timestamp(). That is to say, if
the user only sets SOF_TIMESTAMPING_SOFTWARE, we don't expect we are
able to fetch the timestamp from the skb.
More than this, we can find there are some other ways to turn on
netstamp_needed_key, which will happenly allow users to get tstamp in
the receive path. Please see net_enable_timestamp().
How to solve it?
setsockopt interface is used to control each socket separately but in
this case it is affected by other sockets. For timestamp itself, it's
not feasible to convert netstamp_needed_key into a per-socket button
because when the receive stack just handling the skb from driver doesn't
know which socket the skb belongs to. So we have to test the exact
timestamping flag when the users do recvmsg: if we set both of flags, it
means we want the timestamp; if not, it means we don't expect to see the
timestamp even the skb carries.
As we can see, this patch makes the SOF_TIMESTAMPING_RX_SOFTWARE under
setsockopt control. And it's a per-socket fine-grained now.
Jason Xing (2):
tcp: make SOF_TIMESTAMPING_RX_SOFTWARE feature per socket
net: make SOF_TIMESTAMPING_RX_SOFTWARE feature per socket
include/net/sock.h | 11 ++++++-----
net/bluetooth/hci_sock.c | 4 ++--
net/core/sock.c | 2 +-
net/ipv4/ip_sockglue.c | 2 +-
net/ipv4/ping.c | 2 +-
net/ipv4/tcp.c | 10 ++++++++--
net/ipv6/datagram.c | 4 ++--
net/l2tp/l2tp_ip.c | 2 +-
net/l2tp/l2tp_ip6.c | 2 +-
net/nfc/llcp_sock.c | 2 +-
net/rxrpc/recvmsg.c | 2 +-
net/socket.c | 7 ++++---
net/unix/af_unix.c | 2 +-
13 files changed, 30 insertions(+), 22 deletions(-)
--
2.37.3
next reply other threads:[~2024-08-25 15:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-25 15:24 Jason Xing [this message]
2024-08-25 15:24 ` [PATCH net-next 1/2] tcp: make SOF_TIMESTAMPING_RX_SOFTWARE feature per socket Jason Xing
2024-08-26 13:24 ` Willem de Bruijn
2024-08-26 13:40 ` Jason Xing
2024-08-26 16:03 ` Willem de Bruijn
2024-08-26 16:41 ` Jason Xing
2024-08-26 18:43 ` Willem de Bruijn
2024-08-26 23:42 ` Jason Xing
2024-08-27 13:20 ` Willem de Bruijn
2024-08-27 15:27 ` Jason Xing
2024-08-27 17:08 ` Willem de Bruijn
2024-08-28 0:43 ` Jason Xing
2024-08-28 13:44 ` Willem de Bruijn
2024-08-28 14:02 ` Jason Xing
2024-08-28 14:10 ` Willem de Bruijn
2024-08-28 14:18 ` Jason Xing
2024-08-27 14:46 ` Jakub Kicinski
2024-08-27 15:31 ` Jason Xing
2024-08-25 15:24 ` [PATCH net-next 2/2] net: " Jason Xing
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=20240825152440.93054-1-kerneljasonxing@gmail.com \
--to=kerneljasonxing@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).