the installer uses the vlan/vlandev ifconfig params to configure
vlan interfaces. this updates it to use vnetid and parent.

there's some semantic tweaks in here too. firstly, instead of
creating a vlan interface so it can be selected to configure, this
adds the next vlan interface to the list of options passed to
ask_which().

secondly, if you reconfigure a vlan interface, itll read the parent
as well as the tag off the parent to present as the default.

thanks to rpe@ for helping me with this.

ok?

Index: install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1014
diff -u -p -r1.1014 install.sub
--- install.sub 3 Jun 2017 22:27:41 -0000       1.1014
+++ install.sub 9 Jun 2017 08:28:57 -0000
@@ -1131,14 +1131,12 @@ ieee80211_config() {
 
 # Set up IPv4 and IPv6 interface configuration.
 configure_ifs() {
-       local _first _ifs _if _name _hn _vl=0 _vd _vi _p _tags
+       local _first _ifs _if _name _hn _vl=0 _vd _vi _p
 
        # In case of restart, discover last vlan configured.
        while :; do
                _vd=$(ifconfig vlan$_vl 2>&1)
                [[ $_vd == @(*no such interface*) ]] && break
-               [[ $_vd == @(*vlan: +([[:digit:]]) parent interface:*) ]] ||
-                       break
                ((_vl++))
        done
        _vd=
@@ -1150,11 +1148,8 @@ configure_ifs() {
        rm -f /tmp/i/mygate
 
        while :; do
-               # Create new vlan if possible.
-               ifconfig vlan$_vl create >/dev/null 2>&1
-
                ask_which "network interface" "do you wish to configure" \
-                       '$(get_ifs)' \
+                       "\$(get_ifs) vlan$_vl" \
                        ${_p:-'$( (get_ifs netboot; get_ifs) | sed q )'}
                [[ $resp == done ]] && break
 
@@ -1165,25 +1160,24 @@ configure_ifs() {
                # If the offered vlan is chosen, ask the relevant
                # questions and bring it up.
                if [[ $_if == vlan+([0-9]) ]]; then
-                       # Get existing tag for this vlan.
-                       _vi=$(ifconfig $_if 2>/dev/null |
-                               sed -n 's/vlan: \([0-9]*\).*/\1/p')
-                       # Get list of all in-use tags.
-                       _tags=$(ifconfig vlan 2>/dev/null |
-                               sed -n 's/vlan: \([0-9]*\).*/\1/p')
-                       # Current tag is a valid tag for this vlan.
-                       [[ -n $_tags ]] && _tags=$(rmel "$_vi" $_tags)
+                       # Get existing parent and tag for this vlan.
+                       resp=$(ifconfig $_if 2>/dev/null |
+                               sed -En 's/.encap: vnetid ([[:alnum:]]+) parent 
([[:alnum:]]+)/\2:\1/p')
+                       _vd=${resp%%:*}
+                       _vi=${resp##*:}
+
+                       # If there's no existing tag, use the interface minor
                        if [[ -z $_vi ]]; then
-                               _vi=0
-                               while ((++_vi < 4096)); do
-                                       ! isin "$_vi" $_tags && break
-                               done
+                               _vi=${_if##vlan}
+                               [[ $_vi -eq 0 ]] && _vi=none
                        fi
+
                        _ifs=$(get_ifs)
                        set -- $_ifs
                        while [[ $1 == vlan+([0-9]) ]]; do
                                shift
                        done
+                       [[ $_vd == none ]] && _vd=
                        ask "Which interface:tag should $_if be on?" \
                                "${_vd:=$1}:$_vi"
                        _vd=${resp%%:*}
@@ -1193,13 +1187,16 @@ configure_ifs() {
                        if ! (isin "$_vd" $_ifs &&
                                [[ $_vd != vlan+([0-9]) ]]); then
                                echo "Invalid interface choice '$_vd'"
-                               _vd=
                                continue
                        fi
 
-                       # Validate range of $_vi as 1-4095, and $_vi not in use.
-                       if ((_vi < 1 || _vi > 4095)) || isin "$_vi" $_tags; then
-                               echo "Invalid or in-use vlan tag '$_vi'"
+                       # Validate $_vi as 1-4095, or none
+                       if [[ "$_vi" -ge 1 && "$_vi" -le 4095 ]]; then
+                               _vi="vnetid $_vi"
+                       elif [[ "$_vi" == "none" ]]; then
+                               _vi="-vnetid"
+                       else
+                               echo "Invalid vlan tag '$_vi'"
                                continue
                        fi
 
@@ -1212,8 +1209,10 @@ configure_ifs() {
 
                        # Make sure a hostname.$_if is created with this info.
                        ifconfig $_if destroy >/dev/null 2>&1
-                       ifconfig $_if vlan $_vi vlandev $_vd
-                       echo "vlan $_vi vlandev $_vd" >>$_hn
+                       ifconfig $_if create >/dev/null 2>&1
+                       ifconfig $_if $_vi parent $_vd
+                       echo "$_vi parent $_vd" >>$_hn
+
                        # Create a new vlan if we just configured the highest.
                        [[ ${_if##vlan} == $_vl ]] && ((_vl++))
                fi

Reply via email to