netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: "Martin KaFai Lau" <martin.lau@linux.dev>,
	"Jörn-Thorben Hinz" <j-t.hinz@alumni.tu-berlin.de>
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	 Alexei Starovoitov <ast@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	 Andrii Nakryiko <andrii@kernel.org>,
	 "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,  Shuah Khan <shuah@kernel.org>,
	 Arnd Bergmann <arnd@arndb.de>,
	 Deepa Dinamani <deepa.kernel@gmail.com>,
	 bpf@vger.kernel.org,  linux-kernel@vger.kernel.org,
	 netdev@vger.kernel.org,  linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next] bpf: Allow setting SO_TIMESTAMPING* with bpf_setsockopt()
Date: Wed, 17 Jan 2024 10:55:01 -0500	[thread overview]
Message-ID: <65a7f855821cc_6d500294d0@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <51fd5249-140a-4f1b-b20e-703f159e88a3@linux.dev>

Martin KaFai Lau wrote:
> On 1/16/24 7:17 AM, Willem de Bruijn wrote:
> > Jörn-Thorben Hinz wrote:
> >> A BPF application, e.g., a TCP congestion control, might benefit from or
> >> even require precise (=hardware) packet timestamps. These timestamps are
> >> already available through __sk_buff.hwtstamp and
> >> bpf_sock_ops.skb_hwtstamp, but could not be requested: BPF programs were
> >> not allowed to set SO_TIMESTAMPING* on sockets.
> 
> This patch only uses the SOF_TIMESTAMPING_RX_HARDWARE in the selftest. How about 
> others? e.g. the SOF_TIMESTAMPING_TX_* that will affect the sk->sk_error_queue 
> which seems not good. If rx tstamp is useful, tx tstamp should be useful also?

Good point. Or should not be allowed to be set from BPF.

That significantly changes process behavior, e.g., by returning POLLERR.
 
> >>
> >> Enable BPF programs to actively request the generation of timestamps
> >> from a stream socket. The also required ioctl(SIOCSHWTSTAMP) on the
> >> network device must still be done separately, in user space.
> 
> hmm... so both ioctl(SIOCSHWTSTAMP) of the netdevice and the 
> SOF_TIMESTAMPING_RX_HARDWARE of the sk must be done?
> 
> I likely miss something. When skb is created in the driver rx path, the sk is 
> not known yet though. How the SOF_TIMESTAMPING_RX_HARDWARE of the sk affects the 
> skb_shinfo(skb)->hwtstamps?

Indeed it does not seem to do anything in the datapath.

Requesting SOF_TIMESTAMPING_RX_SOFTWARE will call net_enable_timestamp
to start timestamping packets.

But SOF_TIMESTAMPING_RX_HARDWARE does not so thing.

Drivers do use it in ethtool get_ts_info to signal hardware
capabilities. But those must be configured using the ioctl.

It is there more for consistency with the other timestamp recording
options, I suppose.


  reply	other threads:[~2024-01-17 15:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15 13:41 [PATCH bpf-next] bpf: Allow setting SO_TIMESTAMPING* with bpf_setsockopt() Jörn-Thorben Hinz
2024-01-16 15:17 ` Willem de Bruijn
2024-01-17  7:33   ` Martin KaFai Lau
2024-01-17 15:55     ` Willem de Bruijn [this message]
2024-01-17 21:23       ` Martin KaFai Lau
2024-01-18 14:53         ` Jörn-Thorben Hinz
2024-01-18 11:04   ` Jörn-Thorben Hinz
2024-01-18 14:46     ` 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=65a7f855821cc_6d500294d0@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=andrii@kernel.org \
    --cc=arnd@arndb.de \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=deepa.kernel@gmail.com \
    --cc=edumazet@google.com \
    --cc=j-t.hinz@alumni.tu-berlin.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@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;
as well as URLs for NNTP newsgroup(s).