dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0255-efinet-UEFI-IPv6-PXE-support.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Michael Chang <mchang@suse.com>
4fe85b
Date: Wed, 15 Apr 2015 14:48:30 +0800
4fe85b
Subject: [PATCH] efinet: UEFI IPv6 PXE support
4fe85b
4fe85b
When grub2 image is booted from UEFI IPv6 PXE, the DHCPv6 Reply packet is
4fe85b
cached in firmware buffer which can be obtained by PXE Base Code protocol. The
4fe85b
network interface can be setup through the parameters in that obtained packet.
4fe85b
4fe85b
Signed-off-by: Michael Chang <mchang@suse.com>
4fe85b
Signed-off-by: Ken Lin <ken.lin@hpe.com>
4fe85b
---
4fe85b
 grub-core/net/drivers/efi/efinet.c | 22 ++++++------
4fe85b
 include/grub/efi/api.h             | 71 +++++++++++++++++++++++---------------
4fe85b
 2 files changed, 54 insertions(+), 39 deletions(-)
4fe85b
4fe85b
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
4fe85b
index b9ed13fcad1..8bb0db014ac 100644
4fe85b
--- a/grub-core/net/drivers/efi/efinet.c
4fe85b
+++ b/grub-core/net/drivers/efi/efinet.c
4fe85b
@@ -404,9 +404,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
4fe85b
     pxe_mode = pxe->mode;
4fe85b
     if (pxe_mode->using_ipv6)
4fe85b
       {
4fe85b
-	grub_net_link_level_address_t hwaddr;
4fe85b
-	struct grub_net_network_level_interface *intf;
4fe85b
-
4fe85b
 	grub_dprintf ("efinet", "using ipv6 and dhcpv6\n");
4fe85b
 	grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n",
4fe85b
 		      pxe_mode->dhcp_ack_received ? "yes" : "no",
4fe85b
@@ -414,16 +411,17 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
4fe85b
 	if (!pxe_mode->dhcp_ack_received)
4fe85b
 	  continue;
4fe85b
 
4fe85b
-	hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
4fe85b
-	grub_memcpy (hwaddr.mac,
4fe85b
-		     card->efi_net->mode->current_address,
4fe85b
-		     sizeof (hwaddr.mac));
4fe85b
-
4fe85b
-	intf = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr,
4fe85b
-	      (const struct grub_net_dhcpv6_packet *)&pxe_mode->dhcp_ack.dhcpv6,
4fe85b
-	      1, device, path);
4fe85b
-	if (intf && device && path)
4fe85b
+	grub_net_configure_by_dhcpv6_reply (card->name, card, 0,
4fe85b
+					    (struct grub_net_dhcp6_packet *)
4fe85b
+					    &pxe_mode->dhcp_ack,
4fe85b
+					    sizeof (pxe_mode->dhcp_ack),
4fe85b
+					    1, device, path);
4fe85b
+	if (grub_errno)
4fe85b
+	  grub_print_error ();
4fe85b
+	if (device && path)
4fe85b
 	  grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
4fe85b
+	if (grub_errno)
4fe85b
+	  grub_print_error ();
4fe85b
       }
4fe85b
     else
4fe85b
       {
4fe85b
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
4fe85b
index 9422ba9a9db..2d0f37a8164 100644
4fe85b
--- a/include/grub/efi/api.h
4fe85b
+++ b/include/grub/efi/api.h
4fe85b
@@ -1446,31 +1446,6 @@ typedef union
4fe85b
   grub_efi_pxe_dhcpv6_packet_t dhcpv6;
4fe85b
 } grub_efi_pxe_packet_t;
4fe85b
 
