vifscreate() is used to create all virtual interfaces up-front and is always called at the beginning of netstart, whether an explicit list of interfaces is passed or none, i.e. all are to be configured.
Yet, to check the given interface exists, ifstart() uses ifcreate() which obviously tries to create interfaces. When ifstart() is run for every hostname.if(5) file, every virtual interface is guaranteed to exist thanks to vifscreate(). Nonexistent physical interfaces with an existent config, e.g. urndis(4) and cdce(4), will be skipped by ifstart() due to the failed ifcreate() call, but not without ifcreate() trying the impossible: $ ifconfig urndis0 urndis0: no such interface # sh /etc/netstart -n urndis0 { ifconfig urndis0 || ifconfig urndis0 create; } ifconfig urndis0 inet6 autoconf ifconfig urndis0 inet autoconf This dry-run output does NOT match what netstart would really do: # sh -x /etc/netstart urndis0 2>&1 | tail -n4 + vifscreate urndis0 + ifstart urndis0 + defaultroute + return Here, ifstart() runs but bails out on the failing ifcreate() call and thus skips configuring urndis0 entirely. So clarify the comment and replace the ifcreate() call with a simpler, more obvious `ifconfig' check, which is exactly what ifcreate() boils down to for existing interfaces: # sh ./netstart -n urndis0 ; echo $? 0 Actual steps taken remain the same, i.e. none, as the new dry-run output truthfully tells: # sh -x ./netstart urndis0 2>&1 | tail -n4 + vifscreate urndis0 + ifstart urndis0 + defaultroute + return Virtual interfaces are now also created only once: # sh /etc/netstart -n veb0 { ifconfig veb0 || ifconfig veb0 create; } { ifconfig veb0 || ifconfig veb0 create; } ifconfig veb0 description 'vmd(4) uplink' ifconfig veb0 up # sh ./netstart -n veb0 { ifconfig veb0 || ifconfig veb0 create; } ifconfig veb0 description 'vmd(4) uplink' ifconfig veb0 up Feedback? OK? Index: netstart =================================================================== RCS file: /cvs/src/etc/netstart,v retrieving revision 1.227 diff -u -p -r1.227 netstart --- netstart 1 Nov 2022 11:18:06 -0000 1.227 +++ netstart 1 Nov 2022 13:17:45 -0000 @@ -152,8 +152,8 @@ ifstart() { chown -LR root:wheel $_hn fi - # Check for ifconfig'able interface, except if -n option is specified. - ifcreate $_if || return + # Skip missing physical interface, virtual ones were created up front. + ifconfig $_if >/dev/null 2>&1 || return # Parse the hostname.if(5) file and fill _cmds array with interface # configuration commands.