Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jun 2009 15:45:21 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Doug Barton <dougb@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, Brooks Davis <brooks@freebsd.org>, src-committers@freebsd.org, Bruce Simpson <bms@incunabulum.net>
Subject:   Re: svn commit: r193199 - head/etc
Message-ID:  <200906021545.22204.jhb@freebsd.org>
In-Reply-To: <4A257BEF.2010205@FreeBSD.org>
References:  <200906010537.n515bDou065357@svn.freebsd.org> <200906021511.03955.jhb@freebsd.org> <4A257BEF.2010205@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 02 June 2009 3:22:23 pm Doug Barton wrote:
> John Baldwin wrote:
> > I think more specifically, if you don't set 'ifconfig_<if>' to "DHCP",=
=20
then=20
> > when you plug a <if> device in, nothing happens.=20
>=20
> That's actually not correct, as devd will try to dhcp an interface as
> soon as it comes up.

That is completely wrong.  Checking the actual code would probably be helpf=
ul=20
here.  From /etc/devd.conf:

#
# Try to start dhclient on Ethernet like interfaces when the link comes
# up.  Only devices that are configured to support DHCP will actually
# run it.  No link down rule exists because dhclient automaticly exits
# when the link goes down.
#
notify 0 {
        match "system"          "IFNET";
        match "type"            "LINK_UP";
        media-type              "ethernet";
        action "/etc/rc.d/dhclient start $subsystem";
};

Note the comment.  From /etc/rc.d/dhclient:

ifn=3D"$2"

load_rc_config $name
load_rc_config network

if ! dhcpif $ifn; then
        return 1
fi

run_rc_command "$1"

=46rom /etc/network.subr:

# dhcpif if
#       Returns 0 if the interface is a DHCP interface and 1 otherwise.
dhcpif()
{
        _tmpargs=3D`_ifconfig_getargs $1`
        for _arg in $_tmpargs; do
                case $_arg in
                [Dd][Hh][Cc][Pp])
                        return 0
                        ;;
                [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
                        return 0
                        ;;
                [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp])
                        return 0
                        ;;
                esac
        done
        return 1
}

Clearly if you do not have 'DHCP' set in your ifconfig_<if> variable, dhcpi=
f=20
will be false, and /etc/rc.d/dhclient will be a nop.

> > DHCP is opt-in, not=20
> > opt-out.  The only reason one would want to limit network_interfaces is=
 if=20
> > you wanted to have an ifconfig_foo0 line in /etc/rc.conf but not have f=
oo0=20
> > configured automatically.=20
>=20
> I've already said several times that I want to run through my own list
> of interfaces, configure the first one that comes up, and then stop.
> There is no support for that currently. Others have also chimed in
> with things that they do with the existing feature as well.

This is an interesting problem, though I think network_interfaces is a rath=
er=20
odd way of going about it.  Do you boot to single user and edit rc.conf all=
=20
the time?  I don't see how else you are using network_interfaces to impleme=
nt=20
this.  I think a better solution to that problem would be to assign=20
interfaces priority (if_priority_<if>=3D"N" perhaps).  Also, note that=20
the /etc/rc.d/defaultroute script does only hold up the boot until at least=
=20
one interface gets a default route.  For the common wireless vs. wired case=
=20
that works well, and even OS X will configure both wired and wireless=20
interfaces if both work, it simply uses the priority to determine whose=20
default route "wins".

=2D-=20
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906021545.22204.jhb>