[BusyBox] tftp client timeout for lost acks

Brenda J. Butler bjb at istop.com
Mon Jun 6 03:30:47 UTC 2005


We were seeing some timeouts when getting files with the busybox tftp
client.

With tcpdump, we saw that the tftp client was receiving blocks and
ack'ing them, but the server was failing to receive the occasional
ack.

When that happened, the server would send the last block over again,
but the tftp client was expecting the next block.

This patch allows the client to recover from this situation
(it sends an ack for the repeat block but does not write it
to the local file).

I hope it meets your approval, please don't hesitate to send
me comments for improvement.

The patch is against "head" in svn, I tested it on an older version
of busybox in our environment.  It applied cleanly to the older
version.

Credit for this goes to my co-worker John McCarthy for finding
it and me for fixing it (assuming it works for everyone else too).

cheerio,
bjb


Index: networking/tftp.c
===================================================================
--- networking/tftp.c   (revision 10474)
+++ networking/tftp.c   (working copy)
@@ -458,6 +458,13 @@
                                opcode = TFTP_ACK;
                                continue;
                        }
+                       /* in case the last ack disappeared into the ether */
+                       if ( tmp == (block_nr - 1) ) {
+
+                               --block_nr;
+                               opcode = TFTP_ACK;
+                               continue;
+                       }
                }
 
                if (cmd_put && (opcode == TFTP_ACK)) {



More information about the busybox mailing list