From b52b08df5b63d7f1d66ebfcab5e541bf61a3ee60 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 11 Jun 2017 23:39:17 +0200 Subject: wg-quick: make sure we have empty table for both v6 and v4 Otherwise, we wind up not doing the right thing in the v6-only case, or doing something totally borked when v4 and v6 are filled unevenly. Reported-by: Roelf Wichertjes --- src/tools/wg-quick.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/wg-quick.bash b/src/tools/wg-quick.bash index a4f349a..75050fd 100755 --- a/src/tools/wg-quick.bash +++ b/src/tools/wg-quick.bash @@ -141,7 +141,9 @@ DEFAULT_TABLE= add_default() { if [[ -z $DEFAULT_TABLE ]]; then DEFAULT_TABLE=51820 - while [[ -n $(ip route show table $DEFAULT_TABLE) ]]; do ((DEFAULT_TABLE++)); done + while [[ -n $(ip -4 route show table $DEFAULT_TABLE) || -n $(ip -6 route show table $DEFAULT_TABLE) ]]; do + ((DEFAULT_TABLE++)) + done fi local proto=-4 src ip if [[ $1 == *:* ]]; then -- cgit v1.2.3-59-g8ed1b