public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] landlock08: Skip IPv6 variant if not supported
@ 2025-12-17 19:06 Brian Grech via ltp
  2025-12-18  7:28 ` Andrea Cervesato via ltp
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Grech via ltp @ 2025-12-17 19:06 UTC (permalink / raw)
  To: ltp

Check for IPv6 support before forking the server process to avoid
checkpoint timeout issues. If IPv6 is not available (EAFNOSUPPORT),
report TCONF and skip the variant gracefully.

This allows the landlock08 test to be executed on systems without
IPv6 support.

Signed-off-by: Brian Grech <bgrech@redhat.com>
---
 testcases/kernel/syscalls/landlock/landlock08.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/testcases/kernel/syscalls/landlock/landlock08.c b/testcases/kernel/syscalls/landlock/landlock08.c
index 7c498e6d5..7e7d8470b 100644
--- a/testcases/kernel/syscalls/landlock/landlock08.c
+++ b/testcases/kernel/syscalls/landlock/landlock08.c
@@ -102,12 +102,28 @@ static void test_connect(const int addr_family, const in_port_t port,
 	SAFE_CLOSE(socket.fd);
 }
 
+static int check_ipv6_support(void)
+{
+	int fd;
+
+	fd = socket(AF_INET6, SOCK_STREAM, 0);
+	if (fd == -1 && errno == EAFNOSUPPORT) {
+		tst_res(TCONF, "IPv6 not supported in kernel");
+		return 0;
+	}
+	if (fd != -1)
+		close(fd);
+	return 1;
+}
+
 static void run(void)
 {
 	int addr_family = variants[tst_variant];
 
 	tst_res(TINFO, "Using %s protocol",
 		addr_family == AF_INET ? "IPV4" : "IPV6");
+	if (addr_family == AF_INET6 && !check_ipv6_support())
+		return;
 
 	if (!SAFE_FORK()) {
 		create_server(addr_family);
-- 
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-18  7:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-17 19:06 [LTP] [PATCH] landlock08: Skip IPv6 variant if not supported Brian Grech via ltp
2025-12-18  7:28 ` Andrea Cervesato via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox