[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CC4F692C-1245-4199-9BDD-4C64C035590B@fb.com>
Date: Fri, 8 Nov 2019 19:03:16 +0000
From: Song Liu <songliubraving@...com>
To: Alexei Starovoitov <ast@...nel.org>
CC: David Miller <davem@...emloft.net>,
"daniel@...earbox.net" <daniel@...earbox.net>,
"x86@...nel.org" <x86@...nel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"bpf@...r.kernel.org" <bpf@...r.kernel.org>,
Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH v3 bpf-next 17/18] selftests/bpf: Extend test_pkt_access
test
> On Nov 7, 2019, at 10:40 PM, Alexei Starovoitov <ast@...nel.org> wrote:
>
> The test_pkt_access.o is used by multiple tests. Fix its section name so that
> program type can be automatically detected by libbpf and make it call other
> subprograms with skb argument.
>
> Signed-off-by: Alexei Starovoitov <ast@...nel.org>
Acked-by: Song Liu <songliubraving@...com>
> ---
> .../selftests/bpf/progs/test_pkt_access.c | 38 ++++++++++++++++++-
> 1 file changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_pkt_access.c b/tools/testing/selftests/bpf/progs/test_pkt_access.c
> index 7cf42d14103f..3a7b4b607ed3 100644
> --- a/tools/testing/selftests/bpf/progs/test_pkt_access.c
> +++ b/tools/testing/selftests/bpf/progs/test_pkt_access.c
> @@ -17,8 +17,38 @@
> #define barrier() __asm__ __volatile__("": : :"memory")
> int _version SEC("version") = 1;
>
> -SEC("test1")
> -int process(struct __sk_buff *skb)
> +/* llvm will optimize both subprograms into exactly the same BPF assembly
> + *
> + * Disassembly of section .text:
> + *
> + * 0000000000000000 test_pkt_access_subprog1:
> + * ; return skb->len * 2;
> + * 0: 61 10 00 00 00 00 00 00 r0 = *(u32 *)(r1 + 0)
> + * 1: 64 00 00 00 01 00 00 00 w0 <<= 1
> + * 2: 95 00 00 00 00 00 00 00 exit
> + *
> + * 0000000000000018 test_pkt_access_subprog2:
> + * ; return skb->len * val;
> + * 3: 61 10 00 00 00 00 00 00 r0 = *(u32 *)(r1 + 0)
> + * 4: 64 00 00 00 01 00 00 00 w0 <<= 1
> + * 5: 95 00 00 00 00 00 00 00 exit
> + *
> + * Which makes it an interesting test for BTF-enabled verifier.
This is interesting!
Powered by blists - more mailing lists