PXE boot requests non-standard config filename

Bug #827705 reported by Dave Walker
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro U-Boot
Fix Released
Undecided
Loïc Minier
u-boot
Invalid
Undecided
Unassigned
u-boot (Ubuntu)
Invalid
Undecided
Unassigned
u-boot-linaro (Ubuntu)
Fix Released
Medium
John Rigby

Bug Description

u-boot attempts to grab 88-99-aa-bb-cc-dd rather than 01-88-99-aa-bb-cc-dd as is convention.

"search for the config file using the hardware type (using its ARP type code) and address, all in lower case hexadecimal with dash separators; for example, for an Ethernet (ARP type 1) with address 88:99:AA:BB:CC:DD it would search for the filename 01-88-99-aa-bb-cc-dd. "

Seems to be a simple change to format_mac_pxecfg() in common/cmd_pxecfg.c

Thanks.

Related branches

Dave Walker (davewalker)
tags: added: server-o-ro
Changed in u-boot-linaro (Ubuntu):
assignee: nobody → John Rigby (jcrigby)
status: New → Confirmed
importance: Undecided → Medium
Changed in u-boot-linaro:
status: New → Confirmed
assignee: nobody → John Rigby (jcrigby)
Revision history for this message
Loïc Minier (lool) wrote :
Download full text (3.5 KiB)

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 f...

Read more...

Revision history for this message
Loïc Minier (lool) wrote :
Download full text (4.4 KiB)

Attached patch seems to produce desired effect for me; I get this output:
U-Boot SPL 2011.06-dirty (Aug 17 2011 - 14:34:54)
Texas Instruments OMAP4430 ES2.1
OMAP SD/MMC: 0
reading u-boot.img
reading u-boot.img

U-Boot 2011.06-dirty (Aug 17 2011 - 14:34:54)

CPU : OMAP4430
Board: OMAP4 Panda
I2C: ready
DRAM: 1 GiB
MMC: OMAP SD/MMC: 0
Using default environment

In: serial
Out: serial
Err: serial
Net: No ethernet found.
Hit any key to stop autoboot: 0
reading boot.scr

** Unable to read "boot.scr" from mmc 0:1 **
reading uEnv.txt

** Unable to read "uEnv.txt" from mmc 0:1 **
reading uImage

** Unable to read "uImage" from mmc 0:1 **
(Re)start USB...
USB: Register 1313 NbrPorts 3
USB EHCI 1.00
scanning bus for devices... The request port(2) is not configured
The request port(2) is not configured
3 USB Device(s) found
       scanning bus for storage devices... 0 Storage Device(s) found
       scanning bus for ethernet devices... 1 Ethernet Device(s) found
Waiting for Ethernet connection... done.
BOOTP broadcast 1
DHCP client bound to address 172.17.0.2
missing environment variable: pxeuuid
missing environment variable: ethaddr
Retreiving file: pxelinux.cfg/01-2E-40-72-A2-6C-0A
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server 172.16.0.254; our IP address is 172.17.0.2
Filename 'pxelinux.cfg/01-2E-40-72-A2-6C-0A'.
Load address: 0x88000000
Loading: EHCI timed out on TD - token=0x8008d80
T
TFTP error: 'File not found' (1)
Not retrying...
File not found
Retreiving file: pxelinux.cfg/AC110002
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server 172.16.0.254; our IP address is 172.17.0.2
Filename 'pxelinux.cfg/AC110002'.
Load address: 0x88000000
Loading: EHCI timed out on TD - token=0x8008d80
T
TFTP error: 'File not found' (1)
Not retrying...
File not found
Retreiving file: pxelinux.cfg/AC11000
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server 172.16.0.254; our IP address is 172.17.0.2
Filename 'pxelinux.cfg/AC11000'.
Load address: 0x88000000
Loading: EHCI timed out on TD - token=0x88008d80
T
TFTP error: 'File not found' (1)
Not retrying...
File not found
Retreiving file: pxelinux.cfg/AC1100
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server 172.16.0.254; our IP address is 172.17.0.2
Filename 'pxelinux.cfg/AC1100'.
Load address: 0x88000000
Loading: EHCI timed out on TD - token=0x8008d80
T
TFTP error: 'File not found' (1)
Not retrying...
File not found
Retreiving file: pxelinux.cfg/AC110
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server 172.16.0.254; our IP address is 172.17.0.2
Filename 'pxelinux.cfg/AC110'.
Load address: 0x88000000
Loading: EHCI timed out on TD - token=0x88008d80
T
TFTP error: 'File not found' (1)
Not retrying...
File not found
Retreiving file: pxelinux.cfg/AC11
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server 172.16.0.254; our IP address is 172.17.0.2
Filename 'pxelinux.cfg/AC11'.
Load address: 0x88000000
Loading: EHCI timed out on TD - token=0x8008d80
T
TFTP error: 'File not found' (1)
Not retrying...
File not found
Retreiving file: pxelinux.cfg/AC1
Waiting for Eth...

