grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/3] Use UEFI MAC device as default configured by net_bootp6


From: Andrei Borzenkov
Subject: Re: [PATCH 3/3] Use UEFI MAC device as default configured by net_bootp6
Date: Thu, 16 Apr 2015 22:58:19 +0300

В Wed, 15 Apr 2015 17:05:09 +0800
Michael Chang <address@hidden> пишет:

> The grub_efinet_findcards will register cards by checking if it can support 
> EFI
> Simple Netowork Protocol which create more than one device to a physical NIC
> device.
> 

Yes, indeed.

  /ACPI(a0341d0,0)/PCI(0,3)/MacAddr(52:54:00:12:34:56,1)/EndEntire
  28be27e5-66cc-4a31-a315-db14c3744d85
  fa3cde4c-87c2-427d-aede-7dd096c88c58
  b95e9fda-26de-48d2-8807-1f9107ac5e3a
  d9760ff3-3cca-4267-80f9-7527fafa4223
  9fb9a8a1-2f4a-43a6-889c-d0f7b6c47ad5
  66ed4721-3c98-4d3e-81e3-d03dd39a7254
  ec20eb79-6c1a-4664-9a0d-d2e4cc16d664
  00720665-67eb-4a99-baf7-d3c33a1c7cc9
  937fe521-95ae-4d1a-8929-48bcd90ad31a
  ec835dd3-fe0f-617b-a621-b350c3e13388
  2fe800be-8f01-4aa6-946b-d71388e1833f
  9d9a39d8-bd42-4a73-a4d5-8ee94be11380
  83f01464-99bd-45e5-b383-af6305d8e9e6
  c51711e7-b4bf-404a-bfb8-0a048ef1ffe4
  3b95aa31-3793-434b-8667-c8070892e05e
  f44c00ee-1f2c-4a00-aa09-1c9f3e0800a3
  e4f61863-fe2c-4b56-a8f4-08519bc439df
  f36ff770-a7e1-42cf-9ed2-56f0f271f44c (Managed Network Protocol)
  9e23d768-d2f3-4366-9fc3-3a7aba864374 (VLAN Configuration Protocol)
  device path
  network

  
/ACPI(a0341d0,0)/PCI(0,3)/MacAddr(52:54:00:12:34:56,1)/HardwareVendor(d79df6b0-ef44-43bd-9797-43e93bcf5fa8)[0:
  ]/EndEntire HII configuration access
  device path

  
/ACPI(a0341d0,0)/PCI(0,3)/MacAddr(52:54:00:12:34:56,1)/HardwareVendor(d8944553-c4dd-41f4-9b30-e1397cfb267b)[0:
  ]/EndEntire HII configuration access
  device path

  
/ACPI(a0341d0,0)/PCI(0,3)/MacAddr(52:54:00:12:34:56,1)/HardwareVendor(5bedb5cc-d830-4eb2-8742-2d4cc9b54f2c)[0:
  ]/EndEntire HII configuration access
  device path

  
/ACPI(a0341d0,0)/PCI(0,3)/MacAddr(52:54:00:12:34:56,1)/IPv4(0.0.0.0,0.0.0.0,0,0,0,0)/EndEntire
  network
  pxe
  load file
  device path

  
/ACPI(a0341d0,0)/PCI(0,3)/MacAddr(52:54:00:12:34:56,1)/IPv6(0:0:0:0:0:0:0:0,0:0:0:0:0:0:0:0,0,0,0,0)/EndEntire
  network
  pxe
  load file
  device path


> If without specifying any device to be configured by net_bootp6, it should 
> pick
> up one from them but not all.

Right now I am not even able to netboot in QEMU. Booting from CD and
attempting to read anything over net results in random failure.

There are multiple reports of similar problem in EFI. One of possible
explanations is that EFI drivers are active and steal some packets from
GRUB.

There is patch suggested in bug report
https://savannah.gnu.org/bugs/index.php?41731 but it currently crashes
OVMF so I cannot test it. Also it effectively makes multiple efinet on
single HW card useless anyway (it will open exclusively IPv4 instance
thus blocking any access to MAC device using SNP).

