=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/etc/netstart,v retrieving revision 1.218 retrieving revision 1.219 diff -c -r1.218 -r1.219 *** src/etc/netstart 2022/06/26 09:36:13 1.218 --- src/etc/netstart 2022/07/03 12:14:36 1.219 *************** *** 1,6 **** #!/bin/sh - # ! # $OpenBSD: netstart,v 1.218 2022/06/26 09:36:13 florian Exp $ # Turn off Strict Bourne shell mode. set +o sh --- 1,6 ---- #!/bin/sh - # ! # $OpenBSD: netstart,v 1.219 2022/07/03 12:14:36 kn Exp $ # Turn off Strict Bourne shell mode. set +o sh *************** *** 11,16 **** --- 11,27 ---- exit 1 } + # Test the first argument against the remaining ones, return success on a match. + isin() { + local _a=$1 _b + + shift + for _b; do + [[ $_a == "$_b" ]] && return 0 + done + return 1 + } + # Echo file $1 to stdout. Skip comment lines. Strip leading and trailing # whitespace if IFS is set. # Usage: stripcom /path/to/file *************** *** 94,100 **** } # Create interfaces for network pseudo-devices referred to by hostname.if files. ! # Usage: vifscreate vifscreate() { local _vif _hn _if --- 105,112 ---- } # Create interfaces for network pseudo-devices referred to by hostname.if files. ! # Optionally, limit creation to given interfaces only. ! # Usage: vifscreate [if ...] vifscreate() { local _vif _hn _if *************** *** 106,111 **** --- 118,127 ---- # loopback for routing domain is created by kernel [[ -n ${_if##lo[1-9]*} ]] || continue + if (($# > 0)) && ! isin $_if "$@"; then + continue + fi + if ! ifcreate $_if; then print -u2 "${0##*/}: create for '$_if' failed." fi *************** *** 313,319 **** --- 329,339 ---- # If we were invoked with a list of interface names, just reconfigure these # interfaces (or bridges), add default routes and return. + # Create virtual interfaces upfront to make ifconfig commands depending on + # other interfaces, e.g. "patch", work regardless of in which order interface + # names were specified. if (($# > 0)); then + vifscreate "$@" for _if; do ifstart $_if; done defaultroute return