Skip to content

Commit

Permalink
selftests: net: reuseport_dualstack: fix uninitalized parameter
Browse files Browse the repository at this point in the history
This test reports EINVAL for getsockopt(SOL_SOCKET, SO_DOMAIN)
occasionally due to the uninitialized length parameter.
Initialize it to fix this, and also use int for "test_family" to comply
with the API standard.

Fixes: d6a61f8 ("soreuseport: test mixed v4/v6 sockets")
Reported-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Wei Wang <weiwan@google.com>
Cc: Craig Gallek <cgallek@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
tracywwnj authored and davem330 committed Nov 1, 2019
1 parent 62bdc8f commit d64479a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/testing/selftests/net/reuseport_dualstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void test(int *rcv_fds, int count, int proto)
{
struct epoll_event ev;
int epfd, i, test_fd;
uint16_t test_family;
int test_family;
socklen_t len;

epfd = epoll_create(1);
Expand All @@ -146,6 +146,7 @@ static void test(int *rcv_fds, int count, int proto)
send_from_v4(proto);

test_fd = receive_once(epfd, proto);
len = sizeof(test_family);
if (getsockopt(test_fd, SOL_SOCKET, SO_DOMAIN, &test_family, &len))
error(1, errno, "failed to read socket domain");
if (test_family != AF_INET)
Expand Down

0 comments on commit d64479a

Please sign in to comment.