mkinitfs : function ip_choose_if : try to bring up all interfaces before grep operstate
there is a case:
- there are 2 interfaces, one is is connected to public (eth0), one is for internal (eth1)
- when
ip=
is used, usuallyip=dhcp
- when device is not assigned in
ip=
, usuallyip=dhcp
here is the logic :
- when linux kernel boots, all interfaces status are
down
by default - linux kernel parse
ip=
, according tohttps://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt
:
<device> Name of network device to use.
Default: If the host only has one device, it is used.
Otherwise the device is determined using
autoconfiguration. This is done by sending
autoconfiguration requests out of all devices,
and using the device that received the first reply.
- internal (eth1) is always faster than public (eth0) to response kernel's
autoconfiguration requests
- kernel only
using the device that received the first reply
, and brings up eth1, but keep eth0down
at it's default state. - alpine init finds
eth1
according toip_choose_if
function -
eth1
has no internet connection - alpne fails to do netboot
this patch let alpine init bring up all interfaces before grep operstate
and find the first one that is up
, which is eth0. this fixes the boot issue in such case.
without this patch, one has to use parameter ip=:::::eth0:dhcp
(parsed by linux kernel and alpine init) or BOOTIF=eth0_macaddr
(parsed by alpine init)