mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
selftest: tcp: Add bind() tests for IPV6_V6ONLY.
bhash2 was not well tested for IPv6-only sockets. This patch adds test cases where we set IPV6_V6ONLY for per-fixture bind() calls if variant->ipv6_only[i] is true. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://lore.kernel.org/r/20240326204251.51301-8-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
f40742c22a
commit
d37f2f72c9
@ -42,6 +42,7 @@ FIXTURE_VARIANT(bind_wildcard)
|
|||||||
{
|
{
|
||||||
sa_family_t family[2];
|
sa_family_t family[2];
|
||||||
const void *addr[2];
|
const void *addr[2];
|
||||||
|
bool ipv6_only[2];
|
||||||
|
|
||||||
/* 6 bind() calls below follow two bind() for the defined 2 addresses:
|
/* 6 bind() calls below follow two bind() for the defined 2 addresses:
|
||||||
*
|
*
|
||||||
@ -87,6 +88,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v4_any_v6_any)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v4_any_v6_any_only)
|
||||||
|
{
|
||||||
|
.family = {AF_INET, AF_INET6},
|
||||||
|
.addr = {&in4addr_any, &in6addr_any},
|
||||||
|
.ipv6_only = {false, true},
|
||||||
|
.expected_errno = {0, 0,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v4_any_v6_local)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v4_any_v6_local)
|
||||||
{
|
{
|
||||||
.family = {AF_INET, AF_INET6},
|
.family = {AF_INET, AF_INET6},
|
||||||
@ -127,6 +139,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v4_local_v6_any)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v4_local_v6_any_only)
|
||||||
|
{
|
||||||
|
.family = {AF_INET, AF_INET6},
|
||||||
|
.addr = {&in4addr_loopback, &in6addr_any},
|
||||||
|
.ipv6_only = {false, true},
|
||||||
|
.expected_errno = {0, 0,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v4_local_v6_local)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v4_local_v6_local)
|
||||||
{
|
{
|
||||||
.family = {AF_INET, AF_INET6},
|
.family = {AF_INET, AF_INET6},
|
||||||
@ -168,6 +191,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v4_any)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_only_v4_any)
|
||||||
|
{
|
||||||
|
.family = {AF_INET6, AF_INET},
|
||||||
|
.addr = {&in6addr_any, &in4addr_any},
|
||||||
|
.ipv6_only = {true, false},
|
||||||
|
.expected_errno = {0, 0,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v4_local)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v4_local)
|
||||||
{
|
{
|
||||||
.family = {AF_INET6, AF_INET},
|
.family = {AF_INET6, AF_INET},
|
||||||
@ -178,6 +212,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v4_local)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_only_v4_local)
|
||||||
|
{
|
||||||
|
.family = {AF_INET6, AF_INET},
|
||||||
|
.addr = {&in6addr_any, &in4addr_loopback},
|
||||||
|
.ipv6_only = {true, false},
|
||||||
|
.expected_errno = {0, 0,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v6_local_v4_any)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_local_v4_any)
|
||||||
{
|
{
|
||||||
.family = {AF_INET6, AF_INET},
|
.family = {AF_INET6, AF_INET},
|
||||||
@ -249,6 +294,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v6_local)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_only_v6_local)
|
||||||
|
{
|
||||||
|
.family = {AF_INET6, AF_INET6},
|
||||||
|
.addr = {&in6addr_any, &in6addr_loopback},
|
||||||
|
.ipv6_only = {true, false},
|
||||||
|
.expected_errno = {0, EADDRINUSE,
|
||||||
|
0, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v6_v4mapped_any)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v6_v4mapped_any)
|
||||||
{
|
{
|
||||||
.family = {AF_INET6, AF_INET6},
|
.family = {AF_INET6, AF_INET6},
|
||||||
@ -259,6 +315,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v6_v4mapped_any)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_only_v6_v4mapped_any)
|
||||||
|
{
|
||||||
|
.family = {AF_INET6, AF_INET6},
|
||||||
|
.addr = {&in6addr_any, &in6addr_v4mapped_any},
|
||||||
|
.ipv6_only = {true, false},
|
||||||
|
.expected_errno = {0, 0,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v6_v4mapped_local)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v6_v4mapped_local)
|
||||||
{
|
{
|
||||||
.family = {AF_INET6, AF_INET6},
|
.family = {AF_INET6, AF_INET6},
|
||||||
@ -269,6 +336,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_v6_v4mapped_local)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_any_only_v6_v4mapped_local)
|
||||||
|
{
|
||||||
|
.family = {AF_INET6, AF_INET6},
|
||||||
|
.addr = {&in6addr_any, &in6addr_v4mapped_loopback},
|
||||||
|
.ipv6_only = {true, false},
|
||||||
|
.expected_errno = {0, 0,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v6_local_v6_any)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_local_v6_any)
|
||||||
{
|
{
|
||||||
.family = {AF_INET6, AF_INET6},
|
.family = {AF_INET6, AF_INET6},
|
||||||
@ -279,6 +357,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v6_local_v6_any)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_local_v6_any_only)
|
||||||
|
{
|
||||||
|
.family = {AF_INET6, AF_INET6},
|
||||||
|
.addr = {&in6addr_loopback, &in6addr_any},
|
||||||
|
.ipv6_only = {false, true},
|
||||||
|
.expected_errno = {0, EADDRINUSE,
|
||||||
|
0, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v6_local_v6_v4mapped_any)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_local_v6_v4mapped_any)
|
||||||
{
|
{
|
||||||
.family = {AF_INET6, AF_INET6},
|
.family = {AF_INET6, AF_INET6},
|
||||||
@ -309,6 +398,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v6_v4mapped_any_v6_any)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_v4mapped_any_v6_any_only)
|
||||||
|
{
|
||||||
|
.family = {AF_INET6, AF_INET6},
|
||||||
|
.addr = {&in6addr_v4mapped_any, &in6addr_any},
|
||||||
|
.ipv6_only = {false, true},
|
||||||
|
.expected_errno = {0, 0,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v6_v4mapped_any_v6_local)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_v4mapped_any_v6_local)
|
||||||
{
|
{
|
||||||
.family = {AF_INET6, AF_INET6},
|
.family = {AF_INET6, AF_INET6},
|
||||||
@ -339,6 +439,17 @@ FIXTURE_VARIANT_ADD(bind_wildcard, v6_v4mapped_loopback_v6_any)
|
|||||||
EADDRINUSE, EADDRINUSE},
|
EADDRINUSE, EADDRINUSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_v4mapped_loopback_v6_any_only)
|
||||||
|
{
|
||||||
|
.family = {AF_INET6, AF_INET6},
|
||||||
|
.addr = {&in6addr_v4mapped_loopback, &in6addr_any},
|
||||||
|
.ipv6_only = {false, true},
|
||||||
|
.expected_errno = {0, 0,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE,
|
||||||
|
EADDRINUSE, EADDRINUSE},
|
||||||
|
};
|
||||||
|
|
||||||
FIXTURE_VARIANT_ADD(bind_wildcard, v6_v4mapped_loopback_v6_local)
|
FIXTURE_VARIANT_ADD(bind_wildcard, v6_v4mapped_loopback_v6_local)
|
||||||
{
|
{
|
||||||
.family = {AF_INET6, AF_INET6},
|
.family = {AF_INET6, AF_INET6},
|
||||||
@ -415,6 +526,11 @@ void bind_socket(struct __test_metadata *_metadata,
|
|||||||
self->fd[i] = socket(self->addr[i].addr.sa_family, SOCK_STREAM, 0);
|
self->fd[i] = socket(self->addr[i].addr.sa_family, SOCK_STREAM, 0);
|
||||||
ASSERT_GT(self->fd[i], 0);
|
ASSERT_GT(self->fd[i], 0);
|
||||||
|
|
||||||
|
if (i < 2 && variant->ipv6_only[i]) {
|
||||||
|
ret = setsockopt(self->fd[i], SOL_IPV6, IPV6_V6ONLY, &(int){1}, sizeof(int));
|
||||||
|
ASSERT_EQ(ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
self->addr[i].addr4.sin_port = self->addr[0].addr4.sin_port;
|
self->addr[i].addr4.sin_port = self->addr[0].addr4.sin_port;
|
||||||
|
|
||||||
ret = bind(self->fd[i], &self->addr[i].addr, self->addrlen[i]);
|
ret = bind(self->fd[i], &self->addr[i].addr, self->addrlen[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user