From 52f17a899d8a92e1e1260db30f84608af774107a Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 21 May 2023 16:29:13 +0200 Subject: network: remove routes on stopping ipv6 routes tend to stay even after stopping, so better always remove routes of devices being stopped. --- sbin/init.d/network | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sbin/init.d/network b/sbin/init.d/network index 7ca2180..f0566bf 100755 --- a/sbin/init.d/network +++ b/sbin/init.d/network @@ -972,6 +972,32 @@ function do_stop { fi rm -f "/var/run/wpa_supplicant-${instname}.conf" + arg=0 + while [ $arg -lt $route6_idx ]; do + local dest gw + dest=${route6_list[$arg]%%[ ]*} + gw=${route6_list[$arg]#*[ ]} # gw and potentially other ip args + if [ -n "${gw##connected*}" ]; then + ip -6 route del $dest ${instname:+dev $instname} via $gw >/dev/null 2>&1 + else + ip -6 route del $dest ${instname:+dev $instname} ${gw#connected} >/dev/null 2>&1 + fi + arg=$[$arg+1] + done + + arg=0 + while [ $arg -lt $route_idx ]; do + local dest gw + dest=${route_list[$arg]%%[ ]*} + gw=${route_list[$arg]#*[ ]} # gw and potentially other ip args + if [ -n "${gw##connected*}" ]; then + ip route del $dest ${instname:+dev $instname} via $gw >/dev/null 2>&1 + else + ip route del $dest ${instname:+dev $instname} ${gw#connected} >/dev/null 2>&1 + fi + arg=$[$arg+1] + done + ip link set $instname down >/dev/null 2>&1 ip addr flush dev $instname >/dev/null 2>&1 -- 2.35.3