History log of /freebsd-10.1-release/lib/libstand/tftp.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 256244 09-Oct-2013 kan

Unbreak zfsloader with LOADER_TFTP_SUPPORT on

Only accept 'net' and 'pxe' devices as underlying transport
in tftp.c on x86. Prior to this change tftp code would attempt
to send packets over any boot device, including zfs one with
predictably sad results.

Approved by: re (gjb)
MFC After: 1 month


# 228798 22-Dec-2011 ed

Add placeholder code for prepending pathnames to tftp.

At work we have a single tftp server that provides installation data for
a variety of operating systems. I'd rather place our FreeBSD-related
files in a subdirectory, instead of the root.

It would be nice if this setting could be run-time configurable, but at
least in our specific case, this is not possible, as pxeboot is
chainloaded through pxelinux.

Sponsored by: Kumina bv


# 223488 24-Jun-2011 rodrigc

Fixes to newer tftp code in libstand:
(1) Coding style changes.
(2) If the server does not acknowledge any blocksize option,
revert to the default blocksize of 512 bytes.
(3) Send ACK if the first packet happens to be the last packet.
(4) Do not accept blocksize greater than what was requested.
(5) Drop any unwanted OACK received if a tftp transfer is already
in progress.
(6) Terminate incomplete transfers with a special no-error ERROR packet.
Otherwise we rely on the tftp server to time out, which it does
eventually, after re-sending the last packet several times and spamming
the system log about it every time. This idea is borrowed from the
PXE client, which does exactly that.

Submitted by: Alexander Kabaev <kan@FreeBSD.org>
Reviewed and Tested by: Santhanakrishnan Balraj <sbalraj at juniper dot net>


# 223128 15-Jun-2011 rodrigc

Bring back following change which was undone in previous commit:

------------------------------------------------------------------------
r172854 | marius | 2007-10-21 10:03:18 -0700 (Sun, 21 Oct 2007) | 16 lines
Changed paths:
M /head/lib/libstand/tftp.c

- Given that we tell the compiler that struct ip is packed and 32-bit
aligned, GCC 4.2.1 also generates code for sendudp() that assumes
this alignment. GCC 4.2.1 however doesn't 32-bit align wbuf, causing
the loader to crash due to an unaligned access of wbuf in sendudp()
when netbooting sparc64. Solve this by specifying wbuf as packed and
32-bit aligned, too. As for lastdata and readudp() this currently is
no issue when compiled with GCC 4.2.1, though give lastdata the same
treatment as wbuf for consistency and possibility of being affected
in the future. [1]
- Sprinkle const on a lookup table.
------------------------------------------------------------------------


# 223124 15-Jun-2011 rodrigc

(1) When sending the TFTP RRQ packet to read a file,
send along the "blksize" option specified in RFC2348,
and the "tsize" option specified in RFC2349.

Add code to parse the TFTP Option Acknowledgement (OACK) packet as
specified in RFC2347.

For TFTP servers which support the "blksize" option, we can
specify a TFTP Data block size larger than the default 512 bytes
specified in RFC1350. This offers greater read performance when
downloading files.

We request an initial size of 1428 bytes, which is less than the
Ethernet MTU of 1500 bytes. If the TFTP server sends back an OACK
packet, then use the block size specified in the OACK packet.
Most times it is usually the same value as what we request.
If the TFTP server supports RFC2348, we will see performance improvements
by transferring files over TFTP with larger block sizes.

If we do not get back an OACK packet, then we most likely we
are interoperating with a legacy TFTP server that does not
support TFTP extension options, so default to the block size of
512 bytes.

(2) If the "tftp.blksize" environment variable is set, then
take that value and use it when sending the TFTP RRQ packet,
instead of 1428. This allows us to set different values of
"tftp.blksize" in the loader, so that we can test out different
TFTP block sizes at run time.

Obtained from: Juniper Networks
Fixed by: rodrigc


# 223123 15-Jun-2011 rodrigc

Currently tftp code in the loader retransmits the previous packet if it receives any
unwanted packet(non-tftp). Change this to retransmit the packet(request or ack) only after
a timeout.

Obtained from: Juniper Networks
Fixed by: Santhanakrishnan Balraj <sbalraj at juniper dot net>


# 223122 15-Jun-2011 rodrigc

