Bug 254607

Summary: net/wireguard-tools: patch-wg-quick_freebsd.bash-2 cause "Destination address required"
Product: Ports & Packages Reporter: Koichiro Iwao <meta>
Component: Individual Port(s)Assignee: Bernhard Froehlich <decke>
Status: Closed Works As Intended    
Severity: Affects Only Me CC: decke, meta
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description Koichiro Iwao freebsd_committer freebsd_triage 2021-03-27 17:55:39 UTC
Hi, 

after recent addition of patch-wg-quick_freebsd.bash-2 broke it. Did you actually test it?

# pkg info|grep wireguard
wireguard-2,1                  Meta-port for Wireguard
wireguard-go-0.0.20210323,1    WireGuard implementation in Go
wireguard-kmod-0.0.20210323    WireGuard implementation for the FreeBSD kernel
wireguard-tools-1.0.20210315_3 Fast, modern and secure VPN Tunnel

# wg-quick up wg0
[#] ifconfig wg create name wgs
[#] wg setconf wg0 /dev/stdin
[#] ifconfig wg0 inet 192.168.30.235 alias
ifconfig: ioctl (SIOCAIFADDR): Destination address required
[#] ifconfig wg0 destroy


wireguard-tools-1.0.20210315_2 was working properly. 

Simple instructions to reproduce:
1. ifconfig wg create name wg0
2. ifconfig wg0 inet 192.168.1.2 alias
3. ifconfig fails with "ifconfig: ioctl (SIOCAIFADDR): Destination address required"


I think the removed argument "${1%%/*}" is necessary. It is the destination address. I haven't test it at FreeBSD 13 but at least patch-wg-quick_freebsd.bash-2 must not be applied on FreeBSD 12.

This works:
ifconfig "$INTERFACE" inet "$1" "${1%%/*}" alias

but his doesn't work actually:
ifconfig "$INTERFACE" inet "$1" alias
Comment 1 Bernhard Froehlich freebsd_committer freebsd_triage 2021-03-27 19:37:53 UTC
For comparison this is the output that I have:

[#] ifconfig wg create name wg0
[#] wg setconf wg0 /dev/stdin
[#] ifconfig wg0 inet 10.1.1.1/24 alias
[#] ifconfig wg0 inet6 2001:470:7527:1111::1/64 alias
[#] ifconfig wg0 mtu 1360
[#] ifconfig wg0 up
...

It makes me believe that your wg0.conf is wrong. This is the beginning of the interface section:

[Interface]
Address = 10.1.1.1/24,2001:470:7527:1111::1/64


Please check that your Address entries need to be subnets.
Comment 2 Koichiro Iwao freebsd_committer freebsd_triage 2021-03-28 04:26:01 UTC
(In reply to Bernhard Froehlich from comment #1)
Hmmm, I don't think my config is wrong. Definitely, the config worked with wireguard-tools-1.0.20210315_2 but don't work with wireguard-tools-1.0.20210315_3. 


Simply, even not using wg-quick but running ifconfig commands picked up your wg output directly didn't work.

icepick# ifconfig wg create name wg0
wg0
icepick# ifconfig wg0 inet 10.1.1.1/24 alias
ifconfig: ioctl (SIOCAIFADDR): Destination address required
icepick# 


> [#] ifconfig wg0 inet 10.1.1.1/24 alias
So, this command requires a destination address.  One more argument is required but oddly it is removed from wg-quick.


FYI, this is my config.


[Interface]
Address = 192.168.30.235/24
PrivateKey = 
[Peer]
PublicKey = 
PresharedKey = 
AllowedIps = 192.168.30.0/24
Endpoint = server:12345
PersistentKeepAlive = 25
Comment 3 Koichiro Iwao freebsd_committer freebsd_triage 2021-03-28 04:36:36 UTC
My bad, reloading the kernel module solved the issue. 

I'm not using WireGuard with rc scripts. I'm just using with only wg-quick. The kernel module is not auto reloaded in such a situation.