discover: Wait for net interfaces to be marked ready
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 15 Jun 2017 05:23:06 +0000 (15:23 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 11 Jul 2017 04:50:00 +0000 (14:50 +1000)
commit58db060fbb1548a0acdfc475fa41fe86fb32dd11
treebf23d028b13d7f5d9f694d2e2455fc8a9a2f64e6
parent515d2f03bae8d5617ee3bce5a46287203f7215c2
discover: Wait for net interfaces to be marked ready

If pb-discover is started before udev has settled there is a race
between Petitboot configuring interfaces and udev renaming them. If an
interface is set "up" the name change will fail and interfaces can be
inconsistently named, eg:

  Device:        (*) eth0 [0c:c4:7a:f4:1c:50, link up]
                 ( ) enP1p9s0f1 [0c:c4:7a:f4:1c:51, link down]
                 ( ) enP1p9s0f2 [0c:c4:7a:f4:1c:52, link down]
                 ( ) enP1p9s0f3 [0c:c4:7a:f4:1c:53, link down]

Add "net" devices to the udev filter and wait for them to be announced
by udev before configuring them.
udev_enumerate_add_match_is_initialized() ensures that by the time an
interface appears via udev its name will be consistent.

This also swaps the network and udev init order, but since interfaces
now will not be configured until after udev is ready this should not
have a user-visible effect.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/device-handler.c
discover/network.c
discover/network.h
discover/udev.c