Added sendrecv_tftp function instead of sendrecv for use by tftp.
In sendrecv_tftp:
* Upon receving an unexpected block of data or error, resend the ACK
immediately instead of waiting till the expiry of receive data timeout
to resend the ACK.
* change the receive timeout value between retries to be 2xMINTMO.

Obtained from: Juniper Networks
Fixed by: Santhanakrishnan Balraj <sbalraj at juniper dot net>


# 221366 03-May-2011 rodrigc

Rename DEBUG macro to TFTP_DEBUG, to be more consistent with
debug macros in other files.


# 221358 03-May-2011 rodrigc

Switch to ANSI function prototypes in a few places.
Get rid of some unused parameter warnings.


# 193189 31-May-2009 ed

Fix minor issues in libstand.

- Don't call tftp_makereq() with too many arguments.
- Don't forget to close one of the comments.

Submitted by: Pawel Worach


# 172854 21-Oct-2007 marius

- Given that we tell the compiler that struct ip is packed and 32-bit
aligned, GCC 4.2.1 also generates code for sendudp() that assumes
this alignment. GCC 4.2.1 however doesn't 32-bit align wbuf, causing
the loader to crash due to an unaligned access of wbuf in sendudp()
when netbooting sparc64. Solve this by specifying wbuf as packed and
32-bit aligned, too. As for lastdata and readudp() this currently is
no issue when compiled with GCC 4.2.1, though give lastdata the same
treatment as wbuf for consistency and possibility of being affected
in the future. [1]
- Sprinkle const on a lookup table.

Reported by: marcel [1]
Submitted by: yongari [1]
Reviewed by: marcel [1]
MFC after: 5 days


# 136093 03-Oct-2004 stefanf

Don't add integers to void pointers.


# 111776 02-Mar-2003 marcel

Fix a machine check abort caused by the EFI loader trying to open a
file in the NFS file system when the underlying device is not a
network device. A Sparc64 specific hack for this exact problem was
already present (nfs.c:1.9, tftp.c:1.10), but the problem is not
specific to Sparc64. The hack has been promoted to a non-i386 test
because on non-i386 architectures it's either impossible to have
non-network devices coexist in the same loader with the NFS FS, or
network and non-network device coexist and NFS filesystems can only
be used on top of network devices. I believe i386 pxeboot is where
this does not hold.

The root cause of this problem is in open.c where each file system
is tried until no more file systems exist or a file system returns
success. There's no notion of a list of valid file systems given
the underlying device and the non-existence of a file can cause
the invalid combination to be tried.


# 99558 07-Jul-2002 jake

Add a hack (kludge?) to avoid trying to access files backed by disk
devices as though they were backed by network devices.


# 92913 21-Mar-2002 obrien

Remove 'register' keyword.


# 84221 30-Sep-2001 dillon

Add __FBSDID()s to libstand


# 79034 30-Jun-2001 mikeh

Reset errno so that subsequent TFTP requests don't fail after the
first failure.

PR: misc/25502
MFC after: 2 weeks


# 77369 28-May-2001 msmith

The shortest valid TFTP packet is 4 bytes, not 8.

PR: misc/25503
Submitted by: Jim Browne <jbrowne@jbrowne.com>
MFC after: 1 week


# 69739 08-Dec-2000 ps

When TFTP tries to open a file, it is expecting struct open_file
member f_devdata to be a pointer to a socket number. When currdev
is "pxe", that assumption is correct. When currdev is "disk*", that
assumption is incorrect.

Submitted by: Jim Browne <jbrowne@jbrowne.com>


# 59766 29-Apr-2000 jlemon

Add a readdir function to the loader fsops vector, and implement the
functionality for some of the filesystesms.


# 59086 07-Apr-2000 ps

Break out sendudp and readudp from net.c. This is for PXE, so it
can use its own UDP interface.


# 39468 18-Sep-1998 msmith

Path arguments to *_open functions should be const, but we were mangling
them.

Submitted by: write-protected text segment in BTX


# 38452 20-Aug-1998 msmith

This commit was generated by cvs2svn to compensate for changes in r38451,
which included commits to RCS files with non-trunk default branches.


# 38451 20-Aug-1998 msmith

This is libstand; a support library for standalone executables (eg. bootstrap
modules).
Obtained from: NetBSD, with some architectural changes and many additions.