From f68ac2636c9129984600257b059d38018877244f Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Sat, 11 Aug 2018 19:03:54 +0100 Subject: Flush and down interface if configuration fails Signed-off-by: Robby Workman --- rc.inet1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rc.inet1 b/rc.inet1 index 1f5fc45..a606205 100644 --- a/rc.inet1 +++ b/rc.inet1 @@ -198,6 +198,8 @@ if_up() { IF_UP=1 else echo "/etc/rc.d/rc.inet1: failed to obtain DHCP lease for ${1}" | $LOGGER + /sbin/ip address flush dev ${1} + /sbin/ip link set dev ${1} down fi fi if [ "${USE_DHCP[$i]}" != "yes" ] && [ -n "${IPADDR[$i]}" ]; then # add a fixed v4 IP to the interface @@ -211,6 +213,8 @@ if_up() { IF_UP=1 else echo "/etc/rc.d/rc.inet1: failed to a set IP ${IPADDR[$i]} for ${1}" | $LOGGER + /sbin/ip address flush dev ${1} + /sbin/ip link set dev ${1} down fi fi if [ "${USE_DHCP6[$i]}" != "yes" ] && [ -n "${IPADDR6[$i]}" ]; then # add a fixed v6 IP to the interface @@ -224,10 +228,15 @@ if_up() { IF_UP=1 else echo "/etc/rc.d/rc.inet1: failed to a set IP ${IPADDR6[$i]} for ${1}" | $LOGGER + if (($IF_UP != 1)); then # a v4 address was configured, don't flush it + /sbin/ip address flush dev ${1} + /sbin/ip link set dev ${1} down + fi fi fi +# FIXME: Remove the ipaddr6 test? if [ "${USE_DHCP6[$i]}" != "yes" ] && [ -z "${IPADDR6[$i]}" ] && \ - [ "${USE_AUTOCONF6[$i]}" = "yes" ]; then # interface should configure itself via stateless auto config: + [ "${USE_AUTOCONF6[$i]}" = "yes" ]; then # interface should configure itself via stateless auto config echo "/etc/rc.d/rc.inet1: using Router Advertisement stateless auto configuration for ${1}" | $LOGGER # Enable accepting of router advertisment packets, and auto configuration of interfaces: echo "1" >/proc/sys/net/ipv6/conf/$1/accept_ra @@ -240,9 +249,10 @@ if_up() { sleep 0.5 done if (($IF_UP != 1)); then - /sbin/ip link set dev ${1} down echo "Timed out!" echo "/etc/rc.d/rc.inet1: failed to auto configure ${1} after 15 seconds" | $LOGGER + /sbin/ip address flush dev ${1} + /sbin/ip link set dev ${1} down fi fi if (($IF_UP == 1)); then # only do further config if the interface came up -- cgit v1.2.3