]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg-quick: darwin: remove v6 routes after shutdown
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 15 May 2018 21:12:15 +0000 (23:12 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 16 May 2018 02:05:04 +0000 (04:05 +0200)
This works around a Darwin kernel bug regarding interface removal.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/wg-quick/darwin.bash

index 0c28085bda515bfe25358e0046e7e5baa9c4d6be..ca7e901b9de171dbb39c83265af76a08eeb54b4a 100755 (executable)
@@ -106,7 +106,7 @@ add_if() {
 }
 
 del_routes() {
-       local todelete=( ) destination netif
+       local todelete=( ) destination gateway netif
        while read -r destination _ _ _ _ netif _; do
                [[ $netif == "$REAL_INTERFACE" ]] && todelete+=( "$destination" )
        done < <(netstat -nr -f inet)
@@ -114,8 +114,8 @@ del_routes() {
                cmd route -q delete -inet "$destination" >/dev/null || true
        done
        todelete=( )
-       while read -r destination _ _ netif; do
-               [[ $netif == "$REAL_INTERFACE" ]] && todelete+=( "$destination" )
+       while read -r destination gateway _ netif; do
+               [[ $netif == "$REAL_INTERFACE" || ( $netif == lo* && $gateway == "$REAL_INTERFACE" ) ]] && todelete+=( "$destination" )
        done < <(netstat -nr -f inet6)
        for destination in "${todelete[@]}"; do
                cmd route -q delete -inet6 "$destination" >/dev/null || true