Skip to content

Commit

Permalink
Fix -B with some SCTP tests, which is part of esnet#678 (esnet#715)
Browse files Browse the repository at this point in the history
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 eb1cfe5
    Author: Bruce A. Mah <[email protected]>
    Date:   Fri Aug 1 16:24:14 2014 -0700

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

Signed-off-by: Jianwen Ji <[email protected]>
  • Loading branch information
jijianwen authored and bmah888 committed Mar 23, 2018
1 parent c0a4417 commit 3e58489
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/iperf_sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,16 @@ iperf_sctp_listen(struct iperf_test *test)

snprintf(portstr, 6, "%d", test->server_port);
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_flags = AI_PASSIVE;
if (getaddrinfo(test->bind_address, portstr, &hints, &res) != 0) {
Expand All @@ -180,10 +189,11 @@ iperf_sctp_listen(struct iperf_test *test)
}

#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)
opt = 0;
else if (test->settings->domain == AF_INET6)
else
opt = 1;
if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
(char *) &opt, sizeof(opt)) < 0) {
Expand Down

0 comments on commit 3e58489

Please sign in to comment.