From 4155c45471b52cd6f5d608f9d1424370da9dc5aa Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Thu, 10 Apr 2014 11:20:36 -0700 Subject: [PATCH] Improve detection of IPv6 flowlabel support (Linux only). We check at configure-time to see if IPV6_FLOWLABEL_MGR is defined in , if it is we set a HAVE_FLOWLABEL CPP symbol to turn on conditional compilation of the support for this feature. --- configure.ac | 17 +++++++++++++++++ src/iperf_api.c | 8 +++++--- src/iperf_tcp.c | 8 ++++---- src/locale.c | 4 ++-- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 8c26b7e..a67aa78 100644 --- a/configure.ac +++ b/configure.ac @@ -63,4 +63,21 @@ if test "x$iperf3_cv_header_tcp_congestion" = "xyes"; then AC_DEFINE([HAVE_TCP_CONGESTION], [1], [Have TCP_CONGESTION sockopt.]) fi +# Check for IPv6 flowlabel support (believed to be Linux only) +# We check for IPV6_FLOWLABEL_MGR in even though we +# don't use that file directly (we have our own stripped-down +# copy, see src/flowlabel.h for more details). +AC_CACHE_CHECK([IPv6 flowlabel support], +[iperf3_cv_header_flowlabel], +AC_EGREP_CPP(yes, +[#include +#include +#ifdef IPV6_FLOWLABEL_MGR + yes +#endif +],iperf3_cv_header_flowlabel=yes,iperf3_cv_header_flowlabel=no)) +if test "x$iperf3_cv_header_flowlabel" = "xyes"; then + AC_DEFINE([HAVE_FLOWLABEL], [1], [Have IPv6 flowlabel support.]) +fi + AC_OUTPUT([Makefile src/Makefile examples/Makefile]) diff --git a/src/iperf_api.c b/src/iperf_api.c index 20a7abb..e06620c 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -562,7 +562,9 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) {"version4", no_argument, NULL, '4'}, {"version6", no_argument, NULL, '6'}, {"tos", required_argument, NULL, 'S'}, +#if defined(HAVE_FLOWLABEL) {"flowlabel", required_argument, NULL, 'L'}, +#endif /* HAVE_FLOWLABEL */ {"zerocopy", no_argument, NULL, 'Z'}, {"omit", required_argument, NULL, 'O'}, {"file", required_argument, NULL, 'F'}, @@ -735,17 +737,17 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) client_flag = 1; break; case 'L': -#if defined(linux) +#if defined(HAVE_FLOWLABEL) test->settings->flowlabel = strtol(optarg, NULL, 0); if (test->settings->flowlabel < 1 || test->settings->flowlabel > 0xfffff) { i_errno = IESETFLOW; return -1; } client_flag = 1; -#else /* linux */ +#else /* HAVE_FLOWLABEL */ i_errno = IEUNIMP; return -1; -#endif /* linux */ +#endif /* HAVE_FLOWLABEL */ break; case 'Z': if (!has_sendfile()) { diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c index 037bc16..7071aee 100644 --- a/src/iperf_tcp.c +++ b/src/iperf_tcp.c @@ -26,9 +26,9 @@ #include "iperf_tcp.h" #include "net.h" -#if defined(linux) +#if defined(HAVE_FLOWLABEL) #include "flowlabel.h" -#endif +#endif /* HAVE_FLOWLABEL */ /* iperf_tcp_recv * @@ -361,7 +361,7 @@ iperf_tcp_connect(struct iperf_test *test) } printf("SO_SNDBUF is %u\n", opt); } -#if defined(linux) +#if defined(HAVE_FLOWLABEL) if (test->settings->flowlabel) { if (server_res->ai_addr->sa_family != AF_INET6) { saved_errno = errno; @@ -404,7 +404,7 @@ iperf_tcp_connect(struct iperf_test *test) } } } -#endif +#endif /* HAVE_FLOWLABEL */ #if defined(linux) && defined(TCP_CONGESTION) if (test->congestion) { diff --git a/src/locale.c b/src/locale.c index d1ff026..6aae6b5 100644 --- a/src/locale.c +++ b/src/locale.c @@ -114,9 +114,9 @@ const char usage_longstr[] = "Usage: iperf [-s|-c host] [options]\n" " -4, --version4 only use IPv4\n" " -6, --version6 only use IPv6\n" " -S, --tos N set the IP 'type of service'\n" -#if defined(linux) +#if defined(HAVE_FLOWLABEL) " -L, --flowlabel N set the IPv6 flow label (only supported on Linux)\n" -#endif +#endif /* HAVE_FLOWLABEL */ " -Z, --zerocopy use a 'zero copy' method of sending data\n" " -O, --omit N omit the first n seconds\n" " -T, --title str prefix every output line with this string\n"