Skip to content

Commit b3f1798

Browse files
Brian Grech via ltpacerv
authored andcommitted
landlock08: Skip IPv6 variant if not supported
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>
1 parent 443a59c commit b3f1798

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

testcases/kernel/syscalls/landlock/landlock08.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,28 @@ static void test_connect(const int addr_family, const in_port_t port,
102102
SAFE_CLOSE(socket.fd);
103103
}
104104

105+
static int check_ipv6_support(void)
106+
{
107+
int fd;
108+
109+
fd = socket(AF_INET6, SOCK_STREAM, 0);
110+
if (fd == -1 && errno == EAFNOSUPPORT) {
111+
tst_res(TCONF, "IPv6 not supported in kernel");
112+
return 0;
113+
}
114+
if (fd != -1)
115+
close(fd);
116+
return 1;
117+
}
118+
105119
static void run(void)
106120
{
107121
int addr_family = variants[tst_variant];
108122

109123
tst_res(TINFO, "Using %s protocol",
110124
addr_family == AF_INET ? "IPV4" : "IPV6");
125+
if (addr_family == AF_INET6 && !check_ipv6_support())
126+
return;
111127

112128
if (!SAFE_FORK()) {
113129
create_server(addr_family);

0 commit comments

Comments
 (0)