lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8569f47c-0c59-49f6-8b93-09bc0defb670@quicinc.com>
Date: Tue, 7 May 2024 12:15:17 -0700
From: "Abhishek Chauhan (ABC)" <quic_abchauha@...cinc.com>
To: Martin KaFai Lau <martin.lau@...ux.dev>
CC: Willem de Bruijn <willemdebruijn.kernel@...il.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>,
        Daniel Borkmann <daniel@...earbox.net>, bpf <bpf@...r.kernel.org>,
        <kernel@...cinc.com>
Subject: Re: [RFC PATCH bpf-next v6 3/3] selftests/bpf: Handle forwarding of
 UDP CLOCK_TAI packets



On 5/6/2024 5:54 PM, Martin KaFai Lau wrote:
> On 5/6/24 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@...cinc.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 -
> 
> Yes, this should be bitwise "&" instead of "==".
> 
> The bpf CI did report this: https://github.com/kernel-patches/bpf/actions/runs/8947652196/job/24579927178
> 
> Please monitor the bpf CI test result.
> 
> Do you have issue running the test locally?
> 
Yes, To be honest. I am facing compilation issues when i follow the documentation to Make BPF on latest kernel. 

This is slowing down my development with this patch. 

Very similar to the problem described here :- https://github.com/jsitnicki/ebpf-summit-2020/issues/1

local/mnt/workspace/kernel_master/linux-next/tools/testing/selftests/bpf/tools/build/bpftool/bootstrap/libbpf/include/bpf/bpf_core_read.h:379:26: note: expanded from macro '___arrow2'
#define ___arrow2(a, b) a->b
                        ~^
skeleton/pid_iter.bpf.c:19:9: note: forward declaration of 'struct bpf_link'
        struct bpf_link link;
               ^
skeleton/pid_iter.bpf.c:105:7: error: incomplete definition of type 'struct bpf_link'
                if (BPF_CORE_READ(link, type) == bpf_core_enum_value(enum bpf_link_type___local,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~

>>
>> "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;"
>>
>>
>>>>                "$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;"
>> Martin,
>> Also i am not sure why the the dissembly complains because the value of SKB_TSTAMP_TYPE_MASK = 3 and we are
>> negating it ~3 = -3.
>>
>>    Can't match disassembly(left) with pattern(right):
>>    r11 = *(u8 *)(r1 +129)  ;  r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset)
>>    if w11 & 0x4 goto pc+1  ;  if w11 & 0x4 goto pc+1
>>    goto pc+2               ;  goto pc+2
>>    w11 &= -4               ;  w11 &= -3
>>
>>>>                "*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;"
>>>>                "*(u64 *)($ctx + sk_buff::tstamp) = $src;",
>>>>       },
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