1
1

Prevent specifying a UDP send size that's too small.

We need at least 16 bytes to hold counters and timestamps.
Avoids a problem noted in issue #390.
Этот коммит содержится в:
Bruce A. Mah 2017-04-11 09:43:41 -07:00
родитель f66b42d536
Коммит 03224c9f56
4 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -321,6 +321,8 @@ struct iperf_test
#define MB (1024 * 1024)
#define MAX_TCP_BUFFER (512 * MB)
#define MAX_BLOCKSIZE MB
/* Minimum size UDP send is the size of two 32-bit ints followed by a 64-bit int */
#define MIN_UDP_BLOCKSIZE (4 + 4 + 8)
/* Maximum size UDP send is (64K - 1) - IP and UDP header sizes */
#define MAX_UDP_BLOCKSIZE (65535 - 8 - 20)
#define MIN_INTERVAL 0.1

Просмотреть файл

@ -1016,7 +1016,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
return -1;
}
if (test->protocol->id == Pudp &&
blksize > MAX_UDP_BLOCKSIZE) {
(blksize < MIN_UDP_BLOCKSIZE || blksize > MAX_UDP_BLOCKSIZE)) {
i_errno = IEUDPBLOCKSIZE;
return -1;
}

Просмотреть файл

@ -292,7 +292,7 @@ enum {
IELOGFILE = 17, // Can't open log file
IENOSCTP = 18, // No SCTP support available
IEBIND = 19, // Local port specified with no local bind option
IEUDPBLOCKSIZE = 20, // Block size too large. Maximum value = %dMAX_UDP_BLOCKSIZE
IEUDPBLOCKSIZE = 20, // Block size invalid
IEBADTOS = 21, // Bad TOS value
/* Test errors */
IENEWTEST = 100, // Unable to create a new test (check perror)

Просмотреть файл

@ -1,5 +1,5 @@
/*
* iperf, Copyright (c) 2014, 2015, 2016, The Regents of the University of
* iperf, Copyright (c) 2014, 2015, 2016, 2017, 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.
@ -126,7 +126,7 @@ iperf_strerror(int i_errno)
snprintf(errstr, len, "--bind must be specified to use --cport");
break;
case IEUDPBLOCKSIZE:
snprintf(errstr, len, "block size too large (maximum = %d bytes)", MAX_UDP_BLOCKSIZE);
snprintf(errstr, len, "block size invalid (minimum = %d bytes, maximum = %d bytes)", MIN_UDP_BLOCKSIZE, MAX_UDP_BLOCKSIZE);
break;
case IEBADTOS:
snprintf(errstr, len, "bad TOS value (must be between 0 and 255 inclusive)");