opnsense-src/sys
John Baldwin 4e865d9eb0 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
..
amd64 Both Clang and GCC cannot generate efficient reserve_pv_entries(). 2016-05-25 23:06:52 +00:00
arm Add support for triggering interrupts on both rising and falling edges. 2016-05-26 22:34:25 +00:00
arm64 Extract the correct bits from the GICD_TYPER register. The interrupt count 2016-05-20 15:43:51 +00:00
boot Fix unit number of EFI net interfaces and ignore psuedo network interfaces. 2016-05-26 23:32:28 +00:00
bsm Merge from contrib/openbsm to bring the kernel audit bits up to date with OpenBSM 1.2 alpha 4: 2015-12-20 23:22:04 +00:00
cam Fix a few ada(4) driver issues: 2016-05-25 01:37:39 +00:00
cddl Use netinet/in.h to avoid include/arpa dependency for DIRDEPS_BUILD. 2016-05-26 23:20:17 +00:00
compat Define ATOMIC_LONG_INIT() in the LinuxKPI. 2016-05-26 10:03:22 +00:00
conf Add some missing .PHONY. 2016-05-26 23:20:14 +00:00
contrib Remove extraneous blank line. 2016-05-20 03:22:41 +00:00
crypto crypto routines: Hint minimum buffer sizes to the compiler 2016-05-26 19:29:29 +00:00
ddb Add a small set of logical operators to DDB command language. 2016-05-16 19:42:38 +00:00
dev filemon exec: Use imgp->execpath rather than vn_fullpath(9). 2016-05-26 23:27:08 +00:00
fs Remove drop/reacquire of Giant around geom calls for cd9660 and udf. 2016-05-22 18:16:25 +00:00
gdb
geom Remove unneeded Giant locking around kthreads creation. 2016-05-20 08:28:11 +00:00
gnu Bring ralink/mediatek DTS files in sync with LEDE 2016-05-25 06:39:48 +00:00
i386 Add macro to convert errno and use it when appropriate. 2016-05-22 12:46:34 +00:00
isa sys/isa: minor spelling fixes. 2016-05-03 21:51:52 +00:00
kern exec: Provide execpath in imgp for the process_exec hook. 2016-05-26 23:19:39 +00:00
kgssapi kgssapi: insignificant spelling fix. 2016-05-03 22:05:03 +00:00
libkern sys: Make use of our rounddown() macro when sys/param.h is available. 2016-04-30 14:41:18 +00:00
mips Build etherswitch support for appropriate Ralink/Mediatek SoCs 2016-05-25 06:47:28 +00:00
modules Add some missing .PHONY. 2016-05-26 23:20:14 +00:00
net Change net.link.log_promisc_mode_change to a read-only tunable 2016-05-25 09:00:05 +00:00
net80211 ifconfig: set by default FCC regulatory domain for wireless interfaces. 2016-05-26 13:14:08 +00:00
netgraph Fix style(9). 2016-05-26 19:17:51 +00:00
netinet Import Dummynet AQM version 0.2.1 (CoDel, FQ-CoDel, PIE and FQ-PIE). 2016-05-26 21:40:13 +00:00
netinet6 Mark the prefix and default router list sysctl handlers MPSAFE. 2016-05-23 20:18:11 +00:00
netipsec netipsec: Fix minor style nit 2016-05-10 20:14:11 +00:00
netnatm kernel: use our nitems() macro when it is available through param.h. 2016-04-19 23:48:27 +00:00
netpfil Correct a typo in a comment. 2016-05-26 22:03:28 +00:00
netsmb sys/net*: minor spelling fixes. 2016-05-03 18:05:43 +00:00
nfs NFS: spelling fixes on comments. 2016-04-29 16:07:25 +00:00
nfsclient
nfsserver
nlm Remove slightly used const values that can be replaced with nitems(). 2016-04-21 15:38:28 +00:00
ofed Prepare for activation of LinuxKPI module parameters as read-only 2016-05-25 12:03:21 +00:00
opencrypto sys/opencrypto: minor spelling fixes. 2016-05-06 23:37:19 +00:00
pc98 Move 'device pci' for the PCI bus driver to the MI NOTES file. 2016-04-29 23:53:55 +00:00
powerpc Fix the deciKelvin to Celsius conversion in kernel. 2016-05-22 13:58:32 +00:00
riscv Increase the size and alignment of the setjmp buffer. 2016-05-26 10:03:30 +00:00
rpc Remove unnecessary memset(.., 0, ..)'s 2016-05-24 20:06:41 +00:00
security sys/security: minor spelling fixes. 2016-05-06 16:59:04 +00:00
sparc64 Add macro to convert errno and use it when appropriate. 2016-05-22 12:46:34 +00:00
sys WITH_AUTO_OBJ: Fix crunchgen builds. 2016-05-26 23:20:36 +00:00
teken
tests Style 9 changes. 2015-11-12 10:31:14 +00:00
tools Fix MFS builds when both MD_ROOT_SIZE and MFS_IMAGE are specified 2016-02-02 07:02:51 +00:00
ufs arc4random() returns 0 to (2**32)−1, use an alternative to initialize 2016-05-22 14:31:20 +00:00
vm Prevent parallel object collapses. Both vm_object_collapse_scan() and 2016-05-26 16:59:29 +00:00
x86 Only calibrate ICR read loop when not in x2APIC mode. Run-time 2016-05-26 09:09:11 +00:00
xdr RPC: for pointers replace 0 with NULL. 2016-04-14 17:06:37 +00:00
xen Don't repeat the the word 'the' 2016-05-17 12:52:31 +00:00
Makefile Add riscv to the list of architectures for cscope. 2016-02-29 16:39:27 +00:00