diff options
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 |