diff options
author | Tom Rini <trini@konsulko.com> | 2020-10-01 09:46:10 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-10-01 09:46:10 -0400 |
commit | 26acc6395fee680cea72e51348bd59e206eb0464 (patch) | |
tree | 14a2a97d03c4c0cf7b0c531fbdcf9ebec7cfdd13 /net/tftp.c | |
parent | 097bbf1ba97b8ece930deca663f05ea444e99e45 (diff) | |
parent | 912ece4c3dd486bcd62f0d0dfee760b9f01caac6 (diff) |
Merge branch '2020-09-30-assorted-network-improvements' into next
- Generic UDP framework
- TFTP fixes
- dwc_eth_qos, smc911x, smc911x and mscc phy fixes
Diffstat (limited to 'net/tftp.c')
-rw-r--r-- | net/tftp.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/net/tftp.c b/net/tftp.c index 84e970bec13..6fdb1a821a8 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -159,7 +159,8 @@ static unsigned short tftp_window_size_option = TFTP_WINDOWSIZE; static inline int store_block(int block, uchar *src, unsigned int len) { - ulong offset = block * tftp_block_size + tftp_block_wrap_offset; + ulong offset = block * tftp_block_size + tftp_block_wrap_offset - + tftp_block_size; ulong newsize = offset + len; ulong store_addr = tftp_load_addr + offset; #ifdef CONFIG_SYS_DIRECT_FLASH_TFTP @@ -233,7 +234,8 @@ static void new_transfer(void) static int load_block(unsigned block, uchar *dst, unsigned len) { /* We may want to get the final block from the previous set */ - ulong offset = ((int)block - 1) * len + tftp_block_wrap_offset; + ulong offset = block * tftp_block_size + tftp_block_wrap_offset - + tftp_block_size; ulong tosend = len; tosend = min(net_boot_file_size - offset, tosend); @@ -502,6 +504,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip, int block = ntohs(*s); int ack_ok = (tftp_cur_block == block); + tftp_prev_block = tftp_cur_block; tftp_cur_block = (unsigned short)(block + 1); update_block_number(); if (ack_ok) @@ -651,7 +654,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip, timeout_count_max = tftp_timeout_count_max; net_set_timeout_handler(timeout_ms, tftp_timeout_handler); - if (store_block(tftp_cur_block - 1, pkt + 2, len)) { + if (store_block(tftp_cur_block, pkt + 2, len)) { eth_halt(); net_set_state(NETLOOP_FAIL); break; |