Ok ignore my comments on patch#2. This explains what that patch is trying to do.

I think doing the alternative of what you proposed in #2 is cleaner.
Can't we add an EFI event that triggers and updates whatever it needs
to on IP address changes?

Thanks
/Ilias

On Wed, 22 Jan 2025 at 19:09, Adriano Cordova <adria...@gmail.com> wrote:
>
> This gets called each time a payload is to get executed by bootefi.
> For now this only updates the PXE IP address.
>
> Signed-off-by: Adriano Cordova <adriano.cord...@canonical.com>
> ---
>  include/efi_loader.h       |  1 +
>  lib/efi_loader/efi_net.c   | 31 ++++++++++++++++++++++++-------
>  lib/efi_loader/efi_setup.c |  3 +++
>  3 files changed, 28 insertions(+), 7 deletions(-)
>
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 626d2bbb1a..97152bbb6a 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -628,6 +628,7 @@ int efi_disk_create_partitions(efi_handle_t parent, 
> struct blk_desc *desc,
>  efi_status_t efi_gop_register(void);
>  /* Called by bootefi to make the network interface available */
>  efi_status_t efi_net_register(void);
> +efi_status_t efi_net_do_start(void);
>  /* Called by efi_net_register to make the ip4 config2 protocol available */
>  efi_status_t efi_ipconfig_register(const efi_handle_t handle,
>                                    struct efi_ip4_config2_protocol 
> *ip4config);
> diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
> index 918d43c70f..f0cf317d4f 100644
> --- a/lib/efi_loader/efi_net.c
> +++ b/lib/efi_loader/efi_net.c
> @@ -876,6 +876,30 @@ static efi_status_t EFIAPI efi_pxe_base_code_set_packets(
>         return EFI_UNSUPPORTED;
>  }
>
> +/**
> + * efi_net_do_start() - start the efi network stack
> + *
> + * This gets called from do_bootefi_exec() each time a payload gets executed.
> + *
> + * Return:     status code
> + */
> +efi_status_t efi_net_do_start(void)
> +{
> +       efi_status_t r = EFI_SUCCESS;
> +
> +#ifdef CONFIG_EFI_HTTP_PROTOCOL
> +       /*
> +        * No harm on doing the following. If the PXE handle is present, the 
> client could
> +        * find it and try to get its IP address from it. In here the PXE 
> handle is present
> +        * but the PXE protocol is not yet implmenented, so we add this in 
> the meantime.
> +        */
> +       efi_net_get_addr((struct efi_ipv4_address 
> *)&netobj->pxe_mode.station_ip,
> +                        (struct efi_ipv4_address 
> *)&netobj->pxe_mode.subnet_mask, NULL);
> +#endif
> +
> +       return r;
> +}
> +
>  /**
>   * efi_net_register() - register the simple network protocol
>   *
> @@ -1017,13 +1041,6 @@ efi_status_t efi_net_register(void)
>         r = efi_http_register(&netobj->header, &netobj->http_service_binding);
>         if (r != EFI_SUCCESS)
>                 goto failure_to_add_protocol;
> -       /*
> -        * No harm on doing the following. If the PXE handle is present, the 
> client could
> -        * find it and try to get its IP address from it. In here the PXE 
> handle is present
> -        * but the PXE protocol is not yet implmenented, so we add this in 
> the meantime.
> -        */
> -       efi_net_get_addr((struct efi_ipv4_address 
> *)&netobj->pxe_mode.station_ip,
> -                        (struct efi_ipv4_address 
> *)&netobj->pxe_mode.subnet_mask, NULL);
>  #endif
>
>         return EFI_SUCCESS;
> diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
> index 164586742a..eeed82c073 100644
> --- a/lib/efi_loader/efi_setup.c
> +++ b/lib/efi_loader/efi_setup.c
> @@ -218,6 +218,9 @@ static efi_status_t efi_start_obj_list(void)
>  {
>         efi_status_t ret = EFI_SUCCESS;
>
> +       if (IS_ENABLED(CONFIG_NETDEVICES))
> +               ret = efi_net_do_start();
> +
>         return ret;
>  }
>
> --
> 2.43.0
>

Reply via email to