[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <67203358a4016_24dce62942@willemb.c.googlers.com.notmuch>
Date: Mon, 28 Oct 2024 20:59:04 -0400
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Jason Xing <kerneljasonxing@...il.com>,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
dsahern@...nel.org,
willemdebruijn.kernel@...il.com,
willemb@...gle.com,
ast@...nel.org,
daniel@...earbox.net,
andrii@...nel.org,
martin.lau@...ux.dev,
eddyz87@...il.com,
song@...nel.org,
yonghong.song@...ux.dev,
john.fastabend@...il.com,
kpsingh@...nel.org,
sdf@...ichev.me,
haoluo@...gle.com,
jolsa@...nel.org,
shuah@...nel.org,
ykolal@...com
Cc: bpf@...r.kernel.org,
netdev@...r.kernel.org,
Jason Xing <kernelxing@...cent.com>
Subject: Re: [PATCH net-next v3 03/14] net-timestamp: open gate for
bpf_setsockopt/_getsockopt
Jason Xing wrote:
> From: Jason Xing <kernelxing@...cent.com>
>
> For now, we support bpf_setsockopt to set or clear timestamps flags.
>
> Users can use something like this in bpf program to turn on the feature:
> flags = SOF_TIMESTAMPING_TX_SCHED;
> bpf_setsockopt(skops, SOL_SOCKET, SO_TIMESTAMPING, &flags, sizeof(flags));
> The specific use cases can be seen in the bpf selftest in this series.
>
> Later, I will support each flags one by one based on this.
>
> Signed-off-by: Jason Xing <kernelxing@...cent.com>
> ---
> include/net/sock.h | 4 ++--
> include/uapi/linux/net_tstamp.h | 7 +++++++
> net/core/filter.c | 7 +++++--
> net/core/sock.c | 34 ++++++++++++++++++++++++++-------
> net/ipv4/udp.c | 2 +-
> net/mptcp/sockopt.c | 2 +-
> net/socket.c | 2 +-
> 7 files changed, 44 insertions(+), 14 deletions(-)
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 5384f1e49f5c..062f405c744e 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -1775,7 +1775,7 @@ static inline void skb_set_owner_edemux(struct sk_buff *skb, struct sock *sk)
> #endif
>
> int sk_setsockopt(struct sock *sk, int level, int optname,
> - sockptr_t optval, unsigned int optlen);
> + sockptr_t optval, unsigned int optlen, bool bpf_timetamping);
timestamping, not timetamping
More importantly, is there perhaps a cleaner way to add a BPF
setsockopt than to have to update the existing API and all its
callers?
> int sock_setsockopt(struct socket *sock, int level, int op,
> sockptr_t optval, unsigned int optlen);
> int do_sock_setsockopt(struct socket *sock, bool compat, int level,
> @@ -1784,7 +1784,7 @@ int do_sock_getsockopt(struct socket *sock, bool compat, int level,
> int optname, sockptr_t optval, sockptr_t optlen);
>
> int sk_getsockopt(struct sock *sk, int level, int optname,
> - sockptr_t optval, sockptr_t optlen);
> + sockptr_t optval, sockptr_t optlen, bool bpf_timetamping);
> int sock_gettstamp(struct socket *sock, void __user *userstamp,
> bool timeval, bool time32);
> struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
> diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h
> index 858339d1c1c4..0696699cf964 100644
> --- a/include/uapi/linux/net_tstamp.h
> +++ b/include/uapi/linux/net_tstamp.h
> @@ -49,6 +49,13 @@ enum {
> SOF_TIMESTAMPING_TX_SCHED | \
> SOF_TIMESTAMPING_TX_ACK)
>
> +#define SOF_TIMESTAMPING_BPF_SUPPPORTED_MASK (SOF_TIMESTAMPING_SOFTWARE | \
> + SOF_TIMESTAMPING_TX_SCHED | \
> + SOF_TIMESTAMPING_TX_SOFTWARE | \
> + SOF_TIMESTAMPING_TX_ACK | \
> + SOF_TIMESTAMPING_OPT_ID | \
> + SOF_TIMESTAMPING_OPT_ID_TCP)
> +
We discussed the subtle distinction between OPT_ID and OPT_ID_TCP before.
Basically, OPT_ID_TCP is a fix for OPT_ID on TCP sockets, and should always be
passed. On a new API like this one, we can even require this.
Not super important, only if it does not make the code more complex.
Powered by blists - more mailing lists