[LTP] [PATCH] landlock08: Skip IPv6 variant if not supported

Brian Grech bgrech@redhat.com
Wed Dec 17 20:06:37 CET 2025


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



More information about the ltp mailing list