[PATCH] net: tftpboot: clear timeout_count on every successful block

Simon Glass sjg at chromium.org
Wed Dec 4 16:13:07 CET 2024


Hi Mikhail,

On Tue, 3 Dec 2024 at 16:27, Mikhail Kshevetskiy
<mikhail.kshevetskiy at iopsys.eu> wrote:
>
> timeout_count is never reset once a tftpboot 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 every successful block to avoid this situation.
>
> Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu>
> ---
>  net/tftp.c | 2 ++
>  1 file changed, 2 insertions(+)
>

What is the impact of this change?

> 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
>

Regards,
Simon


More information about the U-Boot mailing list