Wireguard fails when using IPv6 addresses

Describe your issue

When trying to use wireguard, the default with IPv6, it fails on wg-quick up. This does not happen when IP addresses in the config are only IPv4.

What's the expected behavior?

Wireguard works with IPv6.

What's the current behavior?

Wireguard fails on step ip -6 rule add not fwmark 51820 table 51820 with error RTNETLINK answers: Not supported (more detail below)

How to reproduce your issue?

sudo apk add wireguard-tools
sudo modprobe wireguard

create file /etc/wireguard/wg0-client.conf:

[Interface]
Address = 10.0.0.4/32, 2a00:5:abcd:1234::4/128
PrivateKey = yM2ajamtC3UejR1FFXqkgy2d1FqEJLe5VJIFrFn6yFM=

[Peer]
PublicKey = VkK4mGNfWlsjDBOSWkljTatCZ0CBIpHQ9Gf3bPTm2SI=
Endpoint = 192.168.1.2:51820
AllowedIPs = 0.0.0.0/0,::/0

and run:

sudo wg-quick up wg0-client
[#] ip link add wg0-client type wireguard
[#] wg setconf wg0-client /dev/fd/63
[#] ip -4 address add 10.0.0.4/32 dev wg0-client
[#] ip -6 address add 2a00:5:abcd:1234::4/128 dev wg0-client
[#] ip link set mtu 1420 up dev wg0-client
[#] wg set wg0-client fwmark 51820
[#] ip -6 route add ::/0 dev wg0-client table 51820
[#] ip -6 rule add not fwmark 51820 table 51820
RTNETLINK answers: Not supported
[#] ip link delete dev wg0-client

I suspect something with IPv6 isn't enabled in the kernel config, maybe CONFIG_IP6_NF_MATCH_IPV6HEADER?

What device are you using?

Pinephone CE postmarketOS edition 3GB/32GB

On what postmarketOS version did you encounter the issue?

  • edge (master branch)
  • stable (v20.05 branch)

On what environment did you encounter the issue?

Phone environments

  • Phosh
  • Plasma Mobile
  • Sxmo

How did you get postmarketOS image?

What's the build date of the image? (in dd-mm-yyyy format)

2020-09-17

Additional information

Wireguard module should be enabled:

pine64-pinephone:~$ lsmod | head
Module                  Size  Used by
wireguard              86016  0
libchacha20poly1305    16384  1 wireguard
chacha_neon            24576  1 libchacha20poly1305
poly1305_neon          20480  1 libchacha20poly1305
ip6_udp_tunnel         16384  1 wireguard
udp_tunnel             16384  1 wireguard
libcurve25519_generic    40960  1 wireguard
libblake2s             16384  1 wireguard
libblake2s_generic     20480  1 libblake2s