So it looks like efinet needs redesign anyway.

>                              In my case three firmware device are listed.
> IPv4, IPv6 and MAC device. Both IPv4 and IPv6 are derived from MAC device for
> providing PXE Base Code Protocol. I think we should use MAC device instead of
> those two to avoid collision, because net_bootp6 command does not depend on 
> PXE
> Base Code but only Simple Network Protocol to work
> ---
>  grub-core/net/bootp.c              |    8 +++++++
>  grub-core/net/drivers/efi/efinet.c |   40 
> ++++++++++++++++++++++++++++++++++++
>  include/grub/net.h                 |    1 +
>  3 files changed, 49 insertions(+), 0 deletions(-)
> 
> diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
> index 477f205..c4963ca 100644
> --- a/grub-core/net/bootp.c
> +++ b/grub-core/net/bootp.c
> @@ -1290,6 +1290,10 @@ grub_cmd_bootp6 (struct grub_command *cmd 
> __attribute__ ((unused)),
>    {
>      if (argc > 0 && grub_strcmp (card->name, args[0]) != 0)
>        continue;
> +#ifdef GRUB_MACHINE_EFI
> +    else if (!card->is_efi_mac_device (card))
> +      continue;
> +#endif
>      ncards++;
>    }
>  
> @@ -1299,6 +1303,10 @@ grub_cmd_bootp6 (struct grub_command *cmd 
> __attribute__ ((unused)),
>  
>      if (argc > 0 && grub_strcmp (card->name, args[0]) != 0)
>        continue;
> +#ifdef GRUB_MACHINE_EFI
> +    else if (!card->is_efi_mac_device (card))
> +      continue;
> +#endif
>  
>      ifaces = grub_net_ipv6_get_link_local (card, &card->default_address);
>      if (!ifaces)
> diff --git a/grub-core/net/drivers/efi/efinet.c 
> b/grub-core/net/drivers/efi/efinet.c
> index b1837e3..900384f 100644
> --- a/grub-core/net/drivers/efi/efinet.c
> +++ b/grub-core/net/drivers/efi/efinet.c
> @@ -157,6 +157,45 @@ grub_efinet_get_device_handle (struct grub_net_card 
> *card)
>    return card->efi_handle;
>  }
>  
> +static int
> +grub_efinet_is_mac_device (struct grub_net_card *card)
> +{
> +  grub_efi_handle_t efi_handle;
> +  grub_efi_device_path_t *dp;
> +  grub_efi_device_path_t *next, *p;
> +  grub_efi_uint8_t type;
> +  grub_efi_uint8_t subtype;
> +
> +  efi_handle = grub_efinet_get_device_handle (card);
> +
> +  if (!efi_handle)
> +    return 0;
> +
> +  dp = grub_efi_get_device_path (efi_handle);
> +
> +  if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
> +    return 0;
> +
> +  for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH 
> (p);
> +       ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next);
> +       p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next))
> +    ;
> +
> +  if (p)
> +    {
> +      type = GRUB_EFI_DEVICE_PATH_TYPE (p);
> +      subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (p);
> +
> +      if (type == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
> +       && subtype == GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE)
> +     {
> +       return 1;
> +     }
> +    }
> +
> +  return 0;
> +}
> +
>  static void
>  grub_efinet_findcards (void)
>  {
> @@ -223,6 +262,7 @@ grub_efinet_findcards (void)
>                  sizeof (card->default_address.mac));
>        card->efi_net = net;
>        card->efi_handle = *handle;
> +      card->is_efi_mac_device = grub_efinet_is_mac_device;
>  
>        grub_net_card_register (card);
>      }
> diff --git a/include/grub/net.h b/include/grub/net.h
> index 71dc243..4571b72 100644
> --- a/include/grub/net.h
> +++ b/include/grub/net.h
> @@ -140,6 +140,7 @@ struct grub_net_card
>        struct grub_efi_simple_network *efi_net;
>        grub_efi_handle_t efi_handle;
>        grub_size_t last_pkt_size;
> +      int (*is_efi_mac_device) (struct grub_net_card* card);
>      };
>  #endif
>      void *data;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]