Commit 89ba81d1079a07b8430a98c1746c6d411312eb0d
Committed by
Ben Warren
1 parent
5cfaa4e54d
Exists in
master
and in
54 other branches
tftp: get the tftp block size from config file and from the environment
Increasing the block size is useful if CONFIG_IP_DEFRAG is used. Howerver, the last fragments in a burst may overflow the receiving ethernet, so the default is left at 1468, with thre new CONFIG_TFTP_BLOCKSIZE for config files. Further, "tftpblocksize" can be set in the environment. Signed-off-by: Alessandro Rubini <rubini@gnudd.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Showing 1 changed file with 11 additions and 2 deletions Side-by-side Diff
net/tftp.c
... | ... | @@ -84,8 +84,14 @@ |
84 | 84 | /* 512 is poor choice for ethernet, MTU is typically 1500. |
85 | 85 | * Minus eth.hdrs thats 1468. Can get 2x better throughput with |
86 | 86 | * almost-MTU block sizes. At least try... fall back to 512 if need be. |
87 | + * (but those using CONFIG_IP_DEFRAG may want to set a larger block in cfg file) | |
87 | 88 | */ |
89 | +#ifdef CONFIG_TFTP_BLOCKSIZE | |
90 | +#define TFTP_MTU_BLOCKSIZE CONFIG_TFTP_BLOCKSIZE | |
91 | +#else | |
88 | 92 | #define TFTP_MTU_BLOCKSIZE 1468 |
93 | +#endif | |
94 | + | |
89 | 95 | static unsigned short TftpBlkSize=TFTP_BLOCK_SIZE; |
90 | 96 | static unsigned short TftpBlkSizeOption=TFTP_MTU_BLOCKSIZE; |
91 | 97 | |
92 | 98 | |
... | ... | @@ -466,9 +472,12 @@ |
466 | 472 | void |
467 | 473 | TftpStart (void) |
468 | 474 | { |
469 | -#ifdef CONFIG_TFTP_PORT | |
470 | 475 | char *ep; /* Environment pointer */ |
471 | -#endif | |
476 | + | |
477 | + /* Allow the user to choose tftpblocksize */ | |
478 | + if ((ep = getenv("tftpblocksize")) != NULL) | |
479 | + TftpBlkSizeOption = simple_strtol(ep, NULL, 10); | |
480 | + debug("tftp block size is %i\n", TftpBlkSizeOption); | |
472 | 481 | |
473 | 482 | TftpServerIP = NetServerIP; |
474 | 483 | if (BootFile[0] == '\0') { |