Bug 254328 - net/wireguard: after update to the latest revision it waits forever if service is stopped/restarted
Summary: net/wireguard: after update to the latest revision it waits forever if servic...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Only Me
Assignee: Bernhard Froehlich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-16 07:55 UTC by Oleg Streejak
Modified: 2021-03-23 22:01 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (decke)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Streejak 2021-03-16 07:55:13 UTC
After update to the latest revision it waits forever if service is  stopped/restarted:

# service wireguard restart
[#] ifconfig wg0 destroy
load: 0.21  cmd: ifconfig 4128 [tun_condvar] 25.06r 0.00u 0.00s 0% 2036k
load: 0.08  cmd: ifconfig 4128 [tun_condvar] 231.71r 0.00u 0.00s 0% 1784k
load: 0.01  cmd: ifconfig 4128 [tun_condvar] 471.35r 0.00u 0.00s 0% 1784k
load: 0.06  cmd: ifconfig 4128 [tun_condvar] 654.40r 0.00u 0.00s 0% 1784k

the ways to restart wireguard are: a) full reboot and b) kill the pid that owns the wg0:

# service wireguard restart
[#] ifconfig wg0 destroy
load: 0.21  cmd: ifconfig 4128 [tun_condvar] 25.06r 0.00u 0.00s 0% 2036k
load: 0.08  cmd: ifconfig 4128 [tun_condvar] 231.71r 0.00u 0.00s 0% 1784k
load: 0.01  cmd: ifconfig 4128 [tun_condvar] 471.35r 0.00u 0.00s 0% 1784k
load: 0.06  cmd: ifconfig 4128 [tun_condvar] 654.40r 0.00u 0.00s 0% 1784k
^Z
Suspended
# bg
[1]    service wireguard restart &
# ifconfig wg0
wg0: flags=8011<UP,POINTOPOINT,MULTICAST> metric 0 mtu 1420
	options=80000<LINKSTATE>
	nd6 options=101<PERFORMNUD,NO_DAD>
	Opened by PID 716
# kill 716
# [#] ifconfig wg create name wg0
[!] Missing WireGuard kernel support (ifconfig: SIOCIFCREATE2: Invalid argument). Falling back to slow userspace implementation.
[#] wireguard-go wg0
[#] wg setconf wg0 /dev/stdin
[#] ifconfig wg0 mtu 1420
[#] ifconfig wg0 up
[#] route -q -n add -inet 192.168.0.107/32 -interface wg0
[#] route -q -n add -inet 192.168.0.106/32 -interface wg0
[#] route -q -n add -inet 192.168.0.101/32 -interface wg0
[+] Backgrounding route monitor

[1]    Done                          service wireguard restart

Fortunately while it waits to be destroy the tunnel is still working

FreeBSD 12.2-RELEASE-p4 GENERIC  i386
Comment 1 Matt Smith 2021-03-16 10:06:16 UTC
I see the same on 13.0-RC2. You can get the service to cleanly exit by deleting the /var/run/wireguard/wg0.sock file which suggests that something is waiting for wireguard-go to exit?
Comment 2 Oleg Streejak 2021-03-16 10:15:06 UTC
(In reply to Matt Smith from comment #1)

yes, that works also:

# service wireguard restart & ; sleep 3; rm /var/run/wireguard/wg0.sock
[1] 17017
[#] ifconfig wg0 destroy
# [#] ifconfig wg create name wg0
[!] Missing WireGuard kernel support (ifconfig: SIOCIFCREATE2: Invalid argument). Falling back to slow userspace implementation.
[#] wireguard-go wg0
[#] wg setconf wg0 /dev/stdin
[#] ifconfig wg0 mtu 1420
[#] ifconfig wg0 up
[#] route -q -n add -inet 192.168.0.107/32 -interface wg0
[#] route -q -n add -inet 192.168.0.106/32 -interface wg0
[#] route -q -n add -inet 192.168.0.101/32 -interface wg0
[+] Backgrounding route monitor

[1]    Done                          service wireguard restart
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2021-03-16 10:41:05 UTC
^Triage: give this a more useful Summary.
Comment 4 commit-hook freebsd_committer freebsd_triage 2021-03-23 19:59:57 UTC
A commit references this bug:

Author: decke
Date: Tue Mar 23 19:59:44 UTC 2021
New revision: 569057
URL: https://svnweb.freebsd.org/changeset/ports/569057

Log:
  net/wireguard-tools: Add patches to fix hang at stop/restart

  PR:		254328
  Submitted by:	Jason A. Donenfeld <Jason@zx2c4.com>
  Reported by:	Oleg Strizhak <oleg@pcbtech.ru>

Changes:
  head/net/wireguard-tools/Makefile
  head/net/wireguard-tools/files/patch-wg-quick_freebsd.bash-1
  head/net/wireguard-tools/files/patch-wg-quick_freebsd.bash-2
Comment 5 Bernhard Froehlich freebsd_committer freebsd_triage 2021-03-23 20:00:09 UTC
Fixed. Thanks!
Comment 6 Oleg Streejak 2021-03-23 22:01:28 UTC
Thank you a lot!