git: 06dfe625ddce - main - net/wireguard-tools: Fix route monitor on FreeBSD 14
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 29 Sep 2025 12:14:38 UTC
The branch main has been updated by grembo:
URL: https://cgit.FreeBSD.org/ports/commit/?id=06dfe625ddce3df823fc392c60c81881c36d13a1
commit 06dfe625ddce3df823fc392c60c81881c36d13a1
Author: Michael Gmelin <grembo@FreeBSD.org>
AuthorDate: 2025-09-26 11:00:55 +0000
Commit: Michael Gmelin <grembo@FreeBSD.org>
CommitDate: 2025-09-29 12:14:18 +0000
net/wireguard-tools: Fix route monitor on FreeBSD 14
PR: 275026
Reported by: Vedran Miletic <vedran@miletic.net>
Approved by: decke (maintainer)
Co-authored-by: Oleg Streejak <oleg@pcbtech.ru>
---
net/wireguard-tools/Makefile | 2 +-
.../files/patch-wg-quick_freebsd.bash | 43 ++++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/net/wireguard-tools/Makefile b/net/wireguard-tools/Makefile
index cd97a43099f5..b80a0cbe8e5b 100644
--- a/net/wireguard-tools/Makefile
+++ b/net/wireguard-tools/Makefile
@@ -1,6 +1,6 @@
PORTNAME= wireguard-tools
PORTVERSION= 1.0.20210914
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= net net-vpn
MASTER_SITES= https://git.zx2c4.com/wireguard-tools/snapshot/
diff --git a/net/wireguard-tools/files/patch-wg-quick_freebsd.bash b/net/wireguard-tools/files/patch-wg-quick_freebsd.bash
new file mode 100644
index 000000000000..83254d7abac3
--- /dev/null
+++ b/net/wireguard-tools/files/patch-wg-quick_freebsd.bash
@@ -0,0 +1,43 @@
+--- wg-quick/freebsd.bash.orig 2021-09-13 22:43:31 UTC
++++ wg-quick/freebsd.bash
+@@ -27,6 +27,7 @@ SAVE_CONFIG=0
+ CONFIG_FILE=""
+ PROGRAM="${0##*/}"
+ ARGS=( "$@" )
++FREEBSD_MAJOR_VERSION=$(freebsd-version | cut -d. -f1)
+
+ cmd() {
+ echo "[#] $*" >&3
+@@ -283,20 +284,28 @@ monitor_daemon() {
+ echo "[+] Backgrounding route monitor" >&2
+ (make_temp
+ trap 'del_routes; clean_temp; exit 0' INT TERM EXIT
++ local event grep_for pid
++ if [[ "$FREEBSD_MAJOR_VERSION" -lt 14 ]]; then
++ grep_for="RTM_"
++ elif [[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]]; then
++ grep_for="iface" # needs refinement
++ else
++ grep_for="(add/repl|delete) iface iface#[0-9]{1,4} $INTERFACE "
++ fi
+ exec >/dev/null 2>&1
+- exec 19< <(exec route -n monitor)
+- local event pid=$!
++ exec 19< <(exec sh -c "route -n monitor | grep -E --line-buffered '$grep_for'")
++ monitor_ppid=$!
+ # TODO: this should also check to see if the endpoint actually changes
+ # in response to incoming packets, and then call set_endpoint_direct_route
+ # then too. That function should be able to gracefully cleanup if the
+ # endpoints change.
+ while read -u 19 -r event; do
+- [[ $event == RTM_* ]] || continue
+ ifconfig "$INTERFACE" >/dev/null 2>&1 || break
+ [[ $AUTO_ROUTE4 -eq 1 || $AUTO_ROUTE6 -eq 1 ]] && set_endpoint_direct_route
+ # TODO: set the mtu as well, but only if up
+ done
+- kill $pid) & disown
++ pkill -P "$monitor_ppid" route || true
++ ) & disown
+ }
+
+ HAVE_SET_DNS=0