From: Yonghong Song <yonghong.song@linux.dev>
To: Leon Hwang <leon.hwang@linux.dev>, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
toke@redhat.com, martin.lau@kernel.org, eddyz87@gmail.com,
wutengda@huaweicloud.com, kernel-patches-bot@fb.com
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Add testcase for updating attached freplace prog to PROG_ARRAY map
Date: Thu, 25 Jul 2024 23:16:35 -0700 [thread overview]
Message-ID: <eb964de3-1a07-49a3-9d26-68777e1fc1cb@linux.dev> (raw)
In-Reply-To: <20240725003251.37855-3-leon.hwang@linux.dev>
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@linux.dev>
> ---
> .../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.
> 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.
next prev parent reply other threads:[~2024-07-26 6:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 0:32 [PATCH bpf-next 0/2] bpf: Fix updating attached freplace prog to PROG_ARRAY map Leon Hwang
2024-07-25 0:32 ` [PATCH bpf-next 1/2] " Leon Hwang
2024-07-25 20:58 ` Yonghong Song
2024-07-26 3:27 ` leon.hwang
2024-07-26 6:15 ` Yonghong Song
2024-07-26 7:31 ` Leon Hwang
2024-07-25 0:32 ` [PATCH bpf-next 2/2] selftests/bpf: Add testcase for " Leon Hwang
2024-07-25 21:11 ` Yonghong Song
2024-07-26 3:33 ` leon.hwang
2024-07-26 6:16 ` Yonghong Song [this message]
2024-07-26 7:33 ` Leon Hwang
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=eb964de3-1a07-49a3-9d26-68777e1fc1cb@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-patches-bot@fb.com \
--cc=leon.hwang@linux.dev \
--cc=martin.lau@kernel.org \
--cc=toke@redhat.com \
--cc=wutengda@huaweicloud.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