Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End session with empty data packet if necessary. #4

Merged
merged 3 commits into from
Nov 19, 2015
Merged

End session with empty data packet if necessary. #4

merged 3 commits into from
Nov 19, 2015

Conversation

bjoernalbers
Copy link
Contributor

Hello Piotr,

with this patch tftpd will properly terminate the session, even if the last data packet would have a payload of 512 bytes.
Without the patch the session would timeout under such circumstances (10.1.1.1 = tftp client @ Cisco ASA, 10.1.1.100 = tftp server "fx-tftp"):

18:36:24.230219 IP 10.1.1.100.20290 > 10.1.1.1.33842: UDP, length 516
        0x0000:  4500 0220 8a28 0000 4011 0000 0a01 0164  E....(..@......d
        0x0010:  0a01 0101 4f42 8432 020c 1884 0003 79a4  ....OB.2......y.
        0x0020:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0030:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0040:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0050:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0060:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0070:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0080:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0090:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00a0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00b0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00c0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00d0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00e0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00f0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0100:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0110:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0120:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0130:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0140:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0150:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0160:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0170:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0180:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0190:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01a0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01b0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01c0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01d0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01e0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01f0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0200:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0210:  0000 0000 0000 0000 0000 0000 0000 0000  ................
18:36:24.230532 IP 10.1.1.1.33842 > 10.1.1.100.20290: UDP, length 4
        0x0000:  4500 0020 41d8 0000 ff11 638e 0a01 0101  E...A.....c.....
        0x0010:  0a01 0164 8432 4f42 000c 9c52 0004 79a4  ...d.2OB...R..y.
        0x0020:  0000 0000 0000 0000 0000 0000 0000       ..............
18:36:39.242049 IP 10.1.1.1.33842 > 10.1.1.100.20290: UDP, length 5
        0x0000:  4500 0021 0a02 0000 ff11 9b63 0a01 0101  E..!.......c....
        0x0010:  0a01 0164 8432 4f42 000d 15f4 0005 0000  ...d.2OB........
        0x0020:  0000 0000 0000 0000 0000 0000 0000       ..............

Now we just send an empty data packet and everybody is happy :-)

18:46:30.214452 IP 10.1.1.100.27069 > 10.1.1.1.52230: UDP, length 516
        0x0000:  4500 0220 1e9f 0000 4011 0000 0a01 0164  E.......@......d
        0x0010:  0a01 0101 69bd cc06 020c 1884 0003 79a4  ....i.........y.
        0x0020:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0030:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0040:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0050:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0060:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0070:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0080:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0090:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00a0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00b0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00c0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00d0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00e0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x00f0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0100:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0110:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0120:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0130:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0140:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0150:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0160:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0170:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0180:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0190:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01a0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01b0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01c0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01d0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01e0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x01f0:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0200:  0000 0000 0000 0000 0000 0000 0000 0000  ................
        0x0210:  0000 0000 0000 0000 0000 0000 0000 0000  ................
18:46:30.214678 IP 10.1.1.1.52230 > 10.1.1.100.27069: UDP, length 4
        0x0000:  4500 0020 6a00 0000 ff11 3b66 0a01 0101  E...j.....;f....
        0x0010:  0a01 0164 cc06 69bd 000c 3a03 0004 79a4  ...d..i...:...y.
        0x0020:  0000 0000 0000 0000 0000 0000 0000       ..............
18:46:30.214789 IP 10.1.1.100.27069 > 10.1.1.1.52230: UDP, length 4
        0x0000:  4500 0020 56dc 0000 4011 0000 0a01 0164  E...V...@......d
        0x0010:  0a01 0101 69bd cc06 000c 1684 0003 79a5  ....i.........y.
18:46:30.214966 IP 10.1.1.1.52230 > 10.1.1.100.27069: UDP, length 4
        0x0000:  4500 0020 28b5 0000 ff11 7cb1 0a01 0101  E...(.....|.....
        0x0010:  0a01 0164 cc06 69bd 000c 3a02 0004 79a5  ...d..i...:...y.
        0x0020:  0000 0000 0000 0000 0000 0000 0000       ..............

Thanks for pushing this to Rubygems as well,
Björn

- Add rake as development dependency so that `bundle exec rake` works as
  expected.
- Remove descriptions from Rake::TestTasks object in order to avoid...

     "undefined method `description=' for #<Rake::TestTask:..."
> The end of a transfer is marked by a DATA packet that contains
> between 0 and 511 bytes of data (i.e., Datagram length < 516).

-- [RFC 1350, Section 6: Normal Termination](https://www.ietf.org/rfc/rfc1350.txt)
@drbig
Copy link
Owner

drbig commented Nov 19, 2015

Thanks again for contributing back! :) Much appreciated. Gem will be pushed.

drbig added a commit that referenced this pull request Nov 19, 2015
End session with empty data packet if necessary.
@drbig drbig merged commit 28d9b36 into drbig:master Nov 19, 2015
@bjoernalbers
Copy link
Contributor Author

Cool :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants