From a0d5736e11e1e70189393fc8803c2c1500c87d3e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 15 May 2018 23:12:15 +0200 Subject: wg-quick: darwin: remove v6 routes after shutdown This works around a Darwin kernel bug regarding interface removal. --- src/tools/wg-quick/darwin.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/wg-quick/darwin.bash b/src/tools/wg-quick/darwin.bash index 0c28085..ca7e901 100755 --- a/src/tools/wg-quick/darwin.bash +++ b/src/tools/wg-quick/darwin.bash @@ -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 -- cgit v1.2.3-59-g8ed1b