Fix build on Linux distros that don't support TCP_CONGESTION.

Apparently older kernels don't support TCP_CONGESTION, so we can't
just test for defined(linux) to know if we can use this sockopt or not.
This change unbreaks the build on (notably) CentOS 5.
This commit is contained in:
Bruce A. Mah 2014-01-16 10:43:08 -08:00
parent 7234074fe8
commit 0ff7575499
2 changed files with 5 additions and 5 deletions

View File

@ -540,7 +540,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
{"affinity", required_argument, NULL, 'A'},
#endif
{"title", required_argument, NULL, 'T'},
#if defined(linux)
#if defined(linux) && defined(TCP_CONGESTION)
{"linux-congestion", required_argument, NULL, 'C'},
#endif
{"debug", no_argument, NULL, 'd'},
@ -747,7 +747,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
client_flag = 1;
break;
case 'C':
#if defined(linux)
#if defined(linux) && defined(TCP_CONGESTION)
test->congestion = strdup(optarg);
client_flag = 1;
#else /* linux */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2011, The Regents of the University of California,
* Copyright (c) 2009-2014, The Regents of the University of California,
* through Lawrence Berkeley National Laboratory (subject to receipt of any
* required approvals from the U.S. Dept. of Energy). All rights reserved.
*
@ -184,7 +184,7 @@ iperf_tcp_listen(struct iperf_test *test)
return -1;
}
}
#if defined(linux)
#if defined(linux) && defined(TCP_CONGESTION)
if (test->congestion) {
if (setsockopt(s, IPPROTO_TCP, TCP_CONGESTION, test->congestion, strlen(test->congestion)) < 0) {
close(s);
@ -373,7 +373,7 @@ iperf_tcp_connect(struct iperf_test *test)
}
#endif
#if defined(linux)
#if defined(linux) && defined(TCP_CONGESTION)
if (test->congestion) {
if (setsockopt(s, IPPROTO_TCP, TCP_CONGESTION, test->congestion, strlen(test->congestion)) < 0) {
close(s);