[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5692ddb3-9558-4440-a7bf-47fcc47401ed@linux.dev>
Date: Thu, 14 Mar 2024 12:21:58 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Willem de Bruijn <willemdebruijn.kernel@...il.com>,
"Abhishek Chauhan (ABC)" <quic_abchauha@...cinc.com>
Cc: kernel@...cinc.com, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Andrew Halaney <ahalaney@...hat.com>,
Martin KaFai Lau <martin.lau@...nel.org>, bpf <bpf@...r.kernel.org>,
Daniel Borkmann <daniel@...earbox.net>, Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>
Subject: Re: [PATCH net-next v4] net: Re-use and set mono_delivery_time bit
for userspace tstamp packets
On 3/14/24 2:49 AM, Willem de Bruijn wrote:
>> The two bits could potentially only encode the delivery time that is allowed to
>> be forwarded without reset. 0 could mean refering back to sk_clockid and don't
>> forward. The final consumer of the forwarded skb->tstamp is the qdisc which
>> currently only has mono and tai.
>
> So the followinng meaning of bit pair
> { skb->mono_delivery_time, skb->user_delivery_time } ?
>
> - { 0, 0 } legacy skb->tstamp: realtime on rx
> - { 1, 0 } skb->tstamp is mono: existing behavior of mono_delivery_time bit
> - { 0, 1 } skb->tstamp is tai: analogous to mono case
> - { 1, 1 } skb->tstamp defined by skb->sk->sk_clockid
I was thinking only forward mono and tai until it is clearer how other clocks
will be useful for forwarding between e/ingress. By resetting all skb->tstamp
other than mono and tai, { 0, 0 } at ingress will mean realtime on rx and { 0, 0
} at egress will mean go look skb->sk->sk_clockid.
I do like your scheme such that it is much clearer what is in skb->tstamp
without depending on other bits like tc_at_ingress or not.
"{ 0, 1 } skb->tstamp is tai: analogous to mono case" can probably be dropped
for now until bpf_skb_set_tstamp(BPF_SKB_TSTAMP_DELIVERY_TAI) is needed.
Otherwise, it is mostly a duplicate of "{ 1, 1 } skb->tstamp defined by
skb->sk->sk_clockid".
The bpf_convert_tstamp_{read,write} and the helper bpf_skb_set_tstamp need to be
changed to handle the new "user_delivery_time" bit anyway, e.g.
bpf_skb_set_tstamp(BPF_SKB_TSTAMP_DELIVERY_MONO) needs to clear the
"user_delivery_time" bit.
I think the "struct inet_frag_queue" also needs a new "user_delivery_time"
field. "mono_delivery_time" is already in there.
It may as well be cleaner to combine mono_delivery_time and user_delivery_time
into a 2 bits field like:
struct sk_buff {
__u8 tstamp_type:2;
};
enum {
SKB_TSTAMP_TYPE_RX_REAL = 0, /* A RX (receive) time in real */
SKB_TSTAMP_TYPE_TX_MONO = 1, /* A TX (delivery) time in mono */
/* A TX (delivery) time and its clock is in skb->sk->sk_clockid.
*
* BPF_SKB_TSTAMP_DELIVERY_USER should be added
* such that reading __sk_buff->tstamp_type will match the
* SKB_TSTAMP_TYPE_TX_USER.
*
* The bpf program can learn the clockid by
* reading skb->sk->sk_clockid.
*
* bpf_skb_set_tstamp(BPF_SKB_TSTAMP_DELIVERY_USER)
* should be disallowed for now until the use case
* is more clear. Potentially, we could allow it
* in the future as long as
* the sock_flag(sk, SOCK_TXTIME) is true at that moment.
*/
SKB_TSTAMP_TYPE_TX_USER = 2,
/* UNUSED_FOR_FUTURE = 3, */
};
It will have more code churns in the first patch to rename
s/mono_delivery_time/tstamp_type/.
wdyt?
Powered by blists - more mailing lists