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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <436b87f7-b5b2-4b5e-8979-47d123783b35@bootlin.com>
Date: Fri, 28 Feb 2025 09:13:52 +0100
From: Bastien Curutchet <bastien.curutchet@...tlin.com>
To: Stanislav Fomichev <stfomichev@...il.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
 Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
 Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman
 <eddyz87@...il.com>, Song Liu <song@...nel.org>,
 Yonghong Song <yonghong.song@...ux.dev>,
 John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
 Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
 Jiri Olsa <jolsa@...nel.org>, Mykola Lysenko <mykolal@...com>,
 Shuah Khan <shuah@...nel.org>,
 Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
 Alexis Lothore <alexis.lothore@...tlin.com>, bpf@...r.kernel.org,
 linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next 01/10] selftests/bpf: test_tunnel: Add
 generic_attach* helpers

Hi Stanislav,

On 2/27/25 11:08 PM, Stanislav Fomichev wrote:
> 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@...tlin.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?

I agree with you, it will be better this way. I'll do it in V2.


Best regards,
Bastien

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