Run on boot without arguments, netstart(8) creates all virtual interfaces *for which hostname.if files exist* before configuring them.
This prevents ordering problems with bridges and its members, as dlg's commit message from 2018 reminds us. But it also helps interface types like pair(4) which pair one another in whatever way the user says: $ cat /etc/hostname.pair1 patch pair2 $ cat /etc/hostname.pair2 rdomain 1 On boot this works, but `sh /etc/netstart pair1 pair2' won't work because pair2 does not exist a creation time of pair1 because netstart does not create virtual interfaces upfront. I just hit this exact use case when setting up gelatod(8) (see ports@). To fix this, pass the list of interfaces to vifscreate() and make it create only those iff given. Regular boot, i.e. `sh /etc/netstart', stays uneffected by this and selective runs as shown work as expected without requring users to know the order in which netstart creates/configures interfaces. The installer's internal version of netstart doesn't need this at all; neither does it have the selective semantic nor does vifscreate() exist. Feedback? Objection? OK? Index: netstart =================================================================== RCS file: /cvs/src/etc/netstart,v retrieving revision 1.216 diff -u -p -r1.216 netstart --- netstart 2 Sep 2021 19:38:20 -0000 1.216 +++ netstart 16 Nov 2021 22:58:31 -0000 @@ -94,9 +94,11 @@ ifcreate() { } # Create interfaces for network pseudo-devices referred to by hostname.if files. -# Usage: vifscreate +# Optionally, limit creation to given interfaces only. +# Usage: vifscreate [if ...] vifscreate() { - local _vif _hn _if + local _vif _hn _if _ifs + set -A _ifs -- "$@" for _vif in $(ifconfig -C); do for _hn in /etc/hostname.${_vif}+([[:digit:]]); do @@ -106,6 +108,9 @@ vifscreate() { # loopback for routing domain is created by kernel [[ -n ${_if##lo[1-9]*} ]] || continue + ((${#_ifs[*]} > 0)) && [[ ${_ifs[*]} != *${_if}* ]] && + continue + if ! ifcreate $_if; then print -u2 "${0##*/}: create for '$_if' failed." fi @@ -303,6 +308,7 @@ $PRINT_ONLY || [[ ! -f /etc/soii.key ]] # If we were invoked with a list of interface names, just reconfigure these # interfaces (or bridges), add default routes and return. if (($# > 0)); then + vifscreate "$@" for _if; do ifstart $_if; done defaultroute return