Re: [PATCH bpf-next 2/2] selftests/bpf: Add testcase for updating attached freplace prog to PROG_ARRAY map

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



26 July 2024 at 14:16, "Yonghong Song" <yonghong.song@xxxxxxxxx> wrote:

> 
> On 7/24/24 5:32 PM, Leon Hwang wrote:
> 
> > 
> > Add a selftest to confirm the issue, which gets -EINVAL when update
> > 
> >  attached freplace prog to PROG_ARRAY map, has been fixed.
> > 
> >  cd tools/testing/selftests/bpf; ./test_progs -t tailcalls
> > 
> >  327/25 tailcalls/tailcall_freplace:OK
> > 
> >  327 tailcalls:OK
> > 
> >  Summary: 1/25 PASSED, 0 SKIPPED, 0 FAILED
> > 
> >  Signed-off-by: Leon Hwang <leon.hwang@xxxxxxxxx>
> > 
> >  ---
> > 
> >  .../selftests/bpf/prog_tests/tailcalls.c | 76 ++++++++++++++++++-
> > 
> >  .../selftests/bpf/progs/tailcall_freplace.c | 33 ++++++++
> > 
> >  .../testing/selftests/bpf/progs/tc_bpf2bpf.c | 23 ++++++
> > 
> >  3 files changed, 131 insertions(+), 1 deletion(-)
> > 
> >  create mode 100644 tools/testing/selftests/bpf/progs/tailcall_freplace.c
> > 
> >  create mode 100644 tools/testing/selftests/bpf/progs/tc_bpf2bpf.c
> > 
> 
> [...]
> 
> > 
> > diff --git a/tools/testing/selftests/bpf/progs/tailcall_freplace.c b/tools/testing/selftests/bpf/progs/tailcall_freplace.c
> > 
> >  new file mode 100644
> > 
> >  index 0000000000000..80b5fa386ed9c
> > 
> >  --- /dev/null
> > 
> >  +++ b/tools/testing/selftests/bpf/progs/tailcall_freplace.c
> > 
> >  @@ -0,0 +1,33 @@
> > 
> >  +// SPDX-License-Identifier: GPL-2.0
> > 
> >  +
> > 
> >  +#include <linux/bpf.h>
> > 
> >  +#include <bpf/bpf_helpers.h>
> > 
> >  +#include "bpf_legacy.h"
> > 
> >  +
> > 
> >  +struct {
> > 
> >  + __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
> > 
> >  + __uint(max_entries, 1);
> > 
> >  + __uint(key_size, sizeof(__u32));
> > 
> >  + __uint(value_size, sizeof(__u32));
> > 
> >  +} jmp_table SEC(".maps");
> > 
> >  +
> > 
> >  +int count = 0;
> > 
> >  +
> > 
> >  +__noinline
> > 
> >  +int subprog(struct __sk_buff *skb)
> > 
> >  +{
> > 
> >  + count++;
> > 
> >  +
> > 
> >  + bpf_tail_call_static(skb, &jmp_table, 0);
> > 
> >  +
> > 
> >  + return count;
> > 
> >  +}
> > 
> >  +
> > 
> >  +SEC("freplace")
> > 
> >  +int entry(struct __sk_buff *skb)
> > 
> >  +{
> > 
> >  + return subprog(skb);
> > 
> >  +}
> > 
> >  +
> > 
> >  +char __license[] SEC("license") = "GPL";
> > 
> >  +
> > 
> 
> extra line in the above.

Ack.

> 
> > 
> > diff --git a/tools/testing/selftests/bpf/progs/tc_bpf2bpf.c b/tools/testing/selftests/bpf/progs/tc_bpf2bpf.c
> > 
> >  new file mode 100644
> > 
> >  index 0000000000000..4810961554585
> > 
> >  --- /dev/null
> > 
> >  +++ b/tools/testing/selftests/bpf/progs/tc_bpf2bpf.c
> > 
> >  @@ -0,0 +1,23 @@
> > 
> >  +// SPDX-License-Identifier: GPL-2.0
> > 
> >  +
> > 
> >  +#include <linux/bpf.h>
> > 
> >  +#include <bpf/bpf_helpers.h>
> > 
> >  +#include "bpf_legacy.h"
> > 
> >  +
> > 
> >  +__noinline
> > 
> >  +int subprog(struct __sk_buff *skb)
> > 
> >  +{
> > 
> >  + volatile int ret = 1;
> > 
> >  +
> > 
> >  + asm volatile (""::"r+"(ret));
> > 
> >  + return ret;
> > 
> >  +}
> > 
> >  +
> > 
> >  +SEC("tc")
> > 
> >  +int entry(struct __sk_buff *skb)
> > 
> >  +{
> > 
> >  + return subprog(skb);
> > 
> >  +}
> > 
> >  +
> > 
> >  +char __license[] SEC("license") = "GPL";
> > 
> >  +
> > 
> 
> extra line in the above.
>

Ack.

Thanks,
Leon





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux