It is time.

ok deraadt

There is a man page change we've discussed which can also go in, after
that I expect jmc will get involved and change it a little.

Andrew and I have had another discussion about how the installer might
provide a way in the installer to create these files instead (no new
question lines can be added, but questions can become more complex), but
that's a later thing.


Andrew Hewus Fresh <and...@afresh1.com> wrote:

> I think this is the complete diff, with the man page bits mostly from
> Martijn.   Now that the ifconfig -M bits are in, this should be easier
> to test.  I was able to test the installer bits, and they worked for me.
> 
> Index: etc/netstart
> ===================================================================
> RCS file: /cvs/src/etc/netstart,v
> retrieving revision 1.229
> diff -u -p -r1.229 netstart
> --- etc/netstart      5 Nov 2022 12:06:05 -0000       1.229
> +++ etc/netstart      26 Nov 2022 17:21:38 -0000
> @@ -135,6 +135,23 @@ ifstart() {
>       local _if=$1 _hn=/etc/hostname.$1 _cmds _i=0 _line _stat
>       set -A _cmds
>  
> +     # If the _if looks like an lladdr and look it up.
> +     if [[ $_if = ??:??:??:??:??:?? ]]; then
> +             if ! _line="$( ifconfig -M "$_if" )"; then
> +                     print -u2 "${0##*/}: unique if for lladdr $_if not 
> found."
> +                     return
> +             fi
> +
> +             [[ -z "$_line" ]] && return
> +             _if=$_line
> +             _line=
> +
> +             if [[ -e /etc/hostname.$_if ]]; then
> +                     print -u2 "${0##*/}: $_hn: /etc/hostname.$_if overrides"
> +                     return
> +             fi
> +     fi
> +
>       # Interface names must be alphanumeric only.  We check to avoid
>       # configuring backup or temp files, and to catch the "*" case.
>       [[ $_if != +([[:alpha:]])+([[:digit:]]) ]] && return
> @@ -183,14 +200,16 @@ ifmstart() {
>       local _sifs=$1 _xifs=$2 _hn _if _sif _xif
>  
>       for _sif in ${_sifs:-ALL}; do
> -             for _hn in /etc/hostname.+([[:alpha:]])+([[:digit:]]); do
> +             for _hn in 
> /etc/hostname.@(+([[:alpha:]])+([[:digit:]])|??:??:??:??:??:??); do
>                       [[ -f $_hn ]] || continue
>                       _if=${_hn#/etc/hostname.}
>  
> -                     # Skip unwanted ifs.
> -                     for _xif in $_xifs; do
> -                             [[ $_xif == ${_if%%[0-9]*} ]] && continue 2
> -                     done
> +                     if [[ $_if = +([[:alpha:]])+([[:digit:]]) ]]; then
> +                             # Skip unwanted ifs.
> +                             for _xif in $_xifs; do
> +                                     [[ $_xif == ${_if%%[0-9]*} ]] && 
> continue 2
> +                             done
> +                     fi
>  
>                       # Start wanted ifs.
>                       [[ $_sif == @(ALL|${_if%%[0-9]*}) ]] && ifstart $_if
> Index: distrib/miniroot/install.sub
> ===================================================================
> RCS file: /cvs/src/distrib/miniroot/install.sub,v
> retrieving revision 1.1214
> diff -u -p -r1.1214 install.sub
> --- distrib/miniroot/install.sub      6 Nov 2022 21:32:54 -0000       1.1214
> +++ distrib/miniroot/install.sub      26 Nov 2022 17:21:38 -0000
> @@ -2431,6 +2431,12 @@ ifstart() {
>       local _if=$1 _hn=/mnt/etc/hostname.$1 _cmds _i=0 _line
>       set -A _cmds
>  
> +     if [[ $_if = ??:??:??:??:??:?? ]]; then
> +             _if=$(ifconfig -M $_if)
> +             [[ -z $_if ]]                   && return # invalid interface
> +             [[ -e /mnt/etc/hostname.$_if ]] && return # duplicate config
> +     fi
> +
>       # Create interface if it does not yet exist.
>       { ifconfig $_if || ifconfig $_if create; } >/dev/null 2>&1 || return
>  
> @@ -2472,6 +2478,9 @@ enable_ifs() {
>                       svlan)  _svlans="$_svlans $_if";;
>                       vlan)   _vlans="$_vlans $_if";;
>                       esac
> +             elif [[ $_if = ??:??:??:??:??:?? ]]; then
> +                     # start by lladdr
> +                     ifstart $_if
>               else
>                       # 'Real' interfaces (if available) are done now.
>                       ifconfig $_if >/dev/null 2>&1 && ifstart $_if
> Index: share/man/man5/hostname.if.5
> ===================================================================
> RCS file: /cvs/src/share/man/man5/hostname.if.5,v
> retrieving revision 1.79
> diff -u -p -r1.79 hostname.if.5
> --- share/man/man5/hostname.if.5      26 Jul 2022 00:36:54 -0000      1.79
> +++ share/man/man5/hostname.if.5      26 Nov 2022 17:21:38 -0000
> @@ -41,9 +41,14 @@ The
>  .Nm hostname.*\&
>  files contain information regarding the configuration of each network 
> interface.
>  One file should exist for each interface that is to be configured, such as
> -.Pa hostname.fxp0
> +.Pa hostname.fxp0 ,
> +.Pa hostname.12:34:56:78:ab ,
>  or
>  .Pa hostname.bridge0 .
> +Additionally the interface name can be replaced with the interface's lladdr,
> +given that the lladdr is unique across the system and no
> +.Nm
> +exists for the interface name.
>  A configuration file is not needed for lo0.
>  .Pp
>  The configuration information is expressed in a line-by-line packed format
> 

Reply via email to