aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/network.subr7
-rw-r--r--etc/rc.subr22
2 files changed, 24 insertions, 5 deletions
diff --git a/etc/network.subr b/etc/network.subr
index ce71b786f307..f9a1f88f4029 100644
--- a/etc/network.subr
+++ b/etc/network.subr
@@ -349,11 +349,8 @@ afexists()
_af=$1
case ${_af} in
- inet)
- ${SYSCTL_N} kern.features.inet > /dev/null 2>&1
- ;;
- inet6)
- ${SYSCTL_N} kern.features.inet6 > /dev/null 2>&1
+ inet|inet6)
+ check_kern_features ${_af}
;;
ipx)
${SYSCTL_N} net.ipx > /dev/null 2>&1
diff --git a/etc/rc.subr b/etc/rc.subr
index 4748e258255d..97d449c8a9cb 100644
--- a/etc/rc.subr
+++ b/etc/rc.subr
@@ -1734,6 +1734,28 @@ check_required_after()
fi
+# check_kern_features mib
+# Return existence of kern.features.* sysctl MIB as true or
+# false. The result will be cached in $_rc_cache_kern_features_
+# namespace. "0" means the kern.features.X exists.
+
+check_kern_features()
+{
+ local _v
+
+ [ -n "$1" ] || return 1;
+ _v=`eval echo "\\$_rc_cache_kern_features_$1"`
+ [ -n "$_v" ] && return "$_v";
+
+ if ${SYSCTL_N} kern.features.$1 > /dev/null 2>&1; then
+ eval _rc_cache_kern_features_$1=0
+ return 0
+ else
+ eval _rc_cache_kern_features_$1=1
+ return 1
+ fi
+}
+
# _echoonce var msg mode
# mode=0: Echo $msg if ${$var} is empty.
# After doing echo, a string is set to ${$var}.