Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
break;
case 'P':
test->num_streams = atoi(optarg);
if (test->num_streams < 0 || test->num_streams > MAX_STREAMS) {
if (test->num_streams < 1 || test->num_streams > MAX_STREAMS) {
i_errno = IENUMSTREAMS;
return -1;
}
Expand Down Expand Up @@ -2627,7 +2627,7 @@ get_parameters(struct iperf_test *test)
if ((j_p = iperf_cJSON_GetObjectItemType(j, "nodelay", cJSON_True)) != NULL)
test->no_delay = 1;
if ((j_p = iperf_cJSON_GetObjectItemType(j, "parallel", cJSON_Number)) != NULL){
if (j_p->valueint < 0 || j_p->valueint > MAX_STREAMS) {
if (j_p->valueint < 1 || j_p->valueint > MAX_STREAMS) {
i_errno = IENUMSTREAMS;
r = -1;
} else {
Expand Down Expand Up @@ -2655,7 +2655,7 @@ get_parameters(struct iperf_test *test)
if (j_p->valueint < 0){
i_errno = IEBLOCKSIZE;
r = -1;
}else {
} else {
test->settings->blksize = j_p->valueint;
}
}
Expand Down Expand Up @@ -2702,55 +2702,55 @@ get_parameters(struct iperf_test *test)
if (j_p->valueint < 0 || j_p->valueint > 1){
i_errno = IERECVPARAMS;
r = -1;
}else {
} else {
test->settings->gro = j_p->valueint;
}
}
if ((j_p = iperf_cJSON_GetObjectItemType(j, "gro_bf_size", cJSON_Number)) != NULL){
if (j_p->valueint < 0){
i_errno = IERECVPARAMS;
r = -1;
}else {
} else {
test->settings->gro_bf_size = j_p->valueint;
}
}
if ((j_p = iperf_cJSON_GetObjectItemType(j, "bandwidth", cJSON_Number)) != NULL){
if (j_p->valueint < 0){
i_errno = IERECVPARAMS;
r = -1;
}else {
} else {
test->settings->rate = j_p->valueint;
}
}
if ((j_p = iperf_cJSON_GetObjectItemType(j, "fqrate", cJSON_Number)) != NULL){
if (j_p->valueint < 0){
i_errno = IERECVPARAMS;
r = -1;
}else {
} else {
test->settings->fqrate = j_p->valueint;
}
}
if ((j_p = iperf_cJSON_GetObjectItemType(j, "pacing_timer", cJSON_Number)) != NULL){
if (j_p->valueint < 0){
i_errno = IERECVPARAMS;
r = -1;
}else {
} else {
test->settings->pacing_timer = j_p->valueint;
}
}
if ((j_p = iperf_cJSON_GetObjectItemType(j, "burst", cJSON_Number)) != NULL){
if (j_p->valueint <= 0 || j_p->valueint > MAX_BURST){
i_errno = IEBURST;
r = -1;
}else {
} else {
test->settings->burst = j_p->valueint;
}
}
if ((j_p = iperf_cJSON_GetObjectItemType(j, "TOS", cJSON_Number)) != NULL){
if (j_p->valueint < 0 || j_p->valueint > 255){
i_errno = IEBADTOS;
r = -1;
}else {
} else {
test->settings->tos = j_p->valueint;
}
}
Expand All @@ -2759,7 +2759,7 @@ get_parameters(struct iperf_test *test)
if (j_p->valueint < 1 || j_p->valueint > 0xfffff ){
i_errno = IESETFLOW;
r = -1;
}else {
} else {
test->settings->flowlabel = j_p->valueint;
}
}
Expand Down Expand Up @@ -2823,25 +2823,25 @@ get_parameters(struct iperf_test *test)
}


/* Ensure that the client does not request to run longer than the server's configured max */
if ((test->max_server_duration > 0) && (((test->duration + test->omit) > test->max_server_duration) || (test->duration == 0))) {
i_errno = IEMAXSERVERTESTDURATIONEXCEEDED;
r = -1;
}
/* Ensure that the client does not request to run longer than the server's configured max */
if ((test->max_server_duration > 0) && (((test->duration + test->omit) > test->max_server_duration) || (test->duration == 0))) {
i_errno = IEMAXSERVERTESTDURATIONEXCEEDED;
r = -1;
}


/* Ensure that total requested data rate is not above the server's limit */
iperf_size_t total_requested_rate = test->num_streams * test->settings->rate * (test->mode == BIDIRECTIONAL? 2 : 1);
if (test->settings->bitrate_limit && total_requested_rate > test->settings->bitrate_limit) {
i_errno = IETOTALRATE;
r = -1;
}
/* Ensure that total requested data rate is not above the server's limit */
iperf_size_t total_requested_rate = test->num_streams * test->settings->rate * (test->mode == BIDIRECTIONAL? 2 : 1);
if (test->settings->bitrate_limit && total_requested_rate > test->settings->bitrate_limit) {
i_errno = IETOTALRATE;
r = -1;
}

total_requested_rate = test->num_streams * test->settings->fqrate * (test->mode == BIDIRECTIONAL? 2 : 1);
if (test->settings->bitrate_limit && total_requested_rate > test->settings->bitrate_limit) {
i_errno = IETOTALRATE;
r = -1;
}
total_requested_rate = test->num_streams * test->settings->fqrate * (test->mode == BIDIRECTIONAL? 2 : 1);
if (test->settings->bitrate_limit && total_requested_rate > test->settings->bitrate_limit) {
i_errno = IETOTALRATE;
r = -1;
}
}

return r;
Expand Down
2 changes: 1 addition & 1 deletion src/iperf_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ iperf_strerror(int int_errno)
snprintf(errstr, len, "test duration valid values are 0 to %d seconds", MAX_TIME);
break;
case IENUMSTREAMS:
snprintf(errstr, len, "number of parallel streams too large (maximum = %d)", MAX_STREAMS);
snprintf(errstr, len, "invalid number of parallel streams (min = 1, max = %d)", MAX_STREAMS);
break;
case IEBLOCKSIZE:
snprintf(errstr, len, "block size too large (maximum = %d bytes)", MAX_BLOCKSIZE);
Expand Down
Loading