pgj / freebsd-wifibox

wifibox: Use Linux to drive your wireless card on FreeBSD
BSD 2-Clause "Simplified" License
159 stars 12 forks source link

Using wifibox with alternative kernels #86

Closed karlgrose closed 7 months ago

karlgrose commented 7 months ago

Description

When using FreeBSD 15.0-CURRENT with an alternative kernel, /boot/kernel.GENERIC-NODEBUG, wifibox fails to start with errors reported in /var/log/wifibox and dmesg as shown in the logs section below.

Host operating system

FreeBSD powerspec 15.0-CURRENT FreeBSD 15.0-CURRENT main-n268174-5f7ac491eef4 GENERIC-NODEBUG amd64

and

FreeBSD powerspec 15.0-CURRENT FreeBSD 15.0-CURRENT main-n268174-5f7ac491eef4 GENERIC amd64

Wireless NIC

ppt0@pci0:6:0:0:    class=0x028000 rev=0x32 hdr=0x00 vendor=0x168c device=0x003e subvendor=0x1043 subdevice=0x8752
    vendor     = 'Qualcomm Atheros'
    device     = 'QCA6174 802.11ac Wireless Network Adapter'
    class      = network

Wifibox version

wifibox version 0.12.0

Disk image type and version

wifibox:~# uname -a Linux wifibox 6.1.54-0-lts #1-Alpine Wed, 20 Sep 2023 08:50:17 +0000 x86_64 GNU/Linux

Changes to the default configuration files

(Workaround solution)

This override for the VMM_KO wifibox service variable avoids the errors reported in this issue report:

cat /etc/rc.conf.d/wifibox 
wifibox_env="VMM_KO=$(sysctl -n kern.module_path | cut -d ';' -f 1)/vmm.ko"

Logs

======= [from /var/log/wifibox] =======
2024-02-11T23:38:08-0800 INFO  vmm.ko is expected at path: /boot/kernel/vmm.ko
2024-02-11T23:38:08-0800 INFO  vmm.ko is found at path: /boot/kernel.GENERIC-NODEBUG/vmm.ko
2024-02-11T23:38:08-0800 DEBUG assert loaded: kmod=vmm, kmod_file=/boot/kernel/vmm.ko
2024-02-11T23:38:08-0800 DEBUG Kernel module vmm is not loaded
2024-02-11T23:38:08-0800 DEBUG [kldload] kldload: an error occurred while loading module /boot/kernel/vmm.ko. Please check dmesg(8) for more details.
2024-02-11T23:38:08-0800 ERROR /boot/kernel/vmm.ko kernel module could not be loaded
=======

======= [from dmesg -a] =======
wifibox0: link state changed to DOWN
.
link_elf_obj: symbol _sx_assert undefined
linker_load_file: /boot/kernel/vmm.ko - unsupported file type
ERROR: /boot/kernel/vmm.ko kernel module could not be loaded.
=======

Additional context

I found that by overriding the VMM_KO variable using /etc/rc.conf.d/wifibox as noted above in the Changes section, the wifibox service then will load without error and work as expected for both the alternative kernel module, /boot/kernel.GENERIC-NODEBUG/vmm.ko, when booting that flavor kernel and for the default generic module, /boot/kernel/vmm.ko, when booting that GENERIC kernel.

Have you tried to turn it on and off?

pgj commented 7 months ago

Hi @karlgrose, thanks for calling my attention to this problem! That is a curious use case that has managed to escape my attention so far, but it is completely valid. The primary purpose of the VMM_KO variable used to be supporting the use of custom-built vmm kernel modules (such as the one that bhyve+ offered).

On the other hand, as you have also explored this in your workaround, the wifibox script allows overriding of VMM_KO from the environment as an implicit extensibility measure and as part of a better code structure. Due to the support for bhyve+, version 0.12.0 of the net/wifibox-core port can also control the VMM_KO variable because the default of this came from the Makefile. That latter is now gone by the recent changes about sunsetting the byhve+ support but it could be restored to keep providing support for this scenario.

That said, I believe the workaround of yours can be improved by setting the value of the VMM_KO on the installation of net/wifibox-core:

# make install VMM_KO=$(sysctl -n kern.module_path | cut -d ';' -f 1)/vmm.ko

But I think it is possible to go further with this and teach the wifibox script how to find vmm.ko for itself automatically, so no workaround would be needed at all.

pgj commented 7 months ago

@karlgrose did the approach work for you that I suggested in my previous comment?

karlgrose commented 7 months ago

As a test, removing the /etc/rc.conf.d/wifibox file and then directly modifying the wifibox script itself to start with a smarter initial value for VMM_KO:

: "${VMM_KO:=$(sysctl -n kern.module_path | cut -d ';' -f 1)/vmm.ko}"

did allow it to run with both of the latest 15.0-CURRENT kernels in question. I have also locked the wifibox-1.3.0 package on my systems to keep this version for now.

pgj commented 7 months ago

Okay, thanks for the confirmation. I will create a fix for this problem, so you will get this feature in the next version.

pgj commented 7 months ago

I have created an updated version of the net/wifibox-core port, please test it: https://github.com/pgj/freebsd-wifibox-port/tree/wifibox-core/update-20240306 .

karlgrose commented 7 months ago

I installed this update-20240306 version of wifibox-core and had no issues whether using the standard or alternative 15.0-CURRENT kernel. Thanks for the fix.