BPF List
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: "Bastien Curutchet (eBPF Foundation)" <bastien.curutchet@bootlin.com>
Cc: 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>,
	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>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Alexis Lothore <alexis.lothore@bootlin.com>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 2/3] selftests/bpf: Migrate test_xdp_redirect.sh to xdp_do_redirect.c
Date: Fri, 10 Jan 2025 17:45:45 -0800	[thread overview]
Message-ID: <8b72630d-8804-4b80-b4bd-857066b64b08@linux.dev> (raw)
In-Reply-To: <20250110-xdp_redirect-v2-2-b8f3ae53e894@bootlin.com>

On 1/10/25 1:21 AM, Bastien Curutchet (eBPF Foundation) wrote:
> +static void ping_test(struct test_data *data)
> +{
> +	struct test_xdp_redirect *skel = NULL;
> +	struct xdp_dummy *skel_dummy = NULL;
> +	struct nstoken *nstoken = NULL;
> +	int i, ret;
> +
> +	skel_dummy = xdp_dummy__open_and_load();
> +	if (!ASSERT_OK_PTR(skel_dummy, "open and load xdp_dummy skeleton"))
> +		goto close;
> +
> +	for (i = 1; i < NS_NB; i++) {
> +		char ns_name[4] = {};
> +
> +		snprintf(ns_name, 4, "NS%d", i);
> +		nstoken = open_netns(ns_name);
> +		if (!ASSERT_OK_PTR(nstoken, "open ns"))
> +			goto close;
> +
> +		ret = bpf_xdp_attach(if_nametoindex("veth0"),
> +				     bpf_program__fd(skel_dummy->progs.xdp_dummy_prog),
> +				     data->xdp_flags, NULL);
> +		if (!ASSERT_GE(ret, 0, "bpf_xdp_attach dummy_prog"))
> +			goto close;
> +
> +		close_netns(nstoken);
> +		nstoken = NULL;
> +	}
> +
> +	skel = test_xdp_redirect__open_and_load();
> +	if (!ASSERT_OK_PTR(skel, "open and load skeleton"))
> +		goto close;
> +
> +	nstoken = open_netns(NS0);
> +	if (!ASSERT_OK_PTR(nstoken, "open NS0"))
> +		goto close;
> +
> +	ret = bpf_xdp_attach(VETH2_INDEX,
> +			     bpf_program__fd(skel->progs.xdp_redirect_to_111),
> +			     data->xdp_flags, NULL);
> +	if (!ASSERT_GE(ret, 0, "bpf_xdp_attach"))
> +		goto close;
> +
> +	ret = bpf_xdp_attach(VETH1_INDEX,
> +			     bpf_program__fd(skel->progs.xdp_redirect_to_222),
> +			     data->xdp_flags, NULL);
> +	if (!ASSERT_GE(ret, 0, "bpf_xdp_attach"))
> +		goto close;
> +
> +	close_netns(nstoken);
> +	nstoken = NULL;
> +
> +	nstoken = open_netns(NS1);
> +	if (!ASSERT_OK_PTR(nstoken, "open NS1"))
> +		goto close;
> +
> +	SYS(close, "ping -c 1 %s.2", IPV4_NETWORK);

I added "> /dev/null" to remove noise for common case.

Applied. Thanks.

  reply	other threads:[~2025-01-11  1:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-10  9:21 [PATCH bpf-next v2 0/3] selftests: bpf: Migrate test_xdp_redirect.sh to test_progs Bastien Curutchet (eBPF Foundation)
2025-01-10  9:21 ` [PATCH bpf-next v2 1/3] selftests/bpf: test_xdp_redirect: Rename BPF sections Bastien Curutchet (eBPF Foundation)
2025-01-10  9:21 ` [PATCH bpf-next v2 2/3] selftests/bpf: Migrate test_xdp_redirect.sh to xdp_do_redirect.c Bastien Curutchet (eBPF Foundation)
2025-01-11  1:45   ` Martin KaFai Lau [this message]
2025-01-10  9:21 ` [PATCH bpf-next v2 3/3] selftests/bpf: Migrate test_xdp_redirect.c to test_xdp_do_redirect.c Bastien Curutchet (eBPF Foundation)
2025-01-11  1:41 ` [PATCH bpf-next v2 0/3] selftests: bpf: Migrate test_xdp_redirect.sh to test_progs patchwork-bot+netdevbpf

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=8b72630d-8804-4b80-b4bd-857066b64b08@linux.dev \
    --to=martin.lau@linux.dev \
    --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=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=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