Only do the IPV6_V6ONLY setsockopt(3) stuff if that option is available.
Should fix #177, in which compilation failed on older Solaris systems that didn't have it. This is a different approach than a patch suggested in that issue. Weakly regression-tested on other platforms (test this by specifying -6, -4, or neither to the server when binding to the wildcard address, and seeing if a client can connect with various of -6, -4, or neither).
Этот коммит содержится в:
родитель
76b5942f6f
Коммит
147d3369a0
@ -155,6 +155,7 @@ iperf_sctp_listen(struct iperf_test *test)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IPV6_V6ONLY
|
||||||
if (test->settings->domain == AF_UNSPEC || test->settings->domain == AF_INET6) {
|
if (test->settings->domain == AF_UNSPEC || test->settings->domain == AF_INET6) {
|
||||||
if (test->settings->domain == AF_UNSPEC)
|
if (test->settings->domain == AF_UNSPEC)
|
||||||
opt = 0;
|
opt = 0;
|
||||||
@ -168,6 +169,7 @@ iperf_sctp_listen(struct iperf_test *test)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* IPV6_V6ONLY */
|
||||||
|
|
||||||
opt = 1;
|
opt = 1;
|
||||||
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
|
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
|
||||||
|
@ -216,6 +216,7 @@ iperf_tcp_listen(struct iperf_test *test)
|
|||||||
i_errno = IEREUSEADDR;
|
i_errno = IEREUSEADDR;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#ifdef IPV6_V6ONLY
|
||||||
if (test->settings->domain == AF_UNSPEC || test->settings->domain == AF_INET6) {
|
if (test->settings->domain == AF_UNSPEC || test->settings->domain == AF_INET6) {
|
||||||
if (test->settings->domain == AF_UNSPEC)
|
if (test->settings->domain == AF_UNSPEC)
|
||||||
opt = 0;
|
opt = 0;
|
||||||
@ -231,6 +232,7 @@ iperf_tcp_listen(struct iperf_test *test)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* IPV6_V6ONLY */
|
||||||
|
|
||||||
if (bind(s, (struct sockaddr *) res->ai_addr, res->ai_addrlen) < 0) {
|
if (bind(s, (struct sockaddr *) res->ai_addr, res->ai_addrlen) < 0) {
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
|
@ -143,12 +143,12 @@ netannounce(int domain, int proto, char *local, int port)
|
|||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we got an IPv6 socket, figure out if it should accept IPv4
|
* If we got an IPv6 socket, figure out if it should accept IPv4
|
||||||
* connections as well. We do that if and only if no address
|
* connections as well. We do that if and only if no address
|
||||||
* family was specified explicitly.
|
* family was specified explicitly.
|
||||||
*/
|
*/
|
||||||
|
#ifdef IPV6_V6ONLY
|
||||||
if (res->ai_family == AF_INET6 && (domain == AF_UNSPEC || domain == AF_INET6)) {
|
if (res->ai_family == AF_INET6 && (domain == AF_UNSPEC || domain == AF_INET6)) {
|
||||||
if (domain == AF_UNSPEC)
|
if (domain == AF_UNSPEC)
|
||||||
opt = 0;
|
opt = 0;
|
||||||
@ -161,6 +161,7 @@ netannounce(int domain, int proto, char *local, int port)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* IPV6_V6ONLY */
|
||||||
|
|
||||||
if (bind(s, (struct sockaddr *) res->ai_addr, res->ai_addrlen) < 0) {
|
if (bind(s, (struct sockaddr *) res->ai_addr, res->ai_addrlen) < 0) {
|
||||||
close(s);
|
close(s);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user