BPF List
 help / color / mirror / Atom feed
From: Bastien Curutchet <bastien.curutchet@bootlin.com>
To: "Alexis Lothoré" <alexis.lothore@bootlin.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Jesper Dangaard Brouer" <hawk@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"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>,
	"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>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] selftests/bpf: Migrate test_xdp_redirect.sh to xdp_do_redirect.c
Date: Mon, 6 Jan 2025 08:54:18 +0100	[thread overview]
Message-ID: <9a18fec7-8f73-48c6-81d4-5baa5b701f76@bootlin.com> (raw)
In-Reply-To: <c7ff7788-d3af-4867-8b13-57a0bf1f529a@bootlin.com>

Hi Alexis,

On 1/3/25 1:54 PM, Alexis Lothoré wrote:
> Hi Bastien,
> 
> On 1/3/25 11:10, Bastien Curutchet (eBPF Foundation) wrote:
> 
> [...]
> 
>> +		SYS(fail, "ip link add veth%d index %d%d%d type veth peer name veth0 netns %s",
>> +		    i, i, i, i, ns_name);
> 
> nit: since you have to run an ip command through SYS anyway, you can reduce the
> open ns/run command/close ns dance (and all the resulting error checks) by
> running directly `SYS("ip netns exec %s ip link add [...]", NS0, [...])`
> 
> [...]
> 

True, thanks.

>> +	ret = bpf_xdp_attach(if_nametoindex("veth2"),
>> +			     bpf_program__fd(prog_to_111),
>> +			     data->xdp_flags, NULL);
> 
> nit: since we are setting static if index at veth creation (which looks needed
> for this test), the if_nametoindex could be replaced by the corresponding index,
> which could be directly a define
> 

Also true, thanks.

>> +	if (!ASSERT_GE(ret, 0, "bpf_xdp_attach"))
>> +		goto close;
>> +
>> +	ret = bpf_xdp_attach(if_nametoindex("veth1"),
>> +			     bpf_program__fd(prog_to_222),
>> +			     data->xdp_flags, NULL);
>> +	if (!ASSERT_GE(ret, 0, "bpf_xdp_attach"))
>> +		goto close;
>> +
>> +	close_netns(nstoken);
>> +
>> +	nstoken = open_netns(NS1);
>> +	if (!ASSERT_OK_PTR(nstoken, "open NS1"))
>> +		goto close;
>> +
>> +	SYS(close, "ping -c 1 %s.2", IPV4_NETWORK);
>> +
>> +	close_netns(nstoken);
>> +
>> +	nstoken = open_netns(NS2);
>> +	if (!ASSERT_OK_PTR(nstoken, "open NS2"))
>> +		goto close;
>> +
>> +	SYS(close, "ping -c 1 %s.1", IPV4_NETWORK);
> 
> Is it really useful to check ping originating from both interfaces, isn´t a
> single ping able to stimulate programs attached to both veth0 ?
> 

Indeed, I think a single ping would be enough, I just wanted to stick 
with what test_xdp_redirect.sh does.

> Aside from those minor points, LGTM :)
> 

Best regards,
Bastien

  reply	other threads:[~2025-01-06  7:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-03 10:10 [PATCH 0/3] selftests: bpf: Migrate test_xdp_redirect.sh to test_progs Bastien Curutchet (eBPF Foundation)
2025-01-03 10:10 ` [PATCH 1/3] selftests/bpf: test_xdp_redirect: Rename BPF sections Bastien Curutchet (eBPF Foundation)
2025-01-03 13:18   ` Alexis Lothoré
2025-01-03 10:10 ` [PATCH 2/3] selftests/bpf: Migrate test_xdp_redirect.sh to xdp_do_redirect.c Bastien Curutchet (eBPF Foundation)
2025-01-03 12:54   ` Alexis Lothoré
2025-01-06  7:54     ` Bastien Curutchet [this message]
2025-01-03 13:17   ` Alexis Lothoré
2025-01-06  8:24     ` Bastien Curutchet
2025-01-07 19:48   ` Martin KaFai Lau
2025-01-03 10:10 ` [PATCH 3/3] selftests/bpf: Migrate test_xdp_redirect.c to test_xdp_do_redirect.c Bastien Curutchet (eBPF Foundation)
2025-01-03 10:20 ` [PATCH 0/3] selftests: bpf: Migrate test_xdp_redirect.sh to test_progs Bastien Curutchet

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=9a18fec7-8f73-48c6-81d4-5baa5b701f76@bootlin.com \
    --to=bastien.curutchet@bootlin.com \
    --cc=alexis.lothore@bootlin.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=netdev@vger.kernel.org \
    --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