Skip to contentSkip to conversation

in tftp client, recover from lost ACKs

PATCH New Brenda J. Butler 2 participants 2 messages Jul 25, 2005 – Mar 12, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 in tftp client, recover from lost ACKs

CHANGELOG entry:

* Patch by John McCarthy and Brenda J. Butler, 8 July 2005 When the tftp client sends an ack but it gets lost, the server will resend the block. The client was now expecting the next block and ignored this block, the server never got an ack, and they got stuck. Now the tftp client will ack the block the second (and subsequent) time(s) allowing the tftp session to proceed. This little fix assumes that the server will resend exactly the same contents (same size from same offset).

Here is the patch for you to look at; it is also in an attachment where the tabs and lines are preserved better. Apply to top of head checkout with patch -p0 < uboot2.patch

Index: net/tftp.c
===================================================================
RCS file: /u00/cvs/u-boot3/net/tftp.c,v
retrieving revision 1.1
retrieving revision 1.3

tftp.c 5 Jul 2005 19:48:46 -0000 1.3 renamed from tftp.c 15 Mar 2005 17:53:28 -0000 1.1 +8 -8
diff -u -r1.1 -r1.3
@@ -246,17 +246,17 @@
                        }
                }
 
-               if (TftpBlock == TftpLastBlock) {
-                       /*
-                        *      Same block again; ignore it.
-                        */
-                       break;
-               }
-
                TftpLastBlock = TftpBlock;
                NetSetTimeout (TIMEOUT * CFG_HZ, TftpTimeout);
 
-               store_block (TftpBlock - 1, pkt + 2, len);
+               if (TftpBlock != TftpLastBlock) {
+                       /*
+                        *      Same block again; do everything again
+                        *      except store it.  Hope the server sent
+                        *      exactly the same length/contents.
+                        */
+                        store_block (TftpBlock - 1, pkt + 2, len);
+               }
 
                /*
                 *      Acknoledge the block just received, which will

prompt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: uboot2.patch
Type: text/x-patch
Size: 913 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20050725/5b10c27a/attachment.bin

#1 lore raw

PATCH 1/1 in tftp client, recover from lost ACKs

Quoted 10 lines · In message <[email protected]> you wrote:

* Patch by John McCarthy and Brenda J. Butler, 8 July 2005 When the tftp client sends an ack but it gets lost, the server will resend the block. The client was now expecting the next block and ignored this block, the server never got an ack, and they got stuck. Now the tftp client will ack the block the second (and subsequent) time(s) allowing the tftp session to proceed. This little fix assumes that the server will resend exactly the same contents (same size from same offset).

I understand what you're trying to fix, but your fix doesn't look right to me:

Quoted 4 lines
tftp.c 5 Jul 2005 19:48:46 -0000 1.3 renamed from tftp.c 15 Mar 2005 17:53:28 -0000 1.1 +0 -0
@@ -246,17 +246,17 @@
                        }

tftp.c 5 Jul 2005 19:48:46 -0000 1.3 line 249

Quoted 10 lines
tftp.c 5 Jul 2005 19:48:46 -0000 1.3 renamed from tftp.c 15 Mar 2005 17:53:28 -0000 1.1 +0 -7
                }
 
-               if (TftpBlock == TftpLastBlock) {
-                       /*
-                        *      Same block again; ignore it.
-                        */
-                       break;
-               }
-
                TftpLastBlock = TftpBlock;

Note: here we set TftpLastBlock = TftpBlock

tftp.c 5 Jul 2005 19:48:46 -0000 1.3 line 252

Quoted 4 lines
tftp.c 5 Jul 2005 19:48:46 -0000 1.3 renamed from tftp.c 15 Mar 2005 17:53:28 -0000 1.1 +1 -1
                NetSetTimeout (TIMEOUT * CFG_HZ, TftpTimeout);
 
-               store_block (TftpBlock - 1, pkt + 2, len);
+               if (TftpBlock != TftpLastBlock) {

That means, that this condition will always be false.

Or am I missing something?

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Applying computer technology is simply finding the  right  wrench  to
pound in the correct screw.