Author: hrs
Date: Sat Jun 11 21:40:37 2011
New Revision: 222996
URL: http://svn.freebsd.org/changeset/base/222996

Log:
  Add a helper function to check kern.features.* sysctls.
  
  Discussed with:       dougb

Modified:
  head/etc/network.subr
  head/etc/rc.subr

Modified: head/etc/network.subr
==============================================================================
--- head/etc/network.subr       Sat Jun 11 21:27:14 2011        (r222995)
+++ head/etc/network.subr       Sat Jun 11 21:40:37 2011        (r222996)
@@ -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

Modified: head/etc/rc.subr
==============================================================================
--- head/etc/rc.subr    Sat Jun 11 21:27:14 2011        (r222995)
+++ head/etc/rc.subr    Sat Jun 11 21:40:37 2011        (r222996)
@@ -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}.
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to