This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch for tftp client code


On Thu, Oct 09, 2003 at 04:33:39PM +0200, Eric Doenges wrote:
> The enclosed patch prevents tftp_get_client from prematurely ending
> transmission without an error if a paket is received out of sequence.
> The original code would interpret such a paket as being the legitimate
> end of transfer, which IMO is wrong no matter how you read RFC 1350
> (which is not terribly clear on how the client should react in such a
> case) -- the tftp_get_client function should either return an error, or
> simply ignore the paket and wait for the server to send the right paket.
> I chose the later approach, which works with the tftp server supplied
> with SuSE 8.2 Linux (according to the man page, this is the version by
> H. Peter Anvin).

Thanks for the patch. I modified the comments to make it a bit clearer
whats happening.

Did you test just the normal case or the error case as well? Its a bit
unusual. UDP is allowed to deliver out of sequence packets, but it
does not often happen. What sort of network setup do you have to make
this happen? Im wondering if your ethernet driver is broken. If so it
will affect you TCP performance.

     Andrew

diff -u -r1.42 ChangeLog
--- net/common/current//ChangeLog       6 Oct 2003 19:07:50 -0000       1.42
+++ net/common/current//ChangeLog       9 Oct 2003 16:01:44 -0000
@@ -1,3 +1,9 @@
+2003-10-09  Eric Doenges <Eric.Doenges@DynaPel.com>
+
+        * src/tftp_client.c: Changed the code so that if the last packet
+       is received out of sequence we don't close the connection but wait
+       for the missing packets.
+ 
 2003-10-06  Andrew Lunn  <andrew.lunn@ascom.ch>
 
        * tests/bridge.c: Build the test when we have the bridge
Index: net/common/current//src/tftp_client.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/src/tftp_client.c,v
retrieving revision 1.6
diff -u -r1.6 tftp_client.c
--- net/common/current//src/tftp_client.c       12 May 2003 10:13:38 -0000      1.6
+++ net/common/current//src/tftp_client.c       9 Oct 2003 16:01:46 -0000
@@ -238,6 +238,11 @@
                  }
                }
                last_good_block++;
+             } else {
+                // To prevent an out-of-sequence last packet from
+                // terminating transmission prematurely, set
+                // actual_len to a full size packet.
+               actual_len = SEGSIZE;
              }
              // Send out the ACK
              hdr->th_opcode = htons(ACK);
@@ -248,6 +253,7 @@
                *err = TFTP_NETERR;
                goto out;
              }
+              // A short packet marks the end of the file.
              if ((actual_len >= 0) && (actual_len < SEGSIZE)) {
                // End of data
                close(s);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]