Skip to content

mkinitfs : function ip_choose_if : try to bring up all interfaces before grep operstate

Justin requested to merge Ba3Hf/mkinitfs:Ba3Hf-master-patch-75981 into master

there is a case:

  • there are 2 interfaces, one is is connected to public (eth0), one is for internal (eth1)
  • when ip= is used, usually ip=dhcp
  • when device is not assigned in ip=, usually ip=dhcp

here is the logic :

  1. when linux kernel boots, all interfaces status are down by default
  2. linux kernel parse ip=, according to
<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.
  1. internal (eth1) is always faster than public (eth0) to response kernel's autoconfiguration requests
  2. kernel only using the device that received the first reply, and brings up eth1, but keep eth0 down at it's default state.
  3. alpine init finds eth1 according to ip_choose_if function
  4. eth1 has no internet connection
  5. 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)

Merge request reports