I've written a patch to ensure that /etc/netstart executes ifconfig
inet6 autoconf, even when interfaces are specified as arguments.
I've updated my patch for revision 1.153 of /etc/netstart from the
revision 1.144 that my original patch was based on.
To the best of my judgement, this patch will also fix a bug. As far as
I can tell, $rtsolif is an IFS list that accumulates interfaces to be
autoconfigured after two of the ifmstart calls. The old code executed
ifconfig $rtsolif inet6 autoconf
which would theoretically break if $rtsolif consisted of multiple
interfaces (cf. ifconfig em0 em0 em0 inet6 autoconf).
Relative to the original patch, this patch also does a better job of
preserving the semantics of $rtsolif as a list of interfaces to be
autoconfigured after ifstart.
To minimise the amount of code that I needed to change, the check that
is used for $ip6kernel is repeated, but its runtime is negligible.
Feedback would be much appreciated :)
Index: etc/netstart
===================================================================
RCS file: /cvs/src/etc/netstart,v
retrieving revision 1.153
diff -u -p -u -r1.153 netstart
--- etc/netstart 20 Jul 2015 06:59:39 -0000 1.153
+++ etc/netstart 10 Sep 2015 20:19:54 -0000
@@ -151,6 +151,21 @@ ifmstart() {
done
}
+# IPv6 autoconf the interfaces in the list at $rtsolif
+# Usage: ifautoconf
+ifautoconf() {
+ printf 'IPv6 autoconf:'
+ # $ip6kernel will not have been set if we were invoked with a
+ # list of interface names
+ if ifconfig lo0 inet6 >/dev/null 2>&1; then
+ for curif in $rtsolif; do
+ printf ' %s' $curif
+ ifconfig $curif inet6 autoconf
+ done
+ fi
+ echo
+}
+
# Get network related vars from rc.conf using the parsing routine from rc.subr.
FUNCS_ONLY=1 . /etc/rc.d/rc.subr
_rc_parse_conf
@@ -165,6 +180,7 @@ if [ $# -gt 0 ]; then
ifstart $1
shift
done
+ ifautoconf
return
fi
@@ -246,10 +262,8 @@ ifmstart "" "trunk svlan vlan carp gif g
# Configure all the carp interfaces which we know about before default route.
ifmstart "trunk svlan vlan carp"
-if [ "$ip6kernel" = "YES" -a "x$rtsolif" != "x" ]; then
- echo "IPv6 autoconf:$rtsolif"
- ifconfig $rtsolif inet6 autoconf
-fi
+# Now that $rtsolif has been populated, IPv6 autoconf those interfaces
+ifautoconf
# Look for default routes in /etc/mygate.
[[ -z $dhcpif ]] && stripcom /etc/mygate | while read gw; do