Skip to content

Commit

Permalink
Disallow specifying both -b and --fq-rate together.
Browse files Browse the repository at this point in the history
Closes #1597.
  • Loading branch information
bmah888 committed Nov 15, 2023
1 parent 97c2e40 commit a6fa75e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/iperf_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion src/iperf_error.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a6fa75e

Please sign in to comment.