freebsd-skq/sys/boot/efi/loader
jhb ae0b7d188d Fix unit number of EFI net interfaces and ignore psuedo network interfaces.
In r277943, the efinet_match() routine was changed to use an off by one
when matching network interfaces.  The effect was that using "net1"
actually used the device attached to "net0".

Digging into the hardware that needed this workaround more, I found that
UEFI was creating two simple network protocol devices for each physical
NIC.  The first device was a "raw" Ethernet device and the second device
was a "IP" device that used the IP protocol on top of the underlying
"raw" device.  The PXE code in the firmware used the "IP" device to pull
across the loader.efi, so currdev was set to "net1" when booting from the
physical interface "net0".  (The loaded image's device handle referenced
the "IP" device that "net1" claimed.)

However, the IP device isn't suitable for doing raw packet I/O (and the
current code to open devices exclusively actually turns the "IP" devices
off on these systems).

To fix, change the efinet driver to only attach to "raw" devices.  This
is determined by fetching the DEVICE_PATH for each handle which supports
the simple network protocol and examining the last node in the path.  If
the last node in the path is a MAC address, the device is assumed to be
a "raw" device and is added as a 'netX' device.  If the last node is not
a MAC address, the device is ignored.

However, this causes a new problem as the device handle associated with
the loaded image no longer matches any of the handles enumerated by
efinet for systems that load the image via the "IP" device.  To handle
this case, expand the logic that resolves currdev from the loaded image
in main().  First, the existing logic of looking for a handle that
matches the loaded image's handle is tried.  If that fails, the device
path of the handle that loaded the loaded image is fetched via
efi_lookup_image_devpath().  This device path is then walked from the
end up to the beginning using efi_handle_lookup() to fetch the handle
associated with a path.  If the handle is found and is a known handle,
then that is used as currdev.  The effect for machines that load the
image via the "IP" device is that the first lookup fails (the handle
for the "IP" device isn't claimed by efinet), but walking up the
image's device path finds the handle of the raw MAC device which is used
as currdev.

With these fixes in place, the hack to subtract 1 from the unit can now
be removed, so that setting currdev to 'net0' actually uses 'net0'.

PR:		202097
Tested by:	ambrisko
Sponsored by:	Cisco Systems
2016-05-26 23:32:28 +00:00
..
arch Deprecate using hints.acpi.0.rsdp to communicate the RSDP to the 2016-04-14 04:59:51 +00:00
autoload.c Enable warnings in EFI boot code 2016-01-12 02:17:39 +00:00
bootinfo.c Fix several instances where the boot loader ignored pager_output 2016-05-18 05:59:05 +00:00
conf.c Add EFI ZFS boot support 2016-01-15 02:33:47 +00:00
copy.c Enable warnings in EFI boot code 2016-01-12 02:17:39 +00:00
devicename.c Add EFI ZFS boot support 2016-01-15 02:33:47 +00:00
loader_efi.h Enable warnings in EFI boot code 2016-01-12 02:17:39 +00:00
main.c Fix unit number of EFI net interfaces and ignore psuedo network interfaces. 2016-05-26 23:32:28 +00:00
Makefile Remove second copy of the -Wno-format band-aid for printf %S. 2016-05-26 23:06:36 +00:00
Makefile.depend DIRDEPS_BUILD: Regenerate without local dependencies. 2016-02-24 17:20:11 +00:00
version