From: seanedmond@linux.microsoft.com
To: u-boot@lists.denx.de
Cc: joe.hershberger@ni.com, rfried.dev@gmail.com
Subject: [PATCH] net: tftp: Fix for DATA ACK for block count out of order
Date: Wed, 4 Jan 2023 16:45:42 -0800 [thread overview]
Message-ID: <20230105004542.13638-1-seanedmond@linux.microsoft.com> (raw)
From: Sean Edmond <seanedmond@microsoft.com>
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@microsoft.com>
---
net/tftp.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/tftp.c b/net/tftp.c
index c780c33f37..51e062bddf 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -592,6 +592,14 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
debug("Received unexpected block: %d, expected: %d\n",
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
--
2.17.1
next reply other threads:[~2023-01-05 13:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 0:45 seanedmond [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-01-05 2:16 [PATCH] net: tftp: Fix for DATA ACK for block count out of order seanedmond
2023-01-10 17:10 ` Ramon Fried
2023-02-03 18:20 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230105004542.13638-1-seanedmond@linux.microsoft.com \
--to=seanedmond@linux.microsoft.com \
--cc=joe.hershberger@ni.com \
--cc=rfried.dev@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox