diff options
author | Wei Wang <weiwan@google.com> | 2019-10-31 19:24:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-11-01 18:11:02 -0400 |
commit | d64479a3e3f9924074ca7b50bd72fa5211dca9c1 (patch) | |
tree | bca6f9227ccfc04d904e23cda3f8f6b4eac53dcc | |
parent | 62bdc8fd1c21d4263ebd18bec57f82532d09249f (diff) |
selftests: net: reuseport_dualstack: fix uninitalized parameter
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: d6a61f80b871 ("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>
-rw-r--r-- | tools/testing/selftests/net/reuseport_dualstack.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/net/reuseport_dualstack.c b/tools/testing/selftests/net/reuseport_dualstack.c index fe3230c55986..fb7a59ed759e 100644 --- a/tools/testing/selftests/net/reuseport_dualstack.c +++ b/tools/testing/selftests/net/reuseport_dualstack.c | |||
@@ -129,7 +129,7 @@ static void test(int *rcv_fds, int count, int proto) | |||
129 | { | 129 | { |
130 | struct epoll_event ev; | 130 | struct epoll_event ev; |
131 | int epfd, i, test_fd; | 131 | int epfd, i, test_fd; |
132 | uint16_t test_family; | 132 | int test_family; |
133 | socklen_t len; | 133 | socklen_t len; |
134 | 134 | ||
135 | epfd = epoll_create(1); | 135 | epfd = epoll_create(1); |
@@ -146,6 +146,7 @@ static void test(int *rcv_fds, int count, int proto) | |||
146 | send_from_v4(proto); | 146 | send_from_v4(proto); |
147 | 147 | ||
148 | test_fd = receive_once(epfd, proto); | 148 | test_fd = receive_once(epfd, proto); |
149 | len = sizeof(test_family); | ||
149 | if (getsockopt(test_fd, SOL_SOCKET, SO_DOMAIN, &test_family, &len)) | 150 | if (getsockopt(test_fd, SOL_SOCKET, SO_DOMAIN, &test_family, &len)) |
150 | error(1, errno, "failed to read socket domain"); | 151 | error(1, errno, "failed to read socket domain"); |
151 | if (test_family != AF_INET) | 152 | if (test_family != AF_INET) |