1
1

Fix -B with some SCTP tests, which is part of #678 (#715)

Got the following error when running server side with -B option:

Server side:
    ./iperf3 -s -B <server_ipv4_address>
    -----------------------------------------------------------
    Server listening on 5201
    -----------------------------------------------------------
    iperf3: error - unable to start stream listener: Bad file descriptor
    -----------------------------------------------------------

Client side:
    ./iperf3 -c <server_ipv4_address> --sctp
    iperf3: error - unable to start stream listener: No such file or directory

Similar fix as below for TCP:
    commit eb1cfe5e162d08efdf18fa12cd6627cfdcd675a7
    Author: Bruce A. Mah <bmah@es.net>
    Date:   Fri Aug 1 16:24:14 2014 -0700

        Another iteration on issue #193, fixes -B with some TCP tests.

Signed-off-by: Jianwen Ji <jijianwen@gmail.com>
Этот коммит содержится в:
Ji Jianwen 2018-03-24 07:10:38 +08:00 коммит произвёл Bruce A. Mah
родитель c0a441756a
Коммит 3e58489a58

Просмотреть файл

@ -165,7 +165,16 @@ iperf_sctp_listen(struct iperf_test *test)
snprintf(portstr, 6, "%d", test->server_port); snprintf(portstr, 6, "%d", test->server_port);
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_family = (test->settings->domain == AF_UNSPEC ? AF_INET6 : test->settings->domain); /*
* If binding to the wildcard address with no explicit address
* family specified, then force us to get an AF_INET6 socket.
* More details in the comments in netanounce().
*/
if (test->settings->domain == AF_UNSPEC && !test->bind_address) {
hints.ai_family = AF_INET6;
} else {
hints.ai_family = test->settings->domain;
}
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE; hints.ai_flags = AI_PASSIVE;
if (getaddrinfo(test->bind_address, portstr, &hints, &res) != 0) { if (getaddrinfo(test->bind_address, portstr, &hints, &res) != 0) {
@ -180,10 +189,11 @@ iperf_sctp_listen(struct iperf_test *test)
} }
#if defined(IPV6_V6ONLY) && !defined(__OpenBSD__) #if defined(IPV6_V6ONLY) && !defined(__OpenBSD__)
if (test->settings->domain == AF_UNSPEC || test->settings->domain == AF_INET6) { if (res->ai_family == AF_INET6 && (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;
else if (test->settings->domain == AF_INET6) else
opt = 1; opt = 1;
if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
(char *) &opt, sizeof(opt)) < 0) { (char *) &opt, sizeof(opt)) < 0) {