Hi,

I want to create an enc1 interface for routing domain 1 and set
additional addresses on lo1.  So my net config looks like this.

==> /etc/hostname.enc1 <==
rdomain 1

==> /etc/hostname.lo1 <==
rdomain 1
inet alias 10.188.10.74 255.255.255.255
...

/etc/netstart creates enc1 in routing domain 0, but does not place
it into rdomain 1 due to this error:
starting network
ifconfig: SIOCSIFRDOMAIN: Invalid argument

With some additional debug output netstart does this:
{ ifconfig enc1 || ifconfig enc1 create; }
{ ifconfig lo0 || ifconfig lo0 create; }
{ ifconfig lo1 || ifconfig lo1 create; }
{ ifconfig enc1 || ifconfig enc1 create; }
ifconfig enc1 rdomain 1
...
{ ifconfig lo1 || ifconfig lo1 create; }
ifconfig lo1 rdomain 1
ifconfig lo1 inet alias 10.188.10.74 netmask 255.255.255.255

ifconfig enc1 rdomain 1 fails as lo1 exists, but is still in routing
domain 0.

To fix this, I think lo1, lo2, ... should not be created upfront.
Also more debug output for /etc/netstart -n is necessary to understand
what is going on.

ok?

bluhm

Index: netstart
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/etc/netstart,v
retrieving revision 1.214
diff -u -p -r1.214 netstart
--- netstart    6 Aug 2021 07:06:35 -0000       1.214
+++ netstart    18 Aug 2021 14:13:01 -0000
@@ -86,7 +86,11 @@ parse_hn_line() {
 ifcreate() {
        local _if=$1
 
-       { ifconfig $_if || ifconfig $_if create; } >/dev/null 2>&1
+       if $PRINT_ONLY; then
+               print -r -- "{ ifconfig $_if || ifconfig $_if create; }"
+       else
+               { ifconfig $_if || ifconfig $_if create; } >/dev/null 2>&1
+       fi
 }
 
 # Create interfaces for network pseudo-devices referred to by hostname.if 
files.
@@ -99,6 +103,9 @@ vifscreate() {
                        [[ -f $_hn ]] || continue
                        _if=${_hn#/etc/hostname.}
 
+                       # loopback for routing domain is created by kernel
+                       [[ -n "${_if##lo[1-9]*}" ]] || continue
+
                        if ! ifcreate $_if; then
                                print -u2 "${0##*/}: create for '$_if' failed."
                        fi
@@ -130,9 +137,7 @@ ifstart() {
        fi
 
        # Check for ifconfig'able interface, except if -n option is specified.
-       if ! $PRINT_ONLY; then
-               ifcreate $_if || return
-       fi
+       ifcreate $_if || return
 
        # Parse the hostname.if(5) file and fill _cmds array with interface
        # configuration commands.
@@ -232,9 +237,6 @@ while getopts ":n" opt; do
        esac
 done
 shift $((OPTIND-1))
-
-# Option -n is only supported if interface names are specified as parameters.
-$PRINT_ONLY && (($# == 0)) && usage
 
 # Load key material for the generation of IPv6 Semantically Opaque Interface
 # Identifiers (SOII) used for link local and SLAAC addresses.

Reply via email to