aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroki Sato <hrs@FreeBSD.org>2011-06-11 21:40:37 +0000
committerHiroki Sato <hrs@FreeBSD.org>2011-06-11 21:40:37 +0000
commitd3ae0231fec26709766560ec3a9eaff299336ad6 (patch)
tree74e76da1f93894c61eb0fed877b6ee2b0d4df010
parent90dc53a6f08fcee81cddbfb3dcaaa91616b88f74 (diff)
downloadsrc-d3ae0231fec26709766560ec3a9eaff299336ad6.tar.gz
src-d3ae0231fec26709766560ec3a9eaff299336ad6.zip
Add a helper function to check kern.features.* sysctls.
Discussed with: dougb
Notes
Notes: svn path=/head/; revision=222996
-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}.