diff options
author | Darren 'Tadgy' Austin <darren@afterdark.org.uk> | 2018-07-31 08:58:32 +0100 |
---|---|---|
committer | Robby Workman <rworkman@slackware.com> | 2018-11-25 19:46:15 -0600 |
commit | a8e6cd3e191ff46cef2525e914a5a64c135d5f84 (patch) | |
tree | 64ef94e6b71b2874712b2eda0a55c8ef161f8417 /rc.inet1 | |
parent | c24fd260e457826e6cd93b33c88572fe1066ce9e (diff) | |
download | slacknetsetup-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.inet1 | 38 |
1 files changed, 27 insertions, 11 deletions
@@ -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 |