netstart: implicit up and explicit down for hostname.if conf files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

netstart: implicit up and explicit down for hostname.if conf files

David Gwynne-5
this makes netstart run "hostname foo0 up" for every interface that
is configured. however, if you do not want an interface to be brought
up on boot (you may just want to configure it) you can disable this
by putting "down" in the file.

this has two uses. the first is to simplify config for things like
bridge. right now you need an explicit "up" for those interfaces,
which is inconsistent with the configuration of most of our other
interfaces.

the other is to help move us away from using address configuration
as an implicit up. this is particularly desirable for tunnel
interfaces, where it doesn't make sense to bring an interface up
until it has been properly configured. having netstart bring the
interface up after all configuration, both tunnel and addresses,
makes it possible for the kernel to check the tunnel configuration
when it is brought up, rather than have it stumble along if it is
misconfigured.

thoughts? ok?

Index: etc/netstart
===================================================================
RCS file: /cvs/src/etc/netstart,v
retrieving revision 1.190
diff -u -p -r1.190 netstart
--- etc/netstart 10 Feb 2018 08:46:10 -0000 1.190
+++ etc/netstart 14 Mar 2018 00:09:12 -0000
@@ -62,6 +62,9 @@ parse_hn_line() {
  _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} down;dhclient $_if"
  V4_DHCPCONF=true
  ;;
+ down) _c[0]=
+ _ifup=down
+ ;;
  '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
  _cmds[${#_cmds[*]}]="${_cmd#!}"
  ;;
@@ -77,6 +80,7 @@ parse_hn_line() {
 ifstart() {
  local _if=$1 _hn=/etc/hostname.$1 _cmds _i=0 _line _stat
  set -A _cmds
+ _ifup=up
 
  # Interface names must be alphanumeric only.  We check to avoid
  # configuring backup or temp files, and to catch the "*" case.
@@ -107,6 +111,8 @@ ifstart() {
  while IFS= read -- _line; do
  parse_hn_line $_line
  done <$_hn
+
+ _cmds[${#_cmds[*]}]="ifconfig $_if $_ifup"
 
  # Apply the interface configuration commands stored in _cmds array.
  while ((_i < ${#_cmds[*]})); do
Index: share/man/man5/hostname.if.5
===================================================================
RCS file: /cvs/src/share/man/man5/hostname.if.5,v
retrieving revision 1.65
diff -u -p -r1.65 hostname.if.5
--- share/man/man5/hostname.if.5 10 Mar 2017 18:28:11 -0000 1.65
+++ share/man/man5/hostname.if.5 14 Mar 2018 00:09:12 -0000
@@ -57,6 +57,9 @@ the administrator should not expect magi
 and the
 per-driver manual pages to see what arguments are permitted.
 .Pp
+Interfaces are implicitly configured to be brought up and running.
+This behaviour can be disabled by adding a line containing down to the file.
+.Pp
 Arguments containing either whitespace or single quote
 characters must be double quoted.
 For example:

Reply | Threaded
Open this post in threaded view
|

Re: netstart: implicit up and explicit down for hostname.if conf files

Bryan Vyhmeister-3
On Wed, Mar 14, 2018 at 10:27:10AM +1000, David Gwynne wrote:

> this makes netstart run "hostname foo0 up" for every interface that
> is configured. however, if you do not want an interface to be brought
> up on boot (you may just want to configure it) you can disable this
> by putting "down" in the file.
>
> this has two uses. the first is to simplify config for things like
> bridge. right now you need an explicit "up" for those interfaces,
> which is inconsistent with the configuration of most of our other
> interfaces.
>
> the other is to help move us away from using address configuration
> as an implicit up. this is particularly desirable for tunnel
> interfaces, where it doesn't make sense to bring an interface up
> until it has been properly configured. having netstart bring the
> interface up after all configuration, both tunnel and addresses,
> makes it possible for the kernel to check the tunnel configuration
> when it is brought up, rather than have it stumble along if it is
> misconfigured.
>
> thoughts? ok?

I, for one, would be very happy with this change. The inconsistency of
"up" only being sometimes required ends up causing me to add "up" to
most interfaces if multiple lines of configuration are present like for
vlan(4) interfaces and that type of thing. I had an issue where I
upgraded from 6.0 to 6.1 or possibly 6.1 to 6.2 and, because I did not
have "up" in some of the hostname.if files, I had some issues with the
upgrade. It was not a big problem but, as I understand it, this would
solve it completely.

Bryan

Reply | Threaded
Open this post in threaded view
|

Re: netstart: implicit up and explicit down for hostname.if conf files

Theo de Raadt-2
In reply to this post by David Gwynne-5
No.  I don't see any study of who this affects negatively.