From 0ff7575499d57c2bccd5218e2546b6b0e0426322 Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Thu, 16 Jan 2014 10:43:08 -0800 Subject: [PATCH] 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. --- src/iperf_api.c | 4 ++-- src/iperf_tcp.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index 202cf2f..aa9c0ed 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -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 */ diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c index 9645fcd..4c8fcb8 100644 --- a/src/iperf_tcp.c +++ b/src/iperf_tcp.c @@ -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);