[Bug 827705] Re: PXE boot requests non-standard config filename
Loïc Minier
lool at dooz.org
Wed Aug 17 11:04:41 UTC 2011
I had a look at what the spec says and what pxelinux and u-boot-linaro
do in practice.
== pxelinux ==
Looking at pxelinux 4.04 as found in Ubuntu oneiric syslinux source
package version 2:4.04+dfsg-1ubuntu1.
syslinux/core/fs/pxe/pxe.c:network_init() calls into the PXE ROM to get
the DHCPACK packet with pxe_get_cached_info(2) (2 is BOOTP_REPLY
according to the PXE spec and I confirmed this with a wire capture which
shows 0x02 as the first byte of the BOOTP packet/UDP payload); the MAC
type is then derived from the struct bootp_t hardware field and is
always 1 for Ethernet (0x01 as the second byte of the BOOTP packet / UDP
payload) and finally the actual MAC address is read from the macaddr
field.
For completeness, syslinux/core/fs/pxe/pxe.h defines a bootp packet as follow:
struct bootp_t {
uint8_t opcode; /* BOOTP/DHCP "opcode" */
uint8_t hardware; /* ARP hreadware type */
[...]
uint8_t macaddr[16]; /* Client MAC address */
In syslinux/core/fs/pxe/pxe.c:make_bootif_string(), the BOOTIF string is constructed as follows by pxelinux:
dst += sprintf(dst, "BOOTIF=%02x", MAC_type);
src = MAC;
for (i = MAC_len; i; i--)
dst += sprintf(dst, "-%02x", *src++);
and MAC_str just points at BOOTIFStr+7 (skipping "BOOTIF=")
Finally, pxe_load_config() in pxe.c attempts loading the following files:
* the DHCP provided filename
* pxelinux.cfg/ + UUID (if set in a DHCP option of the reply)
* pxelinux.cfg/ + MAC_str (MAC type and MAC address bytes in hexa separated by dashes)
* pxelinux.cfg/ + IP based strings (IP in hex without separators, getting shorter and shorter and less specific)
* pxelinux.cfg/ + "default"
== u-boot-linaro ==
Looking at u-boot-linaro-stable
605c08e8b6f7b7e4b9d17b6cb367fb27ce1c511c.
u-boot-linaro/common/cmd_pxecfg.c:get_pxecfg() tries:
* pxelinux.cfg/ + UUID (set in pxeuuid u-boot env)
* pxelinux.cfg/ + MAC address; the MAC address is looked for in the format_mac_pxecfg() function which tries the ethaddr u-boot env and falls back to usbethaddr, then converts all colons to dashes
* pxelinux.cfg/ + IP based strings (identical results to pxelinux -- sprintf(ip_addr, "%08X", ntohl(NetOurIP)))
* pxelinux.cfg/ + "default"
However by default the bootp/dhcp commands will attempt to load the DHCP
supplied filename, so that should result in a similar behavior to the
pxelinux one.
The main differences in the u-boot implementation are:
* UUID is set by the config / end-user in u-boot env instead and sent in DHCP requests rather than coming from DHCP replies
* MAC address doesn't come from the packet but from the env
* MAC type prefix is missing, should be read from the DHCP/BOOTP reply
== Spec ==
What the Intel PXE spec says is that:
* UUID comes from SMBIOS tables
* UUID should be sent in the DHCP requests
* only the DHCP/BOOTP provided filenames should be tried, nothing more
* doesn't say anything about where the MAC address should be obtained from or using a MAC type; this is pxelinux specific
But in reality, pxelinux is split in two stages: pxelinux.0 and then the config file it downloads; what u-boot emulates is what stage 1 does to download the stage 2 config and files that the config refers to.
So looking at what's missing, ideally u-boot would use the data from the
dhcp/bootp reply rather than from the env, but this is painful to do in
separate u-boot commands (dumping packets in the u-boot environment or
storing them in a configured memory location would suck), hence the
easiest way to match pxelinux is probably to just hardcode a 01- prefix
before the MAC address requests.
--
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to the bug report.
https://bugs.launchpad.net/bugs/827705
Title:
PXE boot requests non-standard config filename
To manage notifications about this bug go to:
https://bugs.launchpad.net/u-boot/+bug/827705/+subscriptions
More information about the Ubuntu-server-bugs
mailing list