aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/wg-quick/freebsd.bash
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-04-18 20:40:02 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2021-04-18 20:40:02 -0600
commit3124afbea3c7e04e89ad98db4d1d621f491b531a (patch)
treed1b041693e74f36d133e6ea3d22fc4c320bde6fb /src/wg-quick/freebsd.bash
parentwg-quick: freebsd: do not assume point-to-point interface flag (diff)
downloadwireguard-tools-3124afbea3c7e04e89ad98db4d1d621f491b531a.tar.xz
wireguard-tools-3124afbea3c7e04e89ad98db4d1d621f491b531a.zip
wg-quick: freebsd: use ifconfig for determining if interface is up
We no longer need the arp hack, as these bugs have been fixed in the FreeBSD kernel. This partially reverts 090639ae90fb45ac05e3158e1e31e5bf15fd9559. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rwxr-xr-xsrc/wg-quick/freebsd.bash18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/wg-quick/freebsd.bash b/src/wg-quick/freebsd.bash
index e00f1e1..e731384 100755
--- a/src/wg-quick/freebsd.bash
+++ b/src/wg-quick/freebsd.bash
@@ -152,20 +152,6 @@ del_routes() {
done
}
-if_exists() {
- # HACK: The goal is simply to determine whether or not the interface exists. The
- # straight-forward way of doing this would be `ifconfig $INTERFACE`, but this
- # invokes the SIOCGIFSTATUS ioctl, which races with interface shutdown inside
- # the tun driver, resulting in a kernel panic. So we work around it the stupid
- # way by using the one utility that appears to call if_nametoindex fairly early
- # and fails if it doesn't exist: `arp`.
- if arp -i "$INTERFACE" -a -n >/dev/null 2>&1; then
- return 0
- else
- return 1
- fi
-}
-
del_if() {
[[ $HAVE_SET_DNS -eq 0 ]] || unset_dns
if [[ -S /var/run/wireguard/$INTERFACE.sock ]]; then
@@ -173,7 +159,7 @@ del_if() {
else
cmd ifconfig "$INTERFACE" destroy
fi
- while if_exists; do
+ while ifconfig "$INTERFACE" >/dev/null 2>&1; do
# HACK: it would be nice to `route monitor` here and wait for RTM_IFANNOUNCE
# but it turns out that the announcement is made before the interface
# disappears so we sometimes get a hang. So, we're instead left with polling
@@ -305,7 +291,7 @@ monitor_daemon() {
# endpoints change.
while read -r event; do
[[ $event == RTM_* ]] || continue
- if_exists || break
+ 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 < <(route -n monitor)) & disown