aboutsummaryrefslogtreecommitdiff
path: root/net/ifconfig.sh.Linux.in
diff options
context:
space:
mode:
Diffstat (limited to 'net/ifconfig.sh.Linux.in')
-rw-r--r--net/ifconfig.sh.Linux.in23
1 files changed, 23 insertions, 0 deletions
diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in
index dcbd6286..1ac0dd52 100644
--- a/net/ifconfig.sh.Linux.in
+++ b/net/ifconfig.sh.Linux.in
@@ -297,3 +297,26 @@ ifconfig_post_stop()
iptunnel del "${IFACE}"
eend $?
}
+
+# Is the interface administratively/operationally up?
+# The 'UP' status in ifconfig/iproute2 is the administrative status
+# Operational state is available in iproute2 output as 'state UP', or the
+# operstate sysfs variable.
+# 0: up
+# 1: down
+# 2: invalid arguments
+is_admin_up()
+{
+ local iface="$1"
+ [ -z "$iface" ] && iface="$IFACE"
+ ifconfig "${iface}" | \
+ sed -n '1,1{ /flags=.*[<,]UP[,>]/{ q 0 }}; q 1; '
+}
+
+is_oper_up()
+{
+ local iface="$1"
+ [ -z "$iface" ] && iface="$IFACE"
+ read state </sys/class/net/"${iface}"/operstate
+ [ "x$state" = "up" ]
+}