diff options
author | brooks <brooks@FreeBSD.org> | 2006-08-17 03:03:38 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2006-08-17 03:03:38 +0000 |
commit | 753b3bce68b4863498f2eb4c8bd1d7fda84d1bc6 (patch) | |
tree | 05ac25c2ce4ac473a12fd1ba303cf9a1fbc4e8e6 /etc | |
parent | 6e2c7c961f3ea9e2f7e5a01b8f6125e84808e826 (diff) | |
download | FreeBSD-src-753b3bce68b4863498f2eb4c8bd1d7fda84d1bc6.zip FreeBSD-src-753b3bce68b4863498f2eb4c8bd1d7fda84d1bc6.tar.gz |
Introduce a new function, ifexists and use it to avoid attempting to
touch interfaces that don't actually exist in the stop case. In the
process move some IPv4 specific code from ifconfig_down to ipv4_down.
This should solve problems with ifconfig: error messages on boot when
interfaces are renamed.
Diffstat (limited to 'etc')
-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 |