summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSean Edmond <seanedmond@linux.microsoft.com>2023-01-04 18:16:26 -0800
committerTom Rini <trini@konsulko.com>2023-02-02 14:44:53 -0500
commit21a265c0d1ef93ed40e1990f33be0bc427e956f0 (patch)
treea4830c70ec6d5e61e073a5f48dc643834b1b2241 /net
parentc3d9736d54e7504656577020e3608f01c8fa76d5 (diff)
downloadu-boot-21a265c0d1ef93ed40e1990f33be0bc427e956f0.tar.gz
u-boot-21a265c0d1ef93ed40e1990f33be0bc427e956f0.tar.bz2
u-boot-21a265c0d1ef93ed40e1990f33be0bc427e956f0.zip
net: tftp: Fix for DATA ACK for block count out of order
In rfc7440, if an ACK is not received by the server or if the last data block in a window is dropped, the server will timeout and retransmit the window. In this case, the block count received will be less than the internal block count. In this case, the client should not ACK. ACK should only be sent if the received block count is greater than the expected block count. Signed-off-by: Sean Edmond <seanedmond@linux.microsoft.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Diffstat (limited to 'net')
-rw-r--r--net/tftp.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/tftp.c b/net/tftp.c
index c780c33f37..51e062bddf 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -593,6 +593,14 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
ntohs(*(__be16 *)pkt),
(ushort)(tftp_cur_block + 1));
/*
+ * Only ACK if the block count received is greater than
+ * the expected block count, otherwise skip ACK.
+ * (required to properly handle the server retransmitting
+ * the window)
+ */
+ if ((ushort)(tftp_cur_block + 1) - (short)(ntohs(*(__be16 *)pkt)) > 0)
+ break;
+ /*
* If one packet is dropped most likely
* all other buffers in the window
* that will arrive will cause a sending NACK.