[PATCH v2 4/6] net: eth_bootdev_hunt() must not try to boot
Ilias Apalodimas
ilias.apalodimas at linaro.org
Mon Nov 25 12:26:55 CET 2024
Hi Heinrich
On Sat, 23 Nov 2024 at 23:46, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> eth_bootdev_hunt() should not execute dhcp_run() as this itself would load
> a file and boot it if autostart=yes.
>
> Instead just check that there is a network device.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
> v2:
> new patch
> ---
> net/eth_bootdev.c | 30 ++++++++++++++++++------------
> 1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/net/eth_bootdev.c b/net/eth_bootdev.c
> index 6ee54e3c790..b0fca6e8313 100644
> --- a/net/eth_bootdev.c
> +++ b/net/eth_bootdev.c
> @@ -64,9 +64,23 @@ static int eth_bootdev_bind(struct udevice *dev)
> return 0;
> }
>
> +/**
> + * eth_bootdev_hunt() - probe all network devices
> + *
> + * Network devices can also come from USB, but that is a higher
> + * priority (BOOTDEVP_5_SCAN_SLOW) than network, so it should have been
> + * enumerated already. If something like 'bootflow scan dhcp' is used,
> + * then the user will need to run 'usb start' first.
> + *
> + * @info: info structure describing this hunter
> + * @show: true to show information from the hunter
> + *
> + * Return: 0 if device found, -EINVAL otherwise
> + */
> static int eth_bootdev_hunt(struct bootdev_hunter *info, bool show)
> {
> int ret;
> + struct udevice *dev = NULL;
>
> if (!test_eth_enabled())
> return 0;
> @@ -78,19 +92,11 @@ static int eth_bootdev_hunt(struct bootdev_hunter *info, bool show)
> log_warning("Failed to init PCI (%dE)\n", ret);
> }
>
> - /*
> - * Ethernet devices can also come from USB, but that is a higher
> - * priority (BOOTDEVP_5_SCAN_SLOW) than ethernet, so it should have been
> - * enumerated already. If something like 'bootflow scan dhcp' is used
> - * then the user will need to run 'usb start' first.
> - */
> - if (IS_ENABLED(CONFIG_CMD_DHCP)) {
> - ret = dhcp_run(0, NULL, false);
> - if (ret)
> - return -EINVAL;
> - }
> + ret = -EINVAL;
> + uclass_foreach_dev_probe(UCLASS_ETH, dev)
> + ret = 0;
>
> - return 0;
> + return ret;
I agree with the reasoning above. Now that we have LWIP it would be a
good idea to try to boot only if ww receive and parse option 66 on
DHCP.
In any case FWIW
Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> }
>
> struct bootdev_ops eth_bootdev_ops = {
> --
> 2.45.2
>
More information about the U-Boot
mailing list