From: Sean Edmond Date: Thu, 5 Jan 2023 02:16:26 +0000 (-0800) Subject: net: tftp: Fix for DATA ACK for block count out of order X-Git-Tag: v2023.07~170^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=21a265c0d1ef93ed40e1990f33be0bc427e956f0;p=platform%2Fkernel%2Fu-boot.git 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 Reviewed-by: Ramon Fried --- diff --git a/net/tftp.c b/net/tftp.c index c780c33..51e062b 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.