From e4294f2ffaf7727af106a8ed9c1f49e3d5125f9a Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 13 Dec 2020 16:38:38 +0800 Subject: [PATCH] Add DragonFly BSD support and improve FreeBSD support Support DragonFly BSD for TUN creation and destroy in the same way as FreeBSD. No need to load the `if_tun` kernel module, because the `ifconfig(8)` utility on FreeBSD and DragonFly BSD will auto load it if necessary (the `-n` option suppresses this behavior; see man page for details). This feature was added to `ifconfig(8)` in 1999: https://github.com/freebsd/freebsd/commit/4d16916f800d4c5ee37fb3c93ca6981ad9b33eb3 In addition, FreeBSD 13 has merged `if_tun` and `if_tap` into a single module named `if_tuntap`. So this change improves the FreeBSD support. Signed-off-by: Aaron LI Signed-off-by: Daniel Lenski --- vpnc-script | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vpnc-script b/vpnc-script index 7c52fdd..2de0c61 100755 --- a/vpnc-script +++ b/vpnc-script @@ -157,7 +157,7 @@ elif [ -x /usr/bin/busctl ] && [ ${RESOLVEDENABLED} = 1 ]; then MODIFYRESOLVCONF=modify_resolved_manager_old RESTORERESOLVCONF=restore_resolved_manager_old elif [ -x /sbin/resolvconf ] && [ "`basename $(readlink /sbin/resolvconf) 2> /dev/null`" != resolvectl ]; then - # Optional tool on Debian, Ubuntu, Gentoo and FreeBSD + # Optional tool on Debian, Ubuntu, Gentoo, FreeBSD and DragonFly BSD # (ignored if symlink to resolvctl, created by some versions of systemd-resolved) MODIFYRESOLVCONF=modify_resolvconf_manager RESTORERESOLVCONF=restore_resolvconf_manager @@ -245,7 +245,7 @@ destroy_tun_device() { NetBSD|OpenBSD) # and probably others... ifconfig "$TUNDEV" destroy ;; - FreeBSD) + FreeBSD|DragonFly) ifconfig "$TUNDEV" destroy > /dev/null 2>&1 & ;; esac @@ -919,11 +919,7 @@ do_pre_init() { done fi fi - elif [ "$OS" = "FreeBSD" ]; then - if ! kldstat -q -m if_tun > /dev/null; then - kldload if_tun - fi - + elif [ "$OS" = "FreeBSD" -o "$OS" = "DragonFly" ]; then if ! ifconfig $TUNDEV > /dev/null; then ifconfig $TUNDEV create fi -- 2.50.1