diff --git a/src/iperf_api.c b/src/iperf_api.c index eb234030c..098976c87 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1,5 +1,5 @@ /* - * iperf, Copyright (c) 2014-2022, The Regents of the University of + * iperf, Copyright (c) 2014-2023, 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. @@ -1135,7 +1135,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) int flag; int portno; int blksize; - int server_flag, client_flag, rate_flag, duration_flag, rcv_timeout_flag, snd_timeout_flag; + int server_flag, client_flag, rate_flag, fq_rate_flag, duration_flag, rcv_timeout_flag, snd_timeout_flag; char *endptr; #if defined(HAVE_CPU_AFFINITY) char* comma; @@ -1147,7 +1147,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) int rcv_timeout_in = 0; blksize = 0; - server_flag = client_flag = rate_flag = duration_flag = rcv_timeout_flag = snd_timeout_flag =0; + server_flag = client_flag = rate_flag = fq_rate_flag = duration_flag = rcv_timeout_flag = snd_timeout_flag = 0; #if defined(HAVE_SSL) char *client_username = NULL, *client_rsa_public_key = NULL, *server_rsa_private_key = NULL; FILE *ptr_file; @@ -1578,6 +1578,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) case OPT_FQ_RATE: #if defined(HAVE_SO_MAX_PACING_RATE) test->settings->fqrate = unit_atof_rate(optarg); + fq_rate_flag = 1; client_flag = 1; #else /* HAVE_SO_MAX_PACING_RATE */ i_errno = IEUNIMP; @@ -1720,6 +1721,12 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) return -1; } + /* We can't do both --bandwidth and --fq-rate at the same time */ + if (rate_flag && fq_rate_flag) { + i_errno = IERATEFQRATE; + return -1; + } + if (blksize == 0) { if (test->protocol->id == Pudp) blksize = 0; /* try to dynamically determine from MSS */ diff --git a/src/iperf_api.h b/src/iperf_api.h index 9e70d44f3..5c47c112a 100644 --- a/src/iperf_api.h +++ b/src/iperf_api.h @@ -418,6 +418,7 @@ enum { IESNDTIMEOUT = 33, // Illegal message send timeout IEUDPFILETRANSFER = 34, // Cannot transfer file using UDP IESERVERAUTHUSERS = 35, // Cannot access authorized users file + IERATEFQRATE = 36, // Cannot specify both -b and --fq-rate /* Test errors */ IENEWTEST = 100, // Unable to create a new test (check perror) IEINITTEST = 101, // Test initialization failed (check perror) diff --git a/src/iperf_error.c b/src/iperf_error.c index 6426554cf..72e1440e7 100644 --- a/src/iperf_error.c +++ b/src/iperf_error.c @@ -1,5 +1,5 @@ /* - * iperf, Copyright (c) 2014-2022, The Regents of the University of + * iperf, Copyright (c) 2014-2023, 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. @@ -198,6 +198,9 @@ iperf_strerror(int int_errno) case IESERVERAUTHUSERS: snprintf(errstr, len, "cannot access authorized users file"); break; + case IERATEFQRATE: + snprintf(errstr, len, "-b and --fq-rate cannot be specified together"); + break; case IEBADFORMAT: snprintf(errstr, len, "bad format specifier (valid formats are in the set [kmgtKMGT])"); break;