Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Michal Luczaj <mhal@rbox.co>
To: Jakub Sitnicki <jakub@cloudflare.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Mykola Lysenko <mykolal@fb.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	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>, Shuah Khan <shuah@kernel.org>,
	bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] selftests/bpf: Allow setting BPF_F_INGRESS in prog_msg_verdict()
Date: Wed, 14 Aug 2024 18:18:26 +0200	[thread overview]
Message-ID: <a2c8831b-68bf-4c6f-ad5e-3ac67de2d314@rbox.co> (raw)
In-Reply-To: <42939687-20f9-4a45-b7c2-342a0e11a014@rbox.co>

Let a selftest set BPF_F_INGRESS for map/hash redirect.

In run_tests(), explicitly reset skel->bss->test_ingress to false. Earlier
tests might have left it flipped.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
 tools/testing/selftests/bpf/prog_tests/sockmap_listen.c | 2 ++
 tools/testing/selftests/bpf/progs/test_sockmap_listen.c | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
index da5a6fb03b69..a5e7d27760cf 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
@@ -1850,6 +1850,8 @@ static void test_udp_unix_redir(struct test_sockmap_listen *skel, struct bpf_map
 static void run_tests(struct test_sockmap_listen *skel, struct bpf_map *map,
 		      int family)
 {
+	skel->bss->test_ingress = false;
+
 	test_ops(skel, map, family, SOCK_STREAM);
 	test_ops(skel, map, family, SOCK_DGRAM);
 	test_redir(skel, map, family, SOCK_STREAM);
diff --git a/tools/testing/selftests/bpf/progs/test_sockmap_listen.c b/tools/testing/selftests/bpf/progs/test_sockmap_listen.c
index b7250eb9c30c..5a3504d5dfc3 100644
--- a/tools/testing/selftests/bpf/progs/test_sockmap_listen.c
+++ b/tools/testing/selftests/bpf/progs/test_sockmap_listen.c
@@ -106,9 +106,11 @@ int prog_msg_verdict(struct sk_msg_md *msg)
 	int verdict;
 
 	if (test_sockmap)
-		verdict = bpf_msg_redirect_map(msg, &sock_map, zero, 0);
+		verdict = bpf_msg_redirect_map(msg, &sock_map, zero,
+					       test_ingress ? BPF_F_INGRESS : 0);
 	else
-		verdict = bpf_msg_redirect_hash(msg, &sock_hash, &zero, 0);
+		verdict = bpf_msg_redirect_hash(msg, &sock_hash, &zero,
+						test_ingress ? BPF_F_INGRESS : 0);
 
 	count = bpf_map_lookup_elem(&verdict_map, &verdict);
 	if (count)
-- 
2.46.0

  parent reply	other threads:[~2024-08-14 16:18 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31 10:01 [PATCH bpf-next v2 0/6] selftests/bpf: Various sockmap-related fixes Michal Luczaj
2024-07-31 10:01 ` [PATCH bpf-next v2 1/6] selftests/bpf: Support more socket types in create_pair() Michal Luczaj
2024-07-31 10:01 ` [PATCH bpf-next v2 2/6] selftests/bpf: Socket pair creation, cleanups Michal Luczaj
2024-07-31 10:01 ` [PATCH bpf-next v2 3/6] selftests/bpf: Simplify inet_socketpair() and vsock_socketpair_connectible() Michal Luczaj
2024-07-31 10:01 ` [PATCH bpf-next v2 4/6] selftests/bpf: Honour the sotype of af_unix redir tests Michal Luczaj
2024-07-31 10:01 ` [PATCH bpf-next v2 5/6] selftests/bpf: Exercise SOCK_STREAM unix_inet_redir_to_connected() Michal Luczaj
2024-07-31 10:01 ` [PATCH bpf-next v2 6/6] selftests/bpf: Introduce __attribute__((cleanup)) in create_pair() Michal Luczaj
2024-08-05 15:22 ` [PATCH bpf-next v2 0/6] selftests/bpf: Various sockmap-related fixes Jakub Sitnicki
2024-08-05 19:54   ` Michal Luczaj
2024-08-06 12:01 ` Jakub Sitnicki
2024-08-06 17:18   ` Michal Luczaj
2024-08-06 17:45     ` Jakub Sitnicki
2024-08-14 16:14       ` Michal Luczaj
2024-08-14 16:17         ` [PATCH 1/3] selftests/bpf: Support AF_UNIX SOCK_DGRAM socket pair creation Michal Luczaj
2024-08-14 16:18         ` Michal Luczaj [this message]
2024-08-14 16:20         ` [PATCH 3/3] selftests/bpf: Add selftest for sockmap/hashmap redirection Michal Luczaj
2024-08-16 19:03         ` [PATCH bpf-next v2 0/6] selftests/bpf: Various sockmap-related fixes Jakub Sitnicki
2024-08-19 22:45           ` Martin KaFai Lau
2024-08-19 20:05         ` Jakub Sitnicki
2024-09-24 10:25           ` Michal Luczaj
2024-09-26 22:54             ` Michal Luczaj
2024-09-27  9:15               ` Jakub Sitnicki
2024-10-02  8:27                 ` Michal Luczaj
2024-10-09  9:46                   ` Jakub Sitnicki
2024-10-09 22:31                     ` Michal Luczaj
2025-04-11 11:44           ` Michal Luczaj
2024-08-20  0:20 ` Martin KaFai Lau

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=a2c8831b-68bf-4c6f-ad5e-3ac67de2d314@rbox.co \
    --to=mhal@rbox.co \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=jakub@cloudflare.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=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