Index: install.sub =================================================================== RCS file: /cvs/src/distrib/miniroot/install.sub,v retrieving revision 1.1067 diff -u -p -r1.1067 install.sub --- install.sub 7 May 2018 10:44:01 -0000 1.1067 +++ install.sub 28 May 2018 04:21:08 -0000 @@ -2313,14 +2313,36 @@ parse_hn_line() { set +o noglob } +# Create interface $1 if it does not yet exist. +ifcreate() { + local _if=$1 + + { ifconfig $_if || ifconfig $_if create; } >/dev/null 2>&1 +} + +# Create interfaces for network pseudo-devices referred to by hostname.if files. +vifscreate() { + local _vif _hn _if + + for _vif in $(ifconfig -C); do + for _hn in /mnt/etc/hostname.${_vif}+([[:digit:]]); do + [[ -f $_hn ]] || continue + _if=${_hn#/mnt/etc/hostname.} + + if ! ifcreate $_if; then + echo "create for '$_if' failed." + fi + done + done +} + # Start interface using the on-disk hostname.if file passed as argument $1. # Much of this is gratuitously stolen from /etc/netstart. ifstart() { local _if=$1 _hn=/mnt/etc/hostname.$1 _cmds _i=0 _line set -A _cmds - # Create interface if it does not yet exist. - { ifconfig $_if || ifconfig $_if create; } >/dev/null 2>&1 || return + ifconfig $_if >/dev/null 2>&1 || return ((NIFS++)) @@ -2359,22 +2381,23 @@ enable_network() { # interface up, automatically invokes the IPv6 address ::1. ifconfig lo0 inet 127.0.0.1/8 + # Create all the pseudo interfaces up front. + vifscreate + # Configure all of the non-loopback interfaces which we know about. # Refer to hostname.if(5) for _hn in /mnt/etc/hostname.*; do # Strip off prefix to get interface name. _if=${_hn#/mnt/etc/hostname.} - if isin "${_if%%+([0-9])}" $(ifconfig -C); then - # Dynamic interfaces must be done later. - case ${_if%%+([0-9])} in - trunk) _trunks="$_trunks $_if";; - svlan) _svlans="$_svlans $_if";; - vlan) _vlans="$_vlans $_if";; - esac - else + # Some dynamic interfaces must be done later. + case ${_if%%+([0-9])} in + trunk) _trunks="$_trunks $_if";; + svlan) _svlans="$_svlans $_if";; + vlan) _vlans="$_vlans $_if";; # 'Real' interfaces (if available) are done now. - ifconfig $_if >/dev/null 2>&1 && ifstart $_if - fi + ifstart $_if + *) + esac done # Configure any dynamic interfaces now that 'real' ones are up. # ORDER IS IMPORTANT! (see /etc/netstart).