From: "Abhishek Chauhan (ABC)" <quic_abchauha@quicinc.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Andrew Halaney <ahalaney@redhat.com>,
"Martin KaFai Lau" <martin.lau@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Daniel Borkmann <daniel@iogearbox.net>, bpf <bpf@vger.kernel.org>
Cc: <kernel@quicinc.com>
Subject: Re: [RFC PATCH bpf-next v6 3/3] selftests/bpf: Handle forwarding of UDP CLOCK_TAI packets
Date: Mon, 6 May 2024 16:40:37 -0700 [thread overview]
Message-ID: <8a6e3ed0-186e-4248-98a0-c8b60341d3aa@quicinc.com> (raw)
In-Reply-To: <1480064d-1825-4438-9d30-bc47a694cc12@quicinc.com>
On 5/6/2024 1:54 PM, Abhishek Chauhan (ABC) wrote:
>
>
> On 5/6/2024 1:50 PM, Abhishek Chauhan (ABC) wrote:
>>
>>
>> On 5/6/2024 12:04 PM, Willem de Bruijn wrote:
>>> Abhishek Chauhan wrote:
>>>> With changes in the design to forward CLOCK_TAI in the skbuff
>>>> framework, existing selftest framework needs modification
>>>> to handle forwarding of UDP packets with CLOCK_TAI as clockid.
>>>>
>>>> Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/
>>>> Signed-off-by: Abhishek Chauhan <quic_abchauha@quicinc.com>
>>>> ---
>>>> tools/include/uapi/linux/bpf.h | 15 ++++---
>>>> .../selftests/bpf/prog_tests/ctx_rewrite.c | 10 +++--
>>>> .../selftests/bpf/prog_tests/tc_redirect.c | 3 --
>>>> .../selftests/bpf/progs/test_tc_dtime.c | 39 +++++++++----------
>>>> 4 files changed, 34 insertions(+), 33 deletions(-)
>>>>
>>>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
>>>> index 90706a47f6ff..25ea393cf084 100644
>>>> --- a/tools/include/uapi/linux/bpf.h
>>>> +++ b/tools/include/uapi/linux/bpf.h
>>>> @@ -6207,12 +6207,17 @@ union { \
>>>> __u64 :64; \
>>>> } __attribute__((aligned(8)))
>>>>
>>>> +/* The enum used in skb->tstamp_type. It specifies the clock type
>>>> + * of the time stored in the skb->tstamp.
>>>> + */
>>>> enum {
>>>> - BPF_SKB_TSTAMP_UNSPEC,
>>>> - BPF_SKB_TSTAMP_DELIVERY_MONO, /* tstamp has mono delivery time */
>>>> - /* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle,
>>>> - * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC
>>>> - * and try to deduce it by ingress, egress or skb->sk->sk_clockid.
>>>> + BPF_SKB_TSTAMP_UNSPEC = 0, /* DEPRECATED */
>>>> + BPF_SKB_TSTAMP_DELIVERY_MONO = 1, /* DEPRECATED */
>>>> + BPF_SKB_CLOCK_REALTIME = 0,
>>>> + BPF_SKB_CLOCK_MONOTONIC = 1,
>>>> + BPF_SKB_CLOCK_TAI = 2,
>>>> + /* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle,
>>>> + * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid.
>>>> */
>>>> };
>>>>
>>>> diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>>> index 3b7c57fe55a5..71940f4ef0fb 100644
>>>> --- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>>> +++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
>>>> @@ -69,15 +69,17 @@ static struct test_case test_cases[] = {
>>>> {
>>>> N(SCHED_CLS, struct __sk_buff, tstamp),
>>>> .read = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>>> - "w11 &= 3;"
>>>> - "if w11 != 0x3 goto pc+2;"
>>>> + "if w11 == 0x4 goto pc+1;"
>>>> + "goto pc+4;"
>>>> + "if w11 == 0x3 goto pc+1;"
>>>> + "goto pc+2;"
>>>
>>> Not an expert on this code, and I see that the existing code already
>>> has this below, but: isn't it odd and unnecessary to jump to an
>>> unconditional jump statement?
>>>
>> I am closely looking into your comment and i will evalute it(Martin can correct me
>> if the jumps are correct or not as i am new to BPF as well) but i found out that
>> JSET = "&" and not "==". So the above two ins has to change from -
>>
>> "if w11 == 0x4 goto pc+1;" ==>(needs to be corrected to) "if w11 & 0x4 goto pc+1;"
>> "if w11 == 0x3 goto pc+1;" ==> (needs to be correct to) "if w11 & 0x3 goto pc+1;"
>>
>>
Willem, I looked at the jumps in the above code. They look correct to me.
Martin can check too if i am doing anything wrong here other than the JSET "&".
Ideally pc(program counter) points to the next instruction.
"if w11 & 0x4 goto pc+1;"
"goto pc+4;"
[pc+0] "if w11 & 0x3 goto pc+1;" <== PC is going to be here
[pc+1] "goto pc+2;"
[pc+2] "$dst = 0;"
[pc+3] "goto pc+1;"
[pc+4] "$dst = *(u64 *)($ctx + sk_buff::tstamp);", <== This is where the code is intended to jump to for "goto pc+4;"
>>>> "$dst = 0;"
>>>> "goto pc+1;"
>>>> "$dst = *(u64 *)($ctx + sk_buff::tstamp);",
>>>> .write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);"
>>>> - "if w11 & 0x2 goto pc+1;"
>>>> + "if w11 & 0x4 goto pc+1;"
>>>> "goto pc+2;"
>>>> - "w11 &= -2;"
>>>> + "w11 &= -3;"
next prev parent reply other threads:[~2024-05-06 23:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-04 3:13 [RFC PATCH bpf-next v6 0/3] Replace mono_delivery_time with tstamp_type Abhishek Chauhan
2024-05-04 3:13 ` [RFC PATCH bpf-next v6 1/3] net: Rename mono_delivery_time to tstamp_type for scalabilty Abhishek Chauhan
2024-05-06 18:51 ` Willem de Bruijn
2024-05-06 19:55 ` Abhishek Chauhan (ABC)
2024-05-06 21:29 ` Willem de Bruijn
2024-05-04 3:13 ` [RFC PATCH bpf-next v6 2/3] net: Add additional bit to support clockid_t timestamp type Abhishek Chauhan
2024-05-06 19:00 ` Willem de Bruijn
2024-05-06 19:57 ` Abhishek Chauhan (ABC)
2024-05-07 0:44 ` Martin KaFai Lau
2024-05-07 11:39 ` Willem de Bruijn
2024-05-07 19:08 ` Abhishek Chauhan (ABC)
2024-05-07 19:18 ` Willem de Bruijn
2024-05-07 19:38 ` Abhishek Chauhan (ABC)
2024-05-04 3:13 ` [RFC PATCH bpf-next v6 3/3] selftests/bpf: Handle forwarding of UDP CLOCK_TAI packets Abhishek Chauhan
2024-05-06 19:04 ` Willem de Bruijn
2024-05-06 20:50 ` Abhishek Chauhan (ABC)
2024-05-06 20:54 ` Abhishek Chauhan (ABC)
2024-05-06 23:40 ` Abhishek Chauhan (ABC) [this message]
2024-05-07 0:54 ` Martin KaFai Lau
2024-05-07 19:15 ` Abhishek Chauhan (ABC)
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=8a6e3ed0-186e-4248-98a0-c8b60341d3aa@quicinc.com \
--to=quic_abchauha@quicinc.com \
--cc=ahalaney@redhat.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel@quicinc.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemdebruijn.kernel@gmail.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