[PATCH] net: tftpput: reset timeout_count when an ACK is received

Mikhail Kshevetskiy mikhail.kshevetskiy at iopsys.eu
Fri Nov 29 15:56:26 CET 2024


actually there is the same issue with tftpget
The following patch fix it

>From 2da22fc1fc2601e5b80c742c503177ca235157f8 Mon Sep 17 00:00:00 2001
From: Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu>
Date: Sun, 29 May 2022 19:48:55 +0300
Subject: [PATCH] feature: net/tftp: clear timeout on every successfull block

This patch makes TFTP files loading much more reliable.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu>
---
 net/tftp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/tftp.c b/net/tftp.c
index 704b20b4ff8..8f948204a6f 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -498,6 +498,7 @@ static void tftp_handler(uchar *pkt, unsigned dest,
struct in_addr sip,
                         tftp_state = STATE_DATA;
                         tftp_remote_port = src;
                     }
+                    timeout_count = 0;
                     tftp_send(); /* Send next data block */
                 }
             }
@@ -657,6 +658,7 @@ static void tftp_handler(uchar *pkt, unsigned dest,
struct in_addr sip,
             net_set_state(NETLOOP_FAIL);
             break;
         }
+        timeout_count = 0;
 
         if (len < tftp_block_size) {
             tftp_send();
-- 
2.45.2



On 29.11.2024 17:47, Jerome Forissier wrote:
> timeout_count is never reset once a tftpput transfer has started. If for
> whatever reason timeouts occur frequently, but the server keeps replying
> nonetheless, the transfer may be needlessly aborted.
>
> Reset timer_count on reception of an ACK to avoid this situation.
>
> Signed-off-by: Jerome Forissier <jerome.forissier at linaro.org>
> ---
>  net/tftp.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/net/tftp.c b/net/tftp.c
> index 704b20b4ff8..8d54a83d9c2 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
> @@ -478,6 +478,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
>  	case TFTP_ACK:
>  #ifdef CONFIG_CMD_TFTPPUT
>  		if (tftp_put_active) {
> +			timeout_count = 0;
>  			if (tftp_put_final_block_sent) {
>  				tftp_complete();
>  			} else {


More information about the U-Boot mailing list