]> www.infradead.org Git - users/dwmw2/vpnc-scripts.git/commitdiff
Add DragonFly BSD support and improve FreeBSD support
authorAaron LI <aly@aaronly.me>
Sun, 13 Dec 2020 08:38:38 +0000 (16:38 +0800)
committerDaniel Lenski <dlenski@gmail.com>
Thu, 17 Dec 2020 00:26:19 +0000 (16:26 -0800)
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 <aly@aaronly.me>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
vpnc-script

index 7c52fdd20916f67bf02e56e25e392f713096fc8a..2de0c61877c45a82758abe65b5eb63ae05aa5c78 100755 (executable)
@@ -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