Non-platform-specific detection of TCP_CONGESTION socket option.
Rather than checking for anything Linux-specific at configure-time, see if TCP_CONGESTION is defined in <netinet/tcp.h> and if so define a CPP variable HAVE_TCP_CONGESTION, which we then use to enable conditional compilation of the code for this feature.
This commit is contained in:
parent
e90f34f61a
commit
c550ef4605
13
configure.ac
13
configure.ac
@ -50,4 +50,17 @@ AC_C_CONST
|
|||||||
AC_CHECK_HEADERS([netinet/sctp.h],
|
AC_CHECK_HEADERS([netinet/sctp.h],
|
||||||
AC_DEFINE([HAVE_SCTP], [1], [Have SCTP support.]))
|
AC_DEFINE([HAVE_SCTP], [1], [Have SCTP support.]))
|
||||||
|
|
||||||
|
# Check for TCP_CONGESTION sockopt (believed to be Linux only)
|
||||||
|
AC_CACHE_CHECK([TCP_CONGESTION socket option],
|
||||||
|
[iperf3_cv_header_tcp_congestion],
|
||||||
|
AC_EGREP_CPP(yes,
|
||||||
|
[#include <netinet/tcp.h>
|
||||||
|
#ifdef TCP_CONGESTION
|
||||||
|
yes
|
||||||
|
#endif
|
||||||
|
],iperf3_cv_header_tcp_congestion=yes,iperf3_cv_header_tcp_congestion=no))
|
||||||
|
if test "x$iperf3_cv_header_tcp_congestion" = "xyes"; then
|
||||||
|
AC_DEFINE([HAVE_TCP_CONGESTION], [1], [Have TCP_CONGESTION sockopt.])
|
||||||
|
fi
|
||||||
|
|
||||||
AC_OUTPUT([Makefile src/Makefile examples/Makefile])
|
AC_OUTPUT([Makefile src/Makefile examples/Makefile])
|
||||||
|
@ -570,9 +570,9 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
|||||||
{"affinity", required_argument, NULL, 'A'},
|
{"affinity", required_argument, NULL, 'A'},
|
||||||
#endif
|
#endif
|
||||||
{"title", required_argument, NULL, 'T'},
|
{"title", required_argument, NULL, 'T'},
|
||||||
#if defined(linux) && defined(TCP_CONGESTION)
|
#if defined(HAVE_TCP_CONGESTION)
|
||||||
{"linux-congestion", required_argument, NULL, 'C'},
|
{"linux-congestion", required_argument, NULL, 'C'},
|
||||||
#endif
|
#endif /* HAVE_TCP_CONGESTION */
|
||||||
#if defined(HAVE_SCTP)
|
#if defined(HAVE_SCTP)
|
||||||
{"sctp", no_argument, NULL, OPT_SCTP},
|
{"sctp", no_argument, NULL, OPT_SCTP},
|
||||||
#endif
|
#endif
|
||||||
@ -792,13 +792,13 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
|||||||
client_flag = 1;
|
client_flag = 1;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
#if defined(linux) && defined(TCP_CONGESTION)
|
#if defined(HAVE_TCP_CONGESTION)
|
||||||
test->congestion = strdup(optarg);
|
test->congestion = strdup(optarg);
|
||||||
client_flag = 1;
|
client_flag = 1;
|
||||||
#else /* linux */
|
#else /* HAVE_TCP_CONGESTION */
|
||||||
i_errno = IEUNIMP;
|
i_errno = IEUNIMP;
|
||||||
return -1;
|
return -1;
|
||||||
#endif /* linux */
|
#endif /* HAVE_TCP_CONGESTION */
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
test->debug = 1;
|
test->debug = 1;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "iperf.h"
|
#include "iperf.h"
|
||||||
#include "iperf_api.h"
|
#include "iperf_api.h"
|
||||||
#include "iperf_tcp.h"
|
#include "iperf_tcp.h"
|
||||||
@ -196,7 +197,7 @@ iperf_tcp_listen(struct iperf_test *test)
|
|||||||
}
|
}
|
||||||
printf("SO_SNDBUF is %u\n", opt);
|
printf("SO_SNDBUF is %u\n", opt);
|
||||||
}
|
}
|
||||||
#if defined(linux) && defined(TCP_CONGESTION)
|
#if defined(HAVE_TCP_CONGESTION)
|
||||||
if (test->congestion) {
|
if (test->congestion) {
|
||||||
if (setsockopt(s, IPPROTO_TCP, TCP_CONGESTION, test->congestion, strlen(test->congestion)) < 0) {
|
if (setsockopt(s, IPPROTO_TCP, TCP_CONGESTION, test->congestion, strlen(test->congestion)) < 0) {
|
||||||
close(s);
|
close(s);
|
||||||
@ -205,7 +206,7 @@ iperf_tcp_listen(struct iperf_test *test)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* HAVE_TCP_CONGESTION */
|
||||||
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) {
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
|
@ -106,9 +106,9 @@ const char usage_longstr[] = "Usage: iperf [-s|-c host] [options]\n"
|
|||||||
" -R, --reverse run in reverse mode (server sends, client receives)\n"
|
" -R, --reverse run in reverse mode (server sends, client receives)\n"
|
||||||
" -w, --window #[KMG] TCP window size (socket buffer size)\n"
|
" -w, --window #[KMG] TCP window size (socket buffer size)\n"
|
||||||
" -B, --bind <host> bind to a specific interface\n"
|
" -B, --bind <host> bind to a specific interface\n"
|
||||||
#if defined(linux)
|
#if defined(HAVE_TCP_CONGESTION)
|
||||||
" -C, --linux-congestion <algo> set TCP congestion control algorithm (Linux only)\n"
|
" -C, --linux-congestion <algo> set TCP congestion control algorithm (Linux only)\n"
|
||||||
#endif
|
#endif /* HAVE_TCP_CONGESTION */
|
||||||
" -M, --set-mss # set TCP maximum segment size (MTU - 40 bytes)\n"
|
" -M, --set-mss # set TCP maximum segment size (MTU - 40 bytes)\n"
|
||||||
" -N, --nodelay set TCP no delay, disabling Nagle's Algorithm\n"
|
" -N, --nodelay set TCP no delay, disabling Nagle's Algorithm\n"
|
||||||
" -4, --version4 only use IPv4\n"
|
" -4, --version4 only use IPv4\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user