openlumi / openlumi.github.io

OpenWrt for Xiaomi Zigbee gateway with imx6 SoC DGNWG05LM, ZHWG11LM
https://openlumi.github.io
154 stars 26 forks source link

WireGuard #13

Closed dvv closed 3 years ago

dvv commented 3 years ago

Can not manage to start wireguard:

$ logread -f
...
Sat Feb 27 16:54:37 2021 daemon.err modprobe: 1 module could not be probed
Sat Feb 27 16:54:37 2021 daemon.err modprobe: - wireguard
Sat Feb 27 16:54:37 2021 kern.warn kernel: [15463.933661] wireguard: Unknown symbol dst_cache_set_ip4 (err 0)
Sat Feb 27 16:54:37 2021 kern.warn kernel: [15463.933976] wireguard: Unknown symbol dst_cache_destroy (err 0)
Sat Feb 27 16:54:37 2021 kern.warn kernel: [15463.934128] wireguard: Unknown symbol dst_cache_init (err 0)
Sat Feb 27 16:54:37 2021 kern.warn kernel: [15463.934777] wireguard: Unknown symbol dst_cache_get_ip6 (err 0)
Sat Feb 27 16:54:37 2021 kern.warn kernel: [15463.934884] wireguard: Unknown symbol dst_cache_get_ip4 (err 0)
Sat Feb 27 16:54:37 2021 kern.warn kernel: [15463.935012] wireguard: Unknown symbol dst_cache_set_ip6 (err 0)
Sat Feb 27 16:54:37 2021 daemon.notice netifd: wg0 (15885): Unable to modify interface: Protocol not supported
...
$ cat /etc/openwrt_release 
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='19.07.7'
DISTRIB_REVISION='r11306-c4a6851c72'
DISTRIB_TARGET='imx6/generic'
DISTRIB_ARCH='arm_cortex-a9_neon'
DISTRIB_DESCRIPTION='OpenWrt 19.07.7 r11306-c4a6851c72'
DISTRIB_TAINTS='no-all'
$ uname -a
Linux mihome 4.14.221 #0 SMP Mon Feb 15 15:22:37 2021 armv7l GNU/Linux
$ lsmod | egrep '(wire|tunnel)'
ip6_udp_tunnel         16384  0 
udp_tunnel             16384  0
devbis commented 3 years ago

You have to compile OpenWrt by yourself and enable the required kernel modules in the firmware. Otherwise, some kernel modules may cause issues.

Sources for the OpenWrt 19.07 are located here: https://github.com/openlumi/openwrt/tree/lumi-19.07

dvv commented 3 years ago

On my router:

$ uname -a
Linux home 4.14.167 #0 SMP Wed Jan 29 16:05:35 2020 mips GNU/Linux

gives

$ lsmod | egrep '(wire|tunnel)'
ip6_udp_tunnel          1600  1 wireguard
udp_tunnel              2432  1 wireguard
wireguard              90560  0

so all the required kernel modules already do exist in this firmware.

It's a matter of some missing kernel feature. I believe select DST_CACHE should go ( mentioned https://lore.kernel.org/patchwork/patch/880428/ )

I can not afford building the world. May some be interested.

devbis commented 3 years ago

The modules that exist in firmware depends on the config for building. It may include some modules, may not. We tried to keep the image small and did not include most of the kernel modules that are not required for basic gateway usage. Here is the config I used for the build: https://github.com/openlumi/openwrt/blob/lumi-19.07/config_xiaomi_lumi

dvv commented 3 years ago

I see.

Look at what we've got:

$ modinfo wireguard
module:         /lib/modules/4.14.221/wireguard.ko
intree:         Y
alias:          net-pf-16-proto-16-family-wireguard
alias:          rtnl-link-wireguard
license:        GPL v2
depends:        udp_tunnel,ip6_udp_tunnel

$ modinfo udp_tunnel
module:         /lib/modules/4.14.221/udp_tunnel.ko
license:        GPL
depends:

$ modinfo ip6_udp_tunnel
module:         /lib/modules/4.14.221/ip6_udp_tunnel.ko
license:        GPL
depends:

So I conclude that the missing symbols are to be in the shipped kernel per se.

dvv commented 3 years ago

@devbis Am I right that the following will give me exact config that you have?

git clone --depth 1 -b lumi-19.07 https://github.com/openlumi/openwrt
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
cp config_xiaomi_lumi .config
ln -s files_xiaomi_lumi files
make menuconfig
dvv commented 3 years ago

Built, sysupgrade-d, got a brick... ) Suspecting WiFi drivers

devbis commented 3 years ago

Oh, you've missed one essential step.

files_xiaomi_lumi should be renamed to files or make a symlink with files name.

You could try to restore availability by copying the content to /lib/* files through serial console.

dvv commented 3 years ago

Thank you. Revived. That comment ^^^ should go to readme imho.