Index: head/net/wireguard-tools/Makefile =================================================================== --- head/net/wireguard-tools/Makefile (revision 569183) +++ head/net/wireguard-tools/Makefile (revision 569184) @@ -1,52 +1,52 @@ # $FreeBSD$ PORTNAME= wireguard-tools PORTVERSION= 1.0.20210315 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net net-vpn MASTER_SITES= https://git.zx2c4.com/wireguard-tools/snapshot/ MAINTAINER= decke@FreeBSD.org COMMENT= Fast, modern and secure VPN Tunnel LICENSE= GPLv2 LICENSE_FILE= ${WRKDIR}/${DISTNAME}/COPYING FLAVORS= default lite lite_PKGNAMESUFFIX= -lite USES= gmake tar:xz WRKSRC= ${WRKDIR}/${DISTNAME}/src MAKE_ARGS+= DEBUG=no WITH_BASHCOMPLETION=yes WITH_SYSTEMDUNITS=no MAKE_ENV+= MANDIR="${MANPREFIX}/man" \ SYSCONFDIR="${PREFIX}/etc" OPTIONS_DEFINE= WGQUICK OPTIONS_DEFAULT=WGQUICK OPTIONS_SUB= yes WGQUICK_DESC= wg-quick(8) userland utility WGQUICK_RUN_DEPENDS= bash:shells/bash WGQUICK_MAKE_ARGS= WITH_WGQUICK=yes WGQUICK_MAKE_ARGS_OFF= WITH_WGQUICK=no .if ${FLAVOR:U} == lite USE_RC_SUBR= wireguard_lite OPTIONS_EXCLUDE=WGQUICK COMMENT+= (lite flavor) .endif .include .if ${PORT_OPTIONS:MWGQUICK} USE_RC_SUBR= wireguard_wgquick .endif post-patch: @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \ ${WRKSRC}/completion/wg-quick.bash-completion \ ${WRKSRC}/wg-quick/freebsd.bash .include Index: head/net/wireguard-tools/files/wireguard_lite.in =================================================================== --- head/net/wireguard-tools/files/wireguard_lite.in (revision 569183) +++ head/net/wireguard-tools/files/wireguard_lite.in (revision 569184) @@ -1,98 +1,105 @@ #!/bin/sh # $FreeBSD$ # # PROVIDE: wireguard # REQUIRE: DAEMON # KEYWORD: shutdown # # wireguard_enable (bool): Set to "YES" to enable wireguard. # (default: "NO") # # wireguard_interfaces (str): List of interfaces to bring up/down # on start/stop. (eg: "wg0 wg1") # (default: "") # wireguard__ips (str): List of IP Addresses for iface # wireguard__routes (str): List of Routes for this iface # wireguard__mtu (str): MTU for iface (default: "1500") . /etc/rc.subr load_rc_config $name : ${wireguard_enable="NO"} : ${wireguard_interfaces=""} name=wireguard rcvar=wireguard_enable extra_commands="reload" start_cmd="${name}_start" stop_cmd="${name}_stop" reload_cmd="${name}_reload" wireguard_start() { for interface in ${wireguard_interfaces}; do load_rc_config wireguard_${interface} eval wireguard_ips="\${wireguard_${interface}_ips}" eval wireguard_routes="\${wireguard_${interface}_routes}" eval wireguard_mtu="\${wireguard_${interface}_mtu}" ifconfig ${interface} create %%PREFIX%%/bin/wg setconf ${interface} %%PREFIX%%/etc/wireguard/${interface}.conf for ip in ${wireguard_ips}; do if [ "${ip#*:}" != "${ip}" ]; then ifconfig ${interface} inet6 ${ip} alias else ifconfig ${interface} inet ${ip} alias fi done if [ ! -z "${wireguard_mtu}" ]; then ifconfig ${interface} mtu ${wireguard_mtu} fi ifconfig ${interface} up for route in ${wireguard_routes}; do if [ "${route#*:}" != "${route}" ]; then route -q -n add -inet6 ${route} -interface ${interface} else route -q -n add -inet ${route} -interface ${interface} fi done done } wireguard_stop() { for interface in ${wireguard_interfaces}; do load_rc_config wireguard_${interface} eval wireguard_routes="\${wireguard_${interface}_routes}" for route in ${wireguard_routes}; do if [ "${route#*:}" != "${route}" ]; then route -q -n delete -inet6 ${route} -interface ${interface} else route -q -n delete -inet ${route} -interface ${interface} fi done ifconfig ${interface} down ifconfig ${interface} destroy done + + if kldstat -q -n if_wg; then + if ! kldunload if_wg > /dev/null 2>&1; then + warn "Can't unload if_wg module." + return 1 + fi + fi } wireguard_reload() { for interface in ${wireguard_interfaces}; do %%PREFIX%%/bin/wg syncconf ${interface} %%PREFIX%%/etc/wireguard/${interface}.conf done } run_rc_command "$1" Index: head/net/wireguard-tools/files/wireguard_wgquick.in =================================================================== --- head/net/wireguard-tools/files/wireguard_wgquick.in (revision 569183) +++ head/net/wireguard-tools/files/wireguard_wgquick.in (revision 569184) @@ -1,62 +1,69 @@ #!/bin/sh # $FreeBSD$ # # PROVIDE: wireguard # REQUIRE: DAEMON # KEYWORD: shutdown # # wireguard_enable (bool): Set to "YES" to enable wireguard. # (default: "NO") # # wireguard_interfaces (str): List of interfaces to bring up/down # on start/stop. (eg: "wg0 wg1") # (default: "") # wireguard_env (str): Environment variables for the userspace # implementation. (eg: "LOG_LEVEL=debug") . /etc/rc.subr name=wireguard rcvar=wireguard_enable extra_commands="reload" start_cmd="${name}_start" stop_cmd="${name}_stop" reload_cmd="${name}_reload" wireguard_start() { ${wireguard_env:+eval export $wireguard_env} for interface in ${wireguard_interfaces}; do %%PREFIX%%/bin/wg-quick up ${interface} done } wireguard_stop() { for interface in ${wireguard_interfaces}; do %%PREFIX%%/bin/wg-quick down ${interface} done + + if kldstat -q -n if_wg; then + if ! kldunload if_wg > /dev/null 2>&1; then + warn "Can't unload if_wg module." + return 1 + fi + fi } wireguard_reload() { ${wireguard_env:+eval export $wireguard_env} for interface in ${wireguard_interfaces}; do tmpfile="`mktemp`" %%PREFIX%%/bin/wg-quick strip ${interface} > ${tmpfile} %%PREFIX%%/bin/wg syncconf ${interface} ${tmpfile} rm -f ${tmpfile} done } load_rc_config $name : ${wireguard_enable="NO"} : ${wireguard_interfaces=""} : ${wireguard_env=""} run_rc_command "$1"