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