Would there be any merit in contemplating a syntax that would permit
adding routes in hostname.if so the installer could pick that up and
avoid the much more corner case shell disaster scenarios?

note .. 'route add' no longer requires -inet6 so we would not need a
special route6 syntax.

For example, one attempt at doing this could look like the below:

/usr/src/etc$ cat /etc/hostname.vether2 
10.2.2.2/24
inet6 eui64
route 1.2.3.0/24 10.2.2.1
route 2001:db8::/96 fe80::1%\$if
/usr/src/etc$ doas sh ./netstart -n vether2
ifconfig vether2 10.2.2.2/24
ifconfig vether2 inet6 eui64
route -q add 1.2.3.0/24 10.2.2.1
route -q add 2001:db8::/96 fe80::1%vether2
/usr/src/etc$ ifconfig vether2
vether2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr fe:e1:ba:dc:67:9b
        index 20 priority 0 llprio 3
        groups: vether
        media: Ethernet autoselect
        status: active
        inet 10.2.2.2 netmask 0xffffff00 broadcast 10.2.2.255
        inet6 fe80::6a0e:c942:3581:6ebf%vether2 prefixlen 64 scopeid 0x14
/usr/src/etc$ netstat -nr | grep vether2
1.2.3/24           10.2.2.1           UGS        0        0     -     8 vether2
10.2.2/24          10.2.2.2           UCn        1        0     -     4 vether2
10.2.2.1           link#20            UHLch      1        2     -     3 vether2
10.2.2.2           fe:e1:ba:dc:67:9b  UHLl       0        0     -     1 vether2
10.2.2.255         10.2.2.2           UHb        0        0     -     1 vether2
2001:db8::/96                      fe80::1%vether2                UGS        0  
      0     -     8 vether2
fe80::%vether2/64                  fe80::6a0e:c942:3581:6ebf%vether2 UCn        
1        0     -     4 vether2
fe80::1%vether2                    link#20                        UHLch      1  
      2     -     3 vether2
fe80::6a0e:c942:3581:6ebf%vether2  fe:e1:ba:dc:67:9b              UHLl       0  
      0     -     1 vether2
ff01::%vether2/32                  fe80::6a0e:c942:3581:6ebf%vether2 Um         
0        0     -     4 vether2
ff02::%vether2/32                  fe80::6a0e:c942:3581:6ebf%vether2 Um         
0        0     -     4 vether2
/usr/src/etc$ diff -u netstart.orig netstart
--- netstart.orig       Fri Nov  9 17:58:58 2018
+++ netstart    Fri Nov  9 18:09:39 2018
@@ -68,6 +68,10 @@
                _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient $_if"
                V4_DHCPCONF=true
                ;;
+       route)  ((${#_c[*]} == 3)) || return
+               _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
+               _cmds[${#_cmds[*]}]="route -q add${_cmd#route}"
+               ;;
        '!'*)   _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
                _cmds[${#_cmds[*]}]="${_cmd#!}"
                ;;



If this is worth pursuing, I'll create and test an installer equivalent version.

Thanks,

Penned by Theo de Raadt on 20181109 10:13.33, we have:
| This was intentional because a user could put crazy script commands
| in the files which don't work in the bsd.rd context.  bsd.rd is
| quite gutted.
| 
| That means some circumstances could fail quite badly
| 
| Could be reconsidered...
| 
| > During auto upgrade via the auto_upgrade.conf file (no DHCP server),
| > shell commands are skipped.
| > This small diff is coming from parse_hn_line() in /etc/netstart, thus,
| > it keeps the behavior similar.
| > I think it's handy, especially if you need a static route in order to
| > reach a mirror for example.
| > 
| > diff --git install.sub install.sub
| > index bce1fa50358..31dbafdc95d 100644
| > --- install.sub
| > +++ install.sub
| > @@ -2319,8 +2319,11 @@ parse_hn_line() {
| >                 _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient
| > $_if"
| >                 V4_DHCPCONF=true
| >                 ;;
| > -       '!'*|bridge)
| > -               # Skip shell commands and bridge in the installer.
| > +       '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
| > +               _cmds[${#_cmds[*]}]="${_cmd#!}"
| > +               ;;
| > +       bridge)
| > +               # Skip bridge in the installer.
| >                 return
| >                 ;;
| >         *)      _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"
| > 
| > 
| > Cheers
| > 

-- 
Todd T. Fries . http://todd.fries.net/pgp.txt . @unix2mars . github:toddfries

Reply via email to