summaryrefslogtreecommitdiffstats
path: root/rc.inet1
diff options
context:
space:
mode:
authorDarren 'Tadgy' Austin <darren@afterdark.org.uk>2018-07-31 08:58:32 +0100
committerRobby Workman <rworkman@slackware.com>2018-11-25 19:46:15 -0600
commita8e6cd3e191ff46cef2525e914a5a64c135d5f84 (patch)
tree64ef94e6b71b2874712b2eda0a55c8ef161f8417 /rc.inet1
parentc24fd260e457826e6cd93b33c88572fe1066ce9e (diff)
downloadslacknetsetup-a8e6cd3e191ff46cef2525e914a5a64c135d5f84.tar.xz
Modified interface takedown code in if_down()
Signed-off-by: Robby Workman <rworkman@slackware.com>
Diffstat (limited to 'rc.inet1')
-rw-r--r--rc.inet138
1 files changed, 27 insertions, 11 deletions
diff --git a/rc.inet1 b/rc.inet1
index 622d487..e12dfbf 100644
--- a/rc.inet1
+++ b/rc.inet1
@@ -302,21 +302,37 @@ if_down() {
return
fi
if [ -e /sys/class/net/${1%%:*} ]; then
- if [ "${USE_DHCP[$i]}" = "yes" ]; then
- echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd -k -d ${1}" | $LOGGER
- /sbin/dhcpcd -k -d ${1} 2> /dev/null || /sbin/ip link set dev ${1} down
+ if [ "${USE_DHCP[$i]}" = "yes" ] || [ "${USE_DHCP6[$i]}" = "yes" ]; then # take down dhcpcd
+ # When using -k, dhcpcd requires some command line options to match those used to invoke it:
+ if [ "${USE_DHCP[$i]}" = "yes" ] && [ "${USE_DHCP6[$i]}" != "yes" ]; then # only v4 dhcp
+ DHCP_OPTIONS="-4"
+ elif [ "${USE_DHCP[$i]}" != "yes" ] && [ "${USE_DHCP6[$i]}" = "yes" ]; then # only v6 dhcp
+ DHCP_OPTIONS="-6"
+ fi
+ echo "/etc/rc.d/rc.inet1: /sbin/dhcpcd $DHCP_OPTIONS -k -d ${1}" | $LOGGER
+ if ! /sbin/dhcpcd $DHCP_OPTIONS -k -d ${1} 2>/dev/null; then
+ echo "/etc/rc.d/rc.inet1: failed to stop dhcpcd for interface ${1}" | $LOGGER
+ fi
+ fi
+ if [ -n "${IPADDR[$i]}" ] || [ -n "${IPADDR6[$i]}" ]; then # flush any fixed IPs
+ echo "/etc/rc.d/rc.inet1: /sbin/ip address flush dev ${1}" | $LOGGER
+ /sbin/ip address flush dev ${1}
+ fi
+ if [ "${USE_STATELESS[$i]}" = "yes" ]; then # disable stateless RA auto config
+ # Disable auto configuration of the interface:
+ echo "/etc/rc.d/rc.inet1: disabling stateless Router Advertisement auto configuration on ${1}" | $LOGGER
+ echo "0" >/proc/sys/net/ipv6/conf/$1/autoconf
sleep 1
- else
- echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} down" | $LOGGER
- /sbin/ip link set dev ${1} down
fi
+ # Bring the interface down:
+ echo "/etc/rc.d/rc.inet1: /sbin/ip link set dev ${1} down" | $LOGGER
+ /sbin/ip link set dev ${1} down
+ # One final flush of the interface:
+ /sbin/ip address flush dev ${1}
+ # Kill wireless daemons if any:
if [ -x /etc/rc.d/rc.wireless ]; then
- . /etc/rc.d/rc.wireless ${1} stop # Kill wireless daemons if any.
+ . /etc/rc.d/rc.wireless ${1} stop
fi
- # Flush the address from the interface:
- ip address flush dev ${1}
- # Set interface v6 autoconf back to the default (disabled):
- echo "0" >/proc/sys/net/ipv6/conf/$1/autoconf
# If the interface is a bridge, then destroy it now:
if [ -n "${BRNICS[$i]}" ]; then
br_close $i