From 395ee74991aaeac3c0ba0aa505f108571a107da7 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy Date: Wed, 1 Jan 2025 06:20:16 +0300 Subject: [PATCH] net: tftpboot: clear timeout_count on every successful block We have a some boards that rarely starts networking abnormally, so there are many timeouts during file transfer. In the same time there is a normal transfer between timeouts. In this case we can continue transfer (instead of connection aborting) by just clearing timeout counter on every successful block. This patch does not affect the case when several timeouts happen one after another. The transfer will be aborted. Thus the transfer will be continued in the case of unstable link, but will be aborted in the case of inaccessible server. Feature downside: it may greatly slowdown (instead of abort) file transfer in the case of unstable link. Signed-off-by: Mikhail Kshevetskiy --- 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.47.2