Read more...

Revision history for this message
Andres Rodriguez (andreserl) wrote :

Howdy Loic,

Please, also make sure that the tftp test server you are using, is looking for 01-<mac> (in lowercase) files, as the standard specifies that files in the tftp should be in lowercase. Cause, AFAIK, and how it seems in your example (01-<MAC> uppercase), if it looks for a file in uppercase and it doesn't find it (because the tfpt one is in lowercase), it will also fail to find the file.

Hope this info helps. If you've already tested/considered this, please disregard m,y comments.

Cheers,

tags: added: patch
Revision history for this message
Loïc Minier (lool) wrote :

Andres, good catch, thanks for the reminder; I had skipped over that part of the original bug report.

The additional attached patch lower cases the MAC address too; maybe the code would be rewritten to have two vars and a loop instead of calling sprintf, I'll check with Jason what he prefers. With this additional patch, I get the expected lowercasing:
[...]
3 USB Device(s) found
       scanning bus for storage devices... 0 Storage Device(s) found
       scanning bus for ethernet devices... 1 Ethernet Device(s) found
Waiting for Ethernet connection... done.
BOOTP broadcast 1
DHCP client bound to address 172.17.0.2
missing environment variable: pxeuuid
missing environment variable: ethaddr
Retreiving file: pxelinux.cfg/01-2e-40-72-a2-6c-0a
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server 172.16.0.254; our IP address is 172.17.0.2
Filename 'pxelinux.cfg/01-2e-40-72-a2-6c-0a'.
Load address: 0x88000000
Loading: EHCI timed out on TD - token=0x8008d80
T
TFTP error: 'File not found' (1)
Not retrying...
File not found
Retreiving file: pxelinux.cfg/AC110002
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server 172.16.0.254; our IP address is 172.17.0.2
Filename 'pxelinux.cfg/AC110002'.
[...]

Another thing I noticed from my earlier comment comparing pxelinux and u-boot: pxelinux doesn't send a DHCP request itself, so it doesn't make sense to compare the place where they get the UUID from; pxelinux does the meaningful thing in trying to read the uuid from the reply packet cached by the network card's PXE ROM (it might have been set in the request or in the reply), and u-boot-linaro does the meaningful thing in setting it in the request.

Revision history for this message
Loïc Minier (lool) wrote :

[ John filed bug #828168 about the lower casing, where I clarified that this is pxelinux specific and only concerns MAC addresses (not IPs which should be uppercased as u-boot and pxelinux currently always do); the spec doesn't seem to recommend any treatment of UUID, so I suppose its case should be preserved. ]

John Rigby (jcrigby)
Changed in u-boot-linaro:
assignee: John Rigby (jcrigby) → Loïc Minier (lool)
status: Confirmed → Fix Committed
Tobin Davis (gruemaster)
Changed in u-boot-linaro (Ubuntu):
status: Confirmed → Fix Released
Changed in u-boot-linaro:
status: Fix Committed → Fix Released
Changed in u-boot (Ubuntu):
status: New → Invalid
Changed in u-boot:
status: New → Invalid
Revision history for this message
Dave Walker (davewalker) wrote :

@Tobin, can you add a comment why the u-boot ubuntu package is Invalid - did this package not suffer from this bug?

Thanks.

Revision history for this message
Loïc Minier (lool) wrote :

I believe u-boot is just used to provide mkimage in Ubuntu; u-boot-linaro is the binary package providing the binaries in use for Ubuntu images for beagle/panda etc.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.