u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: tftp: Fix for DATA ACK for block count out of order
@ 2023-01-05  2:16 seanedmond
  2023-01-10 17:10 ` Ramon Fried
  2023-02-03 18:20 ` Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: seanedmond @ 2023-01-05  2:16 UTC (permalink / raw)
  To: u-boot; +Cc: joe.hershberger, rfried.dev, seanedmond

From: Sean Edmond <seanedmond@linux.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@linux.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.39.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: tftp: Fix for DATA ACK for block count out of order
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Ramon Fried @ 2023-01-10 17:10 UTC (permalink / raw)
  To: seanedmond; +Cc: u-boot, joe.hershberger, seanedmond

On Thu, Jan 5, 2023 at 4:16 AM <seanedmond@linux.microsoft.com> wrote:
>
> From: Sean Edmond <seanedmond@linux.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@linux.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.39.0
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: tftp: Fix for DATA ACK for block count out of order
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2023-02-03 18:20 UTC (permalink / raw)
  To: seanedmond; +Cc: u-boot, joe.hershberger, rfried.dev, seanedmond

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

On Wed, Jan 04, 2023 at 06:16:26PM -0800, seanedmond@linux.microsoft.com wrote:

> From: Sean Edmond <seanedmond@linux.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@linux.microsoft.com>
> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] net: tftp: Fix for DATA ACK for block count out of order
@ 2023-01-05  0:45 seanedmond
  0 siblings, 0 replies; 4+ messages in thread
From: seanedmond @ 2023-01-05  0:45 UTC (permalink / raw)
  To: u-boot; +Cc: joe.hershberger, rfried.dev

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-03 18:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
2023-01-05  0:45 seanedmond

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).