[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <67057fa71f8a9_1a41992946d@willemb.c.googlers.com.notmuch>
Date: Tue, 08 Oct 2024 14:53:27 -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
Cc: bpf@...r.kernel.org,
netdev@...r.kernel.org,
Jason Xing <kernelxing@...cent.com>
Subject: Re: [PATCH net-next 5/9] net-timestamp: ready to turn on the button
to generate tx timestamps
Jason Xing wrote:
> From: Jason Xing <kernelxing@...cent.com>
>
> Once we set BPF_SOCK_OPS_TX_TIMESTAMP_OPT_CB_FLAG flag here, there
> are three points in the previous patches where generating timestamps
> works. Let us make the basic bpf mechanism for timestamping feature
> work finally.
>
> We can use like this as a simple example in bpf program:
> __section("sockops")
>
> case BPF_SOCK_OPS_TX_TIMESTAMP_OPT_CB:
> dport = bpf_ntohl(skops->remote_port);
> sport = skops->local_port;
> skops->reply = SOF_TIMESTAMPING_TX_SCHED;
> bpf_sock_ops_cb_flags_set(skops, BPF_SOCK_OPS_TX_TIMESTAMP_OPT_CB_FLAG);
> case BPF_SOCK_OPS_TS_SCHED_OPT_CB:
> bpf_printk(...);
>
> Signed-off-by: Jason Xing <kernelxing@...cent.com>
> /* List of TCP states. There is a build check in net/ipv4/tcp.c to detect
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 82cc4a5633ce..ddf4089779b5 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -477,12 +477,37 @@ void tcp_init_sock(struct sock *sk)
> }
> EXPORT_SYMBOL(tcp_init_sock);
>
> +static u32 bpf_tcp_tx_timestamp(struct sock *sk)
> +{
> + u32 flags;
> +
> + flags = tcp_call_bpf(sk, BPF_SOCK_OPS_TX_TS_OPT_CB, 0, NULL);
> + if (flags <= 0)
> + return 0;
> +
> + if (flags & ~SOF_TIMESTAMPING_MASK)
> + return 0;
> +
> + if (!(flags & SOF_TIMESTAMPING_TX_RECORD_MASK))
> + return 0;
> +
> + return flags;
> +}
> +
> static void tcp_tx_timestamp(struct sock *sk, struct sockcm_cookie *sockc)
> {
> struct sk_buff *skb = tcp_write_queue_tail(sk);
> u32 tsflags = sockc->tsflags;
> + u32 flags;
> +
> + if (!skb)
> + return;
> +
> + flags = bpf_tcp_tx_timestamp(sk);
> + if (flags)
> + tsflags = flags;
So this feature overwrites the flags set by the user?
Ideally we would use an entirely separate field for BPF admin
timestamping requests.
>
> - if (tsflags && skb) {
> + if (tsflags) {
> struct skb_shared_info *shinfo = skb_shinfo(skb);
> struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
Powered by blists - more mailing lists