Posted on 2010-05-05 08:00:00
Tags: FreeBSD, tftp
Thanks to the bravery (or the despair, I am not sure) of Warner Losh aka imp@, the FreeBSD base system now comes with a much needed upgrade of the TFTP server and client.
Although the code has been available for a two years already as the net/freebsd-tftp port and I used successfully and extensively in my previous job at BarNet, I never maneged (dared?) to commit it into the FreeBSD base system.
The import of the new code was announced as such:
Go ahead and merge the work edwin@ on tftpd into the tree. It is a lot better than what's in the tree now. Edwin tested it at a prior employer, but can't test it today. I've found that it works a lot better with the various uboot versions that I've used in my embedded work.
It all started when we got some new routers, which told me the following when trying to upload configuration or download images from it: The TFTP server doesn't support the blocksize option.
My curiousity was triggered, it took me some reading of RFCs and other documentation to find out what was possible and what could be done. Was plain TFTP very simple in its handshake, TFTP with options was kind of messy because of its backwards capability: The first packet returned could either be an acknowledgement of options, or the first data packet.
Going through the source code of src/libexec/tftpd and going through the code of src/usr.bin/tftp showed that there was a lot of duplicate code, and the addition of options would only increase the amount of duplicate code. After all, both the client and the server can act as a sender and receiver.
At the end, it ended up with a nearly complete rewrite of the tftp client and server. It has been tested against the following TFTP clients and servers:
- Itself (yay!)
- The standard FreeBSD tftp client and server
- The Fedora Core 6 tftp client and server
- Cisco router tftp client
- Extreme Networks tftp client
It supports the following RFCs:
- RFC1350 - THE TFTP PROTOCOL (REVISION 2)
- RFC2347 - TFTP Option Extension
- RFC2348 - TFTP Blocksize Option
- RFC2349 - TFTP Timeout Interval and Transfer Size Options
- RFC3617 - Uniform Resource Identifier (URI) Scheme and Applicability Statement for the Trivial File Transfer Protocol (TFTP)
It supports the following unofficial TFTP Options as described at http://www.compuphase.com/tftp.htm:
- blksize2 - Block size restricted to powers of 2, excluding protocol headers
- rollover - Block counter roll-over (roll back to zero or to one)
From the tftp program point of view the following things are changed:
- New commands: "blocksize", "blocksize2", "rollover" and "options"
- Development features: "debug" and "packetdrop"
If you try this tftp/tftpd implementation, please let me know if it works (or doesn't work) and against which implementaion so I can get a list of confirmed working systems.
Posted on 2008-09-10 17:00:00, modified on 2008-09-11 12:00:00
Tags: Networking, FreeBSD, PXE, tftp
After being able to use PXE to boot up virtual machines in QEMU, I found an old computer with an old (1998 firmware) fxp ethernet card (Intel EtherExpress PRO/100 Ethernet) I thought "let's boot FreeBSD -current on it!"
That was easier said than done, because for some reason the ethernet card it was requesting a very strange path:
Where is that 0xff coming from? And how can I ever create a file like that?16:48:24.742828 IP 10.204.250.12.2071 > 10.204.250.2.69: 30 RRQ "pxebootM-^?" octet blksize 1456 0x0000: 4500 003a 0006 0000 1411 9d06 0acc fa0c E..:............ 0x0010: 0acc fa02 0817 0045 0026 a4f9 0001 7078 .......E.&....px 0x0020: 6562 6f6f 74ff 006f 6374 6574 0062 6c6b eboot..octet.blk 0x0030: 7369 7a65 0031 3435 3600 size.1456.
Let's see if the DHCP answer is correct (with net/dhcpdump, also available from my website):
pxeboot, exactly what I expected. The ethernet card wasn't really helpful neither, it just said "TFTP: File not found" without specifying which file it was looking for. Maybe it happened because the option with the Bootfile name is the last one in the packet and it doesn't know how to handle it. Unfortunately this is 1998 firmware and I'm pretty sure that it isn't available from anywhere, let alone be able to update it...TIME: 2008-09-11 10:48:23.169 IP: 10.204.250.2 (00:0f:ea:2c:d5:18) > 255.255.255.255 (ff:ff:ff:ff:ff:ff) OP: 2 (BOOTPREPLY) HTYPE: 1 (Ethernet) HLEN: 6 HOPS: 0 XID: b45ceb89 SECS: 1024 FLAGS: 7f80 CIADDR: 0.0.0.0 YIADDR: 10.204.250.12 SIADDR: 10.204.250.2 GIADDR: 0.0.0.0 CHADDR: 00:02:b3:5c:eb:89:00:00:00:00:00:00:00:00:00:00 SNAME: . FNAME: pxeboot. OPTION: 53 ( 1) DHCP message type 2 (DHCPOFFER) OPTION: 54 ( 4) Server identifier 10.204.250.2 OPTION: 51 ( 4) IP address leasetime 600 (10m) OPTION: 1 ( 4) Subnet mask 255.255.255.0 OPTION: 3 ( 4) Routers 10.204.250.1 OPTION: 60 ( 6) Vendor class identifier Mavvie OPTION: 67 ( 7) Bootfile name pxeboot
So let's give it the file it wants. The shell I use nor the terminals I use actually make it possible for me to enter the ASCII character 255. So it's Perl to the rescue:
Oh... That's a hard-link. Oh well, as long as it works.[/tftpboot] root@k7>perl -e 'link("pxeboot", "pxeboot\xff"); ' [/tftpboot] root@k7>ls -al total 854 drwxr-xr-x 2 nobody wheel 512 Sep 10 11:05 . drwxr-xr-x 21 root wheel 512 Aug 2 07:40 .. -rw-r--r-- 2 root wheel 260097 Aug 27 21:20 pxeboot -rw-r--r-- 2 root wheel 260097 Aug 27 21:20 pxeboot?
Did you see the blksize 1456? If you are using the net/freebsd-tftp port, you will send packets with that size instead of 512 bytes:
16:48:24.747635 IP 10.204.250.2.65265 > 10.204.250.12.2071: UDP, length 15 16:48:24.747821 IP 10.204.250.12.2071 > 10.204.250.2.65265: UDP, length 4 16:48:24.747961 IP 10.204.250.2.65265 > 10.204.250.12.2071: UDP, length 1460 16:48:24.748919 IP 10.204.250.12.2071 > 10.204.250.2.65265: UDP, length 4
Posted on 2008-01-31 20:00:00
Tags: Networking, tftp, FreeBSD
It all started when we got some new routers, which told me the following when trying to upload configuration or download images from it: The TFTP server doesn't support the blocksize option.
My curiousity was triggered, it took me some reading of RFCs and other documentation to find out what was possible and what could be done. Was plain TFTP very simple in its handshake, TFTP with options was kind of messy because of its backwards capability: The first packet returned could either be an acknowledgement of options, or the first data packet.
Going through the source code of src/libexec/tftpd and going through the code of src/usr.bin/tftp showed that there was a lot of duplicate code, and the addition of options would only increase the amount of duplicate code. After all, both the client and the server can act as a sender and receiver.
At the end, it ended up with a nearly complete rewrite of the tftp client and server. It has been tested against the following TFTP clients and servers:
It supports the following RFCs:
It supports the following unofficial TFTP Options as described at http://www.compuphase.com/tftp.htm:
From the tftp program point of view the following things are changed:
If you try this tftp/tftpd implementation, please let me know if it works (or doesn't work) and against which implementaion so I can get a list of confirmed working systems.
For now, the new implementation can be found at as a port in net/freebsd-tftp until it has been imported back into the FreeBSD base system.
Posted on 2007-11-26 10:00:00
Tags: FreeBSD, tftp
Commit of the day for tftpd(8):
Add the -W options, which acts the same as -w but will generate unique names based on the submitted filename, a strftime(3) format string and a two digit sequence number. By default the strftime(3) format string is %Y%m%d (YYYYMMDD), but this can be changed by the -F option.
What does this mean? That you don't have to worry about overwriting your precious previous saved router configuration files:
[/tftpboot] root@tftp>ls -al -rw-r--r-- 1 nobody wheel 44048 Jun 22 08:52 hs2-bd8806.20070622.00 -rw-r--r-- 1 nobody wheel 45973 Jul 21 17:24 hs2-bd8806.20070721.00 -rw-r--r-- 1 nobody wheel 49140 Oct 4 21:49 hs2-bd8806.20071004.00 -rw-r--r-- 1 nobody wheel 49176 Oct 4 21:53 hs2-bd8806.20071004.01 -rw-r--r-- 1 nobody wheel 49177 Oct 4 21:54 hs2-bd8806.20071004.02
This will be availabe in FreeBSD >7.0, >6.3 and >5.5.
Patches will be available from src/libexec/tftpd/
in revisions:
Posted on 2005-02-21 13:02:07, modified on 2006-01-09 16:29:23
Tags: Voice over IP, Cisco, tftp, DHCP
For a new project within BarNet, we're going to use the Cisco solution for Voice-over-IP. The central server will be the Cisco Call Manager (and friends), the phones will be Cisco 7970 phones.
DHCP-wise these devices aren't too demanding, it asks for the TFTP server and something like option 150 (which is unspecified as far as I can tell). The TFTP server option is a string with the hostname or IP address of the TFTP server. The option 150 is, after going through the documentation of the Cisco gear, *also* for specifying the TFTP server, but then only with the IP address.
So the DHCP configuration should be (for people using the ISC DHCP server):
option cisco-tftp code 150 = array of ip-address;
class "cisco7970" {
match if substring (option vendor-class-identifier,0,37) = "Cisco Systems, Inc. IP Phone CP-7970G";
option arp-cache-timeout 60;
option cisco-tftp 192.168.1.1,192.168.1.2;
option tftp-server-name "cisco-cm.mavetju.org";
}
Update
There is a draft for the option 150 available at: http://www.ietf.org/internet-drafts/draft-raj-dhc-tftp-addr-option-00.txt