diff --git a/src/iperf.h b/src/iperf.h index 6b55559..470ce90 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -291,6 +291,8 @@ struct iperf_test #define MB (1024 * 1024) #define MAX_TCP_BUFFER (512 * MB) #define MAX_BLOCKSIZE MB +/* Maximum size UDP send is (64K - 1) - IP and UDP header sizes */ +#define MAX_UDP_BLOCKSIZE (65535 - 8 - 20) #define MIN_INTERVAL 0.1 #define MAX_INTERVAL 60.0 #define MAX_TIME 86400 diff --git a/src/iperf_api.c b/src/iperf_api.c index 4596c55..0d38f8d 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -913,6 +913,11 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) i_errno = IEBLOCKSIZE; return -1; } + if (test->protocol->id == Pudp && + blksize > MAX_UDP_BLOCKSIZE) { + i_errno = IEUDPBLOCKSIZE; + return -1; + } test->settings->blksize = blksize; if (!rate_flag) diff --git a/src/iperf_api.h b/src/iperf_api.h index 368f498..c416d97 100644 --- a/src/iperf_api.h +++ b/src/iperf_api.h @@ -281,6 +281,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 /* 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 a14f261..10ab3a1 100644 --- a/src/iperf_error.c +++ b/src/iperf_error.c @@ -124,6 +124,9 @@ iperf_strerror(int i_errno) case IEBIND: 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); + break; case IEMSS: snprintf(errstr, len, "TCP MSS too large (maximum = %d bytes)", MAX_MSS); break;