The mixed use of upper and lower case variables is neither obvious nor
consistent.

PRINT_ONLY is local to netstart.
ip6kernel is local to netstart.
multicast gets sources from rc.subr(8).

1. uppercase ip6kernel as is common for global variables in base scripts
2. use the simpler true/false idiom and default with the rest of
   netstart-only variables, making it clearer that only
   `multicast=YES/NO' comes from the rc environment
3. hoist kernel feature detection such that a later diff can load the
   SOII key conditionally
4. zap obvious comment

Feedback? Objection? OK?

Index: netstart
===================================================================
RCS file: /cvs/src/etc/netstart,v
retrieving revision 1.222
diff -u -p -r1.222 netstart
--- netstart    24 Oct 2022 20:51:07 -0000      1.222
+++ netstart    25 Oct 2022 10:12:52 -0000
@@ -313,6 +313,7 @@ _rc_parse_conf
 PRINT_ONLY=false
 V4_AUTOCONF=false
 V6_AUTOCONF=false
+IP6KERNEL=false
 
 while getopts ":n" opt; do
        case $opt in
@@ -322,6 +323,11 @@ while getopts ":n" opt; do
 done
 shift $((OPTIND-1))
 
+if ifconfig lo0 inet6 >/dev/null 2>&1; then
+       IP6KERNEL=true
+       ip6routes
+fi
+
 # Load key material for the generation of IPv6 Semantically Opaque Interface
 # Identifiers (SOII) used for link local and SLAAC addresses.
 $PRINT_ONLY || [[ ! -f /etc/soii.key ]] ||
@@ -349,14 +355,6 @@ else
        ifconfig lo0 inet 127.0.0.1/8
 fi
 
-# IPv6 configuration.
-if ifconfig lo0 inet6 >/dev/null 2>&1; then
-       ip6kernel=YES
-       ip6routes
-else
-       ip6kernel=NO
-fi
-
 # Create all the pseudo interfaces up front.
 vifscreate
 
@@ -396,7 +394,7 @@ $PRINT_ONLY || wait_autoconf_default
 # Configure interfaces that rely on routing
 ifmstart "tun tap gif etherip gre egre nvgre eoip vxlan pflow wg"
 
-if [[ $ip6kernel == YES ]]; then
+if $IP6KERNEL; then
        # Ensure IPv6 Duplicate Address Detection (DAD) is completed.
        count=0
        while ((count++ < 10 && $(sysctl -n net.inet6.ip6.dad_pending) != 0)); 
do

Reply via email to