* [PATCH bpf-next] selftests/bpf: Clean up sa_family_t-stringifier
@ 2026-10-08 17:12 Michal Luczaj
2026-10-08 17:23 ` Kuniyuki Iwashima
2026-10-15 16:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Michal Luczaj @ 2026-10-08 17:12 UTC (permalink / raw)
To: Andrii Nakryiko, Eduard Zingerman, Ihor Solodrai,
Alexei Starovoitov, Daniel Borkmann, Kumar Kartikeya Dwivedi,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Shuah Khan
Cc: bpf, linux-kselftest, linux-kernel, Kuniyuki Iwashima, Michal Luczaj
Following commit f3de1cf621f7 ("selftests/bpf: sockmap_listen cleanup: Drop
af_unix redir tests") and commit 9266e49d608c ("selftests/bpf:
sockmap_listen cleanup: Drop af_vsock redir tests"), sockmap_listen.c:
family_str() becomes functionally identical to select_reuseport.c:
family_str(). Move the logic to socket_helpers.h.
Suggested-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://msgid.link/CAAVpQUDULzZh58oKkRaYqgM9bRToGb7wHrzT+cZNpRmAtM12Ow@mail.gmail.com
Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
.../selftests/bpf/prog_tests/select_reuseport.c | 16 +++-------------
.../selftests/bpf/prog_tests/socket_helpers.h | 12 ++++++++++++
.../selftests/bpf/prog_tests/sockmap_listen.c | 22 +++-------------------
3 files changed, 18 insertions(+), 32 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c
index 3dbcc091f16c..3b4b233e21d1 100644
--- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c
+++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c
@@ -6,6 +6,7 @@
#include <stdbool.h>
#include <string.h>
#include <errno.h>
+#include <error.h>
#include <assert.h>
#include <fcntl.h>
#include <linux/bpf.h>
@@ -21,6 +22,7 @@
#include "bpf_util.h"
#include "test_progs.h"
+#include "socket_helpers.h"
#include "test_select_reuseport_common.h"
#define MAX_TEST_NAME 80
@@ -740,18 +742,6 @@ static const char *maptype_str(enum bpf_map_type type)
}
}
-static const char *family_str(sa_family_t family)
-{
- switch (family) {
- case AF_INET:
- return "IPv4";
- case AF_INET6:
- return "IPv6";
- default:
- return "unknown";
- }
-}
-
static const char *sotype_str(int sotype)
{
switch (sotype) {
@@ -794,7 +784,7 @@ static void test_config(int sotype, sa_family_t family, bool inany)
snprintf(s, sizeof(s), "%s %s/%s %s %s",
maptype_str(inner_map_type),
- family_str(family), sotype_str(sotype),
+ inet_family_str(family), sotype_str(sotype),
inany ? "INANY" : "LOOPBACK", t->name);
if (!test__start_subtest(s))
diff --git a/tools/testing/selftests/bpf/prog_tests/socket_helpers.h b/tools/testing/selftests/bpf/prog_tests/socket_helpers.h
index 0d59503a0c73..4a570998612d 100644
--- a/tools/testing/selftests/bpf/prog_tests/socket_helpers.h
+++ b/tools/testing/selftests/bpf/prog_tests/socket_helpers.h
@@ -470,4 +470,16 @@ static inline const char *socket_kind_to_str(int sock_fd)
return "???";
}
+static inline const char *inet_family_str(sa_family_t family)
+{
+ switch (family) {
+ case AF_INET:
+ return "IPv4";
+ case AF_INET6:
+ return "IPv6";
+ default:
+ return "unknown";
+ }
+}
+
#endif // __SOCKET_HELPERS__
diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
index 1c96a3cf4b97..235e1d56f044 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
@@ -1232,22 +1232,6 @@ static void test_ops_cleanup(const struct bpf_map *map)
}
}
-static const char *family_str(sa_family_t family)
-{
- switch (family) {
- case AF_INET:
- return "IPv4";
- case AF_INET6:
- return "IPv6";
- case AF_UNIX:
- return "Unix";
- case AF_VSOCK:
- return "VSOCK";
- default:
- return "unknown";
- }
-}
-
static const char *map_type_str(const struct bpf_map *map)
{
int type;
@@ -1315,7 +1299,7 @@ static void test_ops(struct test_sockmap_listen *skel, struct bpf_map *map,
char s[MAX_TEST_NAME];
int map_fd;
- family_name = family_str(family);
+ family_name = inet_family_str(family);
map_name = map_type_str(map);
sotype_name = sotype_str(sotype);
map_fd = bpf_map__fd(map);
@@ -1355,7 +1339,7 @@ static void test_redir(struct test_sockmap_listen *skel, struct bpf_map *map,
const struct redir_test *t;
char s[MAX_TEST_NAME];
- family_name = family_str(family);
+ family_name = inet_family_str(family);
map_name = map_type_str(map);
for (t = tests; t < tests + ARRAY_SIZE(tests); t++) {
@@ -1387,7 +1371,7 @@ static void test_reuseport(struct test_sockmap_listen *skel,
const struct reuseport_test *t;
char s[MAX_TEST_NAME];
- family_name = family_str(family);
+ family_name = inet_family_str(family);
map_name = map_type_str(map);
sotype_name = sotype_str(sotype);
---
base-commit: e1d84a37cba984388988d2f1ddc84561413f0db2
change-id: 20260724-selftests-sockmap_listen-cleanup-7ff21e9bedc6
Best regards,
--
Michal Luczaj <mhal@rbox.co>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: Clean up sa_family_t-stringifier
2026-10-08 17:12 [PATCH bpf-next] selftests/bpf: Clean up sa_family_t-stringifier Michal Luczaj
@ 2026-10-08 17:23 ` Kuniyuki Iwashima
2026-10-15 16:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2026-10-08 17:23 UTC (permalink / raw)
To: Michal Luczaj
Cc: Andrii Nakryiko, Eduard Zingerman, Ihor Solodrai,
Alexei Starovoitov, Daniel Borkmann, Kumar Kartikeya Dwivedi,
Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
Emil Tsalapatis, Shuah Khan, bpf, linux-kselftest, linux-kernel
On Thu, Oct 8, 2026 at 10:12 AM Michal Luczaj <mhal@rbox.co> wrote:
>
> Following commit f3de1cf621f7 ("selftests/bpf: sockmap_listen cleanup: Drop
> af_unix redir tests") and commit 9266e49d608c ("selftests/bpf:
> sockmap_listen cleanup: Drop af_vsock redir tests"), sockmap_listen.c:
> family_str() becomes functionally identical to select_reuseport.c:
> family_str(). Move the logic to socket_helpers.h.
>
> Suggested-by: Kuniyuki Iwashima <kuniyu@google.com>
> Link: https://msgid.link/CAAVpQUDULzZh58oKkRaYqgM9bRToGb7wHrzT+cZNpRmAtM12Ow@mail.gmail.com
> Signed-off-by: Michal Luczaj <mhal@rbox.co>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: Clean up sa_family_t-stringifier
2026-10-08 17:12 [PATCH bpf-next] selftests/bpf: Clean up sa_family_t-stringifier Michal Luczaj
2026-10-08 17:23 ` Kuniyuki Iwashima
@ 2026-10-15 16:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-10-15 16:20 UTC (permalink / raw)
To: Michal Luczaj
Cc: andrii, eddyz87, ihor.solodrai, ast, daniel, memxor, martin.lau,
song, yonghong.song, jolsa, emil, shuah, bpf, linux-kselftest,
linux-kernel, kuniyu
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Thu, 08 Oct 2026 19:12:15 +0200 you wrote:
> Following commit f3de1cf621f7 ("selftests/bpf: sockmap_listen cleanup: Drop
> af_unix redir tests") and commit 9266e49d608c ("selftests/bpf:
> sockmap_listen cleanup: Drop af_vsock redir tests"), sockmap_listen.c:
> family_str() becomes functionally identical to select_reuseport.c:
> family_str(). Move the logic to socket_helpers.h.
>
> Suggested-by: Kuniyuki Iwashima <kuniyu@google.com>
> Link: https://msgid.link/CAAVpQUDULzZh58oKkRaYqgM9bRToGb7wHrzT+cZNpRmAtM12Ow@mail.gmail.com
> Signed-off-by: Michal Luczaj <mhal@rbox.co>
>
> [...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Clean up sa_family_t-stringifier
https://git.kernel.org/bpf/bpf-next/c/7f34009230b7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-15 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08 17:12 [PATCH bpf-next] selftests/bpf: Clean up sa_family_t-stringifier Michal Luczaj
2026-10-08 17:23 ` Kuniyuki Iwashima
2026-10-15 16:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®