diff options
-rw-r--r-- | etc/network.subr | 67 | ||||
-rwxr-xr-x | etc/pccard_ether | 2 |
2 files changed, 42 insertions, 27 deletions
diff --git a/etc/network.subr b/etc/network.subr index 5df0de5..cb00fbd1 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -70,35 +70,14 @@ ifconfig_up() } # ifconfig_down if -# Remove all inet entries from the $if interface. It returns -# 0 if inet entries were found and removed. It returns 1 if -# no entries were found or they could not be removed. -# -# XXX: should not be only inet +# returns 1 if wpa_supplicant or dhclient was stopped or +# the interface exists. # ifconfig_down() { [ -z "$1" ] && return 1 - _ifs="^" _cfg=1 - inetList="`ifconfig $1 | grep 'inet ' | tr "\n" "$_ifs"`" - - oldifs="$IFS" - IFS="$_ifs" - for _inet in $inetList ; do - # get rid of extraneous line - [ -z "$_inet" ] && break - - _inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'` - - IFS="$oldifs" - ifconfig $1 ${_inet} delete - IFS="$_ifs" - _cfg=0 - done - IFS="$oldifs" - if wpaif $1; then /etc/rc.d/wpa_supplicant stop $1 _cfg=0 @@ -109,7 +88,10 @@ ifconfig_down() _cfg=0 fi - ifconfig $1 down + if ifexists $1; then + ifconfig $1 down + _cfg=0 + fi return $_cfg } @@ -255,6 +237,13 @@ wpaif() return 1 } +# ifexists if +# Returns 0 if the interface exists and 1 otherwise. +ifexists() +{ + ifconfig $1 > /dev/null 2>&1 +} + # ipv4_up if # add IPv4 addresses to the interface $if ipv4_up() @@ -269,8 +258,32 @@ ipv4_up() ipv4_down() { _if=$1 - ifalias_down ${_if} - ipv4_addrs_common ${_if} -alias + _ifs="^" + _ret=1 + + ifexists ${_if} || return 1 + + inetList="`ifconfig ${_if} | grep 'inet ' | tr "\n" "$_ifs"`" + + oldifs="$IFS" + IFS="$_ifs" + for _inet in $inetList ; do + # get rid of extraneous line + [ -z "$_inet" ] && break + + _inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'` + + IFS="$oldifs" + ifconfig ${_if} ${_inet} delete + IFS="$_ifs" + _ret=0 + done + IFS="$oldifs" + + ifalias_down ${_if} && _ret=0 + ipv4_addrs_common ${_if} -alias && _ret=0 + + return $_ret } # ipv4_addrs_common if action @@ -466,6 +479,8 @@ ipx_down() _ifs="^" _ret=1 + ifexists $1 || return 1 + ipxList="`ifconfig $1 | grep 'ipx ' | tr "\n" "$_ifs"`" oldifs="$IFS" diff --git a/etc/pccard_ether b/etc/pccard_ether index 5aab9e8..3fb062f 100755 --- a/etc/pccard_ether +++ b/etc/pccard_ether @@ -101,7 +101,7 @@ pccard_ether_stop() /etc/rc.d/netif stop $ifn # clean ARP table - arp -d -a + ifexists $ifn && arp -d -i $ifn -a # Clean the routing table if checkyesno removable_route_flush; then |