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.
Этот коммит содержится в:
родитель
f66b42d536
Коммит
03224c9f56
@ -321,6 +321,8 @@ struct iperf_test
|
|||||||
#define MB (1024 * 1024)
|
#define MB (1024 * 1024)
|
||||||
#define MAX_TCP_BUFFER (512 * MB)
|
#define MAX_TCP_BUFFER (512 * MB)
|
||||||
#define MAX_BLOCKSIZE 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 */
|
/* Maximum size UDP send is (64K - 1) - IP and UDP header sizes */
|
||||||
#define MAX_UDP_BLOCKSIZE (65535 - 8 - 20)
|
#define MAX_UDP_BLOCKSIZE (65535 - 8 - 20)
|
||||||
#define MIN_INTERVAL 0.1
|
#define MIN_INTERVAL 0.1
|
||||||
|
@ -1016,7 +1016,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (test->protocol->id == Pudp &&
|
if (test->protocol->id == Pudp &&
|
||||||
blksize > MAX_UDP_BLOCKSIZE) {
|
(blksize < MIN_UDP_BLOCKSIZE || blksize > MAX_UDP_BLOCKSIZE)) {
|
||||||
i_errno = IEUDPBLOCKSIZE;
|
i_errno = IEUDPBLOCKSIZE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ enum {
|
|||||||
IELOGFILE = 17, // Can't open log file
|
IELOGFILE = 17, // Can't open log file
|
||||||
IENOSCTP = 18, // No SCTP support available
|
IENOSCTP = 18, // No SCTP support available
|
||||||
IEBIND = 19, // Local port specified with no local bind option
|
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
|
IEBADTOS = 21, // Bad TOS value
|
||||||
/* Test errors */
|
/* Test errors */
|
||||||
IENEWTEST = 100, // Unable to create a new test (check perror)
|
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
|
* California, through Lawrence Berkeley National Laboratory (subject
|
||||||
* to receipt of any required approvals from the U.S. Dept. of
|
* to receipt of any required approvals from the U.S. Dept. of
|
||||||
* Energy). All rights reserved.
|
* Energy). All rights reserved.
|
||||||
@ -126,7 +126,7 @@ iperf_strerror(int i_errno)
|
|||||||
snprintf(errstr, len, "--bind must be specified to use --cport");
|
snprintf(errstr, len, "--bind must be specified to use --cport");
|
||||||
break;
|
break;
|
||||||
case IEUDPBLOCKSIZE:
|
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;
|
break;
|
||||||
case IEBADTOS:
|
case IEBADTOS:
|
||||||
snprintf(errstr, len, "bad TOS value (must be between 0 and 255 inclusive)");
|
snprintf(errstr, len, "bad TOS value (must be between 0 and 255 inclusive)");
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user