aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libexec/rc/network.subr20
-rwxr-xr-xlibexec/rc/pccard_ether17
2 files changed, 29 insertions, 8 deletions
diff --git a/libexec/rc/network.subr b/libexec/rc/network.subr
index 931fbec19a60..5e4f2c1f39a0 100644
--- a/libexec/rc/network.subr
+++ b/libexec/rc/network.subr
@@ -653,6 +653,26 @@ ifexists()
${IFCONFIG_CMD} -n $1 > /dev/null 2>&1
}
+# ifisup if
+# Returns 0 if the interface exists and UP,
+# returns 1 if the interface exists and not UP,
+# returns 2 otherwise.
+ifisup()
+{
+ local _if
+
+ [ -z "$1" ] && return 2
+ _if="$1"
+
+ set -- $(${IFCONFIG_CMD} -n ${_if} 2>/dev/null)
+ case "$1$2" in
+ ${_if}:*'<UP'[,\>]*) return 0 ;;
+ ${_if}:*) return 1 ;;
+ esac
+
+ return 2
+}
+
# ipv4_up if
# add IPv4 addresses to the interface $if
ipv4_up()
diff --git a/libexec/rc/pccard_ether b/libexec/rc/pccard_ether
index 7ca58f210085..957983e55a8e 100755
--- a/libexec/rc/pccard_ether
+++ b/libexec/rc/pccard_ether
@@ -69,16 +69,17 @@ checkauto()
pccard_ether_start()
{
- ifexists $ifn || exit 1
-
- if [ -z "$rc_force" ]; then
- for uif in `ifconfig -ul`; do
- if [ "${uif}" = "${ifn}" ]; then
- # Interface is already up, so ignore it.
+ ifisup $ifn
+ case $? in
+ 0) # Interface is already up, so ignore it.
+ if [ -z "$rc_force"]; then
exit 0
fi
- done
- fi
+ ;;
+ 2) # Interface does not exist.
+ exit 1
+ ;;
+ esac
/etc/rc.d/netif quietstart $ifn