From: Stanislav Fomichev <stfomichev@gmail.com>
To: "Bastien Curutchet (eBPF Foundation)" <bastien.curutchet@bootlin.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>,
Shuah Khan <shuah@kernel.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Alexis Lothore <alexis.lothore@bootlin.com>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next 01/10] selftests/bpf: test_tunnel: Add generic_attach* helpers
Date: Thu, 27 Feb 2025 14:08:31 -0800 [thread overview]
Message-ID: <Z8DiX8MmJWvO5Ws2@mini-arch> (raw)
In-Reply-To: <20250227-tunnels-v1-1-33df5c30aa04@bootlin.com>
On 02/27, Bastien Curutchet (eBPF Foundation) wrote:
> A fair amount of code duplication is present among tests to attach BPF
> programs.
>
> Create generic_attach* helpers that attach BPF programs to a given
> interface.
> Use ASSERT_OK_FD() instead of ASSERT_GE() to check fd's validity.
> Use these helpers in all the available tests.
>
> Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
> ---
> .../testing/selftests/bpf/prog_tests/test_tunnel.c | 128 ++++++++++-----------
> 1 file changed, 62 insertions(+), 66 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c
> index cec746e77cd3abdf561cfc2422fa0a934fc481cd..27a8c8caa87e4c6b39b2b26c2aa9860b131a70a9 100644
> --- a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c
> +++ b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c
> @@ -397,6 +397,56 @@ static int attach_tc_prog(struct bpf_tc_hook *hook, int igr_fd, int egr_fd)
> return 0;
> }
>
> +static int generic_attach(const char *dev, int igr_fd, int egr_fd)
> +{
> + DECLARE_LIBBPF_OPTS(bpf_tc_hook, tc_hook, .attach_point = BPF_TC_INGRESS);
nit: .attach_point = BPF_TC_INGRESS is a bit confusing to me here
(because we later attach both ingress and egress progs); mostly
because the way attach_tc_prog is written I think. Can we move
tc_hook definition to attach_tc_prog and make it
.attach_point=BPF_TC_INGRESS|BPF_TC_EGRESS? And then we can make
attach_tc_prog accept ifindex instead of tc_hook.
int attach_tc_prog(int ifindex, igr_fd, egr_fd)
{
DECLARE_LIBBPF_OPTS(bpf_tc_hook, tc_hook, .attach_point = BPF_TC_INGRESS|BPF_TC_EGRESS);
bpf_tc_hook_create(&tc_hook);
if (igr_fd >= 0) {
tc_hook.attach_point = BPF_TC_INGRESS;
...
}
if (egr_fd >= 0) {
tc_hook.attach_point = BPF_TC_EGRESS;
...
}
}
Or is it just me?
next prev parent reply other threads:[~2025-02-27 22:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-27 13:24 [PATCH bpf-next 00/10] selftests/bpf: Migrate test_tunnel.sh to test_progs Bastien Curutchet (eBPF Foundation)
2025-02-27 13:24 ` [PATCH bpf-next 01/10] selftests/bpf: test_tunnel: Add generic_attach* helpers Bastien Curutchet (eBPF Foundation)
2025-02-27 22:08 ` Stanislav Fomichev [this message]
2025-02-28 8:13 ` Bastien Curutchet
2025-02-27 13:24 ` [PATCH bpf-next 02/10] selftests/bpf: test_tunnel: Add ping helpers Bastien Curutchet (eBPF Foundation)
2025-02-27 22:10 ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 03/10] selftests/bpf: test_tunnel: Move gre tunnel test to test_progs Bastien Curutchet (eBPF Foundation)
2025-02-27 22:17 ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 04/10] selftests/bpf: test_tunnel: Move ip6gre " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:18 ` Stanislav Fomichev
2025-02-28 8:15 ` Bastien Curutchet
2025-02-27 13:24 ` [PATCH bpf-next 05/10] selftests/bpf: test_tunnel: Move erspan tunnel tests " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:19 ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 06/10] selftests/bpf: test_tunnel: Move ip6erspan tunnel test " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:20 ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 07/10] selftests/bpf: test_tunnel: Move geneve " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:21 ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 08/10] selftests/bpf: test_tunnel: Move ip6geneve " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:21 ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 09/10] selftests/bpf: test_tunnel: Move ip6tnl tunnel tests " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:22 ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 10/10] selftests/bpf: test_tunnel: Remove test_tunnel.sh Bastien Curutchet (eBPF Foundation)
2025-02-27 22:22 ` Stanislav Fomichev
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=Z8DiX8MmJWvO5Ws2@mini-arch \
--to=stfomichev@gmail.com \
--cc=alexis.lothore@bootlin.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bastien.curutchet@bootlin.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=yonghong.song@linux.dev \
/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