Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 May 2014 15:57:21 -0700
From:      David Wolfskill <david@catwhisker.org>
To:        rc@freebsd.org
Subject:   An attempt to decrease time taken to bring up NICs
Message-ID:  <20140527225721.GA64440@albert.catwhisker.org>

next in thread | raw e-mail | index | archive | help

--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

This may well be something that is generally applicable only to a subset
of machines, but here goes....

My laptop has both wired (em(4)) and wireless (iwn(4)) NICs.  During
normal operation, I would prefer to have one NIC used; which one depends
on circumstances that are rather location-dependent -- but the machine
is intended to have the role of "DHCP client" (again, in "normal
operation").

As a consequence, /etc/rc.conf includes:

wlans_iwn0=3Dwlan0
ifconfig_wlan0=3D"WPA DHCP"
ifconfig_em0=3D"DHCP"


And as a consequence of *that*, FreeBSD (via rc.d/netif, if I understand
correctly) attempts to bring up em0, then wlan0... serially, and on
every boot (well, transition from single-user to multi-user mode).

Now, I can control the behavior a bit:
* I can choose whether or not to plug a wire into em0.  (In some cases,
  I can even control whether or not the other end of the wire is connected
  to anything useful. :-})
* I can disable the iwn0 NIC (by sliding the hardware switch).
  (Sometimes I can even do that intentionally. :-})

But whether or not either (or both) of the above have been done, we
first try to bring up em0, then try to bring up wlan0.

One plausible approach might be to fork off separate subprocesses, and
try to bring up the NICs in parallel.  However, I'm not that ambitious. :-}

I did think of a couple of things that might help somewhat, though, and
even tried coding one of them up:
* Create an rc.conf knob to control allow the specification of the
  number of NICs I would like to have brought up.  In my case, I might
  set that at 1 -- so if I'm in an environment where I know I only want
  to use thw wired NIC, I connect em0, it's brought up, and then
  rc.d/netif stops trying to bring up NICs (because I've reached the
  target number).
* Create an rc.conf knob to make the sequence in which the NICs are
  brought up explicit.

For the first one (specifying a target number of active NICs), I cobbled
up a bit of code (only changing rc.d/netif); the changed version even
seems to do the right thing if I invoke:

	service netif start

However, in "real life" (i.e., during a real transition from single- to
multi-user mode), the behavior seems to be unchanged.

Is there something ... different ... about how rc.d/netif is invoked
during boot time, perhaps?


For the second... it seems that the sequence is effectively dictated by
the sequence in which "ifconfig -l" outputs the list of NICs (though
rc.d/netif has a bit of code to move lo0 to the front of the list).  I
suppose one possible approach would be:
* If a certain rc variable has a non-empty value, treat it as a
  space-separated list of NICs (same format as output of "ifconfig -l"),
  and use that value in place of the currently-used "ifconfig -l"
  output.  (This implies that the current behavior of ensuring that lo0
  is first would remain.)
* If that rc variable is undefined or has an empty value, fall back to
  the current use of the output of "ifconfog -l".

Might want to set an emtpy value for the rc variable in
/etc/defaults/rc.conf.


The reason the second one is an issue is that it seems to me that the
behavior I'm seeing (where rc.d/netif tries the wired NIC first, then
the wireless) is essentially an accident of the names chosen for the
NICs, rather than something that an administrator can choose.

Finally, I note that even in cases where I've disabled the wireless NIC,
I see (e.g.):

=2E..
May 27 14:08:45 d130 wpa_supplicant[374]: Failed to initiate AP scan.
May 27 14:09:16 d130 last message repeated 31 times
May 27 14:11:17 d130 last message repeated 121 times
May 27 14:21:18 d130 last message repeated 600 times
May 27 14:31:19 d130 last message repeated 600 times
May 27 14:41:20 d130 last message repeated 600 times
May 27 14:51:21 d130 last message repeated 600 times
May 27 15:01:22 d130 last message repeated 600 times
May 27 15:11:23 d130 last message repeated 600 times
May 27 15:21:24 d130 last message repeated 601 times
May 27 15:31:25 d130 last message repeated 600 times
May 27 15:41:26 d130 last message repeated 600 times
=2E...

which seems... well, not very clever.  If I've disabled the wireless
NIC, I'd rather not have wpa_supplicant trying to do anything (at least,
with the wireless NIC).

So -- am I exhibiting my tendency toward "tunnel vision" again, or do
parts of the above seem to make some sense?  Suggestions?

Thanks!

Peace,
david
--=20
David H. Wolfskill				david@catwhisker.org
Taliban: Evil cowards with guns afraid of truth from a 14-year old girl.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.

--UugvWAfsgieZRqgk
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQJ8BAEBCgBmBQJThRhQXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ4RThEMDY4QTIxMjc1MDZFRDIzODYzRTc4
QTY3RjlDOERFRjQxOTNCAAoJEIpn+cje9Bk7yOYP/0G/ww4bbkaRUCfErnJ4+2jB
slaV4xWRMoBGo8mBLa5jo+KUgjdlsJ5YZ+PMkeLhuEWQfbiFrnOOaHp7cEJ+BvT9
DLmskgFL94yYTnIgdUFWcGQwp+WtlNBZbFxrOmo28OP3Bnhvl88DRzs9FVrN+bMU
ml8ZmrNAYUgYX2oCmm6Qpka57/9zCfQbKvA687E5TxdRqbvhxcooojWqZNhX2sY8
lpJDtXyaoEYAUIJH/X5A1EU1FejpVO2mKrdCaARlPABJQPtd6GHkX3NWN43ByeCC
kCl9rPqZ9PoJ/G2NKiKus3DpOpEEg1nd5OwpguTh0h20uslH4CD5NjL/KKI1A6wh
o8jsFAirUs7WcRCIPOe5hvAU6BRxCaiiF8ArREQGVYNQMMq8upur/kp7S+WpD4Dk
L9caRdypIn+D88yymKwKbGcQndE+XM/DL0ndRjdGfPxbyrkjr+/g49Uhqs7Ob8iA
oRykZ+Nk4av8tu/pVB778iHGiwAQeROyxMQspR5aiWEU6Hxp81XwZJqDEZeAX+Nz
TWvx7VSWL4mbykWvfqpkv3n08ZZKmPdn/2pdCI0gRrzieTP0XQWRSoUj7WGFUgn/
fj190L29kypdhuIZ0s0FCRkauxwYftjczmfhQ6jTC0dVXFJvK/vlBQWsPjTlEI3r
rkQaR1In3SdeXg15fuTn
=UdFg
-----END PGP SIGNATURE-----

--UugvWAfsgieZRqgk--



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