提交 12fab163 编写于 作者: W Wei Wang 提交者: Greg Kroah-Hartman

selftests: net: reuseport_dualstack: fix uninitalized parameter

[ Upstream commit d64479a3e3f9924074ca7b50bd72fa5211dca9c1 ]

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: d6a61f80 ("soreuseport: test mixed v4/v6 sockets")
Reported-by: NMaciej Żenczykowski <maze@google.com>
Signed-off-by: NEric Dumazet <edumazet@google.com>
Signed-off-by: NWei Wang <weiwan@google.com>
Cc: Craig Gallek <cgallek@google.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 321c9915
...@@ -129,7 +129,7 @@ static void test(int *rcv_fds, int count, int proto) ...@@ -129,7 +129,7 @@ static void test(int *rcv_fds, int count, int proto)
{ {
struct epoll_event ev; struct epoll_event ev;
int epfd, i, test_fd; int epfd, i, test_fd;
uint16_t test_family; int test_family;
socklen_t len; socklen_t len;
epfd = epoll_create(1); epfd = epoll_create(1);
...@@ -146,6 +146,7 @@ static void test(int *rcv_fds, int count, int proto) ...@@ -146,6 +146,7 @@ static void test(int *rcv_fds, int count, int proto)
send_from_v4(proto); send_from_v4(proto);
test_fd = receive_once(epfd, proto); test_fd = receive_once(epfd, proto);
len = sizeof(test_family);
if (getsockopt(test_fd, SOL_SOCKET, SO_DOMAIN, &test_family, &len)) if (getsockopt(test_fd, SOL_SOCKET, SO_DOMAIN, &test_family, &len))
error(1, errno, "failed to read socket domain"); error(1, errno, "failed to read socket domain");
if (test_family != AF_INET) if (test_family != AF_INET)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册