4fe85b
-#define GRUB_EFI_PXE_MAX_IPCNT 8
4fe85b
-#define GRUB_EFI_PXE_MAX_ARP_ENTRIES 8
4fe85b
-#define GRUB_EFI_PXE_MAX_ROUTE_ENTRIES 8
4fe85b
-
4fe85b
-typedef struct grub_efi_pxe_ip_filter
4fe85b
-{
4fe85b
-  grub_efi_uint8_t filters;
4fe85b
-  grub_efi_uint8_t ip_count;
4fe85b
-  grub_efi_uint8_t reserved;
4fe85b
-  grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_MAX_IPCNT];
4fe85b
-} grub_efi_pxe_ip_filter_t;
4fe85b
-
4fe85b
-typedef struct grub_efi_pxe_arp_entry
4fe85b
-{
4fe85b
-  grub_efi_ip_address_t ip_addr;
4fe85b
-  grub_efi_mac_address_t mac_addr;
4fe85b
-} grub_efi_pxe_arp_entry_t;
4fe85b
-
4fe85b
-typedef struct grub_efi_pxe_route_entry
4fe85b
-{
4fe85b
-  grub_efi_ip_address_t ip_addr;
4fe85b
-  grub_efi_ip_address_t subnet_mask;
4fe85b
-  grub_efi_ip_address_t gateway_addr;
4fe85b
-} grub_efi_pxe_route_entry_t;
4fe85b
-
4fe85b
 typedef struct grub_efi_pxe_icmp_error
4fe85b
 {
4fe85b
   grub_efi_uint8_t type;
4fe85b
@@ -1496,6 +1471,48 @@ typedef struct grub_efi_pxe_tftp_error
4fe85b
   grub_efi_char8_t error_string[127];
4fe85b
 } grub_efi_pxe_tftp_error_t;
4fe85b
 
4fe85b
+typedef struct {
4fe85b
+  grub_uint8_t addr[4];
4fe85b
+} grub_efi_pxe_ipv4_address_t;
4fe85b
+
4fe85b
+typedef struct {
4fe85b
+  grub_uint8_t addr[16];
4fe85b
+} grub_efi_pxe_ipv6_address_t;
4fe85b
+
4fe85b
+typedef struct {
4fe85b
+  grub_uint8_t addr[32];
4fe85b
+} grub_efi_pxe_mac_address_t;
4fe85b
+
4fe85b
+typedef union {
4fe85b
+  grub_uint32_t addr[4];
4fe85b
+  grub_efi_pxe_ipv4_address_t v4;
4fe85b
+  grub_efi_pxe_ipv6_address_t v6;
4fe85b
+} grub_efi_pxe_ip_address_t;
4fe85b
+
4fe85b
+#define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8
4fe85b
+typedef struct grub_efi_pxe_ip_filter
4fe85b
+{
4fe85b
+  grub_efi_uint8_t filters;
4fe85b
+  grub_efi_uint8_t ip_count;
4fe85b
+  grub_efi_uint16_t reserved;
4fe85b
+  grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT];
4fe85b
+} grub_efi_pxe_ip_filter_t;
4fe85b
+
4fe85b
+typedef struct {
4fe85b
+  grub_efi_pxe_ip_address_t ip_addr;
4fe85b
+  grub_efi_pxe_mac_address_t mac_addr;
4fe85b
+} grub_efi_pxe_arp_entry_t;
4fe85b
+
4fe85b
+typedef struct {
4fe85b
+  grub_efi_pxe_ip_address_t ip_addr;
4fe85b
+  grub_efi_pxe_ip_address_t subnet_mask;
4fe85b
+  grub_efi_pxe_ip_address_t gw_addr;
4fe85b
+} grub_efi_pxe_route_entry_t;
4fe85b
+
4fe85b
+
4fe85b
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8
4fe85b
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8
4fe85b
+
4fe85b
 typedef struct grub_efi_pxe_mode
4fe85b
 {
4fe85b
   grub_efi_boolean_t started;
4fe85b
@@ -1527,9 +1544,9 @@ typedef struct grub_efi_pxe_mode
4fe85b
   grub_efi_pxe_packet_t pxe_bis_reply;
4fe85b
   grub_efi_pxe_ip_filter_t ip_filter;
4fe85b
   grub_efi_uint32_t arp_cache_entries;
4fe85b
-  grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_MAX_ARP_ENTRIES];
4fe85b
+  grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES];
4fe85b
   grub_efi_uint32_t route_table_entries;
4fe85b
-  grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_MAX_ROUTE_ENTRIES];
4fe85b
+  grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES];
4fe85b
   grub_efi_pxe_icmp_error_t icmp_error;
4fe85b
   grub_efi_pxe_tftp_error_t tftp_error;
4fe85b
 } grub_efi_pxe_mode_t;