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

8e15ce
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8e15ce
From: Michael Chang <mchang@suse.com>
8e15ce
Date: Wed, 15 Apr 2015 14:48:30 +0800
8e15ce
Subject: [PATCH] efinet: UEFI IPv6 PXE support
8e15ce
8e15ce
When grub2 image is booted from UEFI IPv6 PXE, the DHCPv6 Reply packet is
8e15ce
cached in firmware buffer which can be obtained by PXE Base Code protocol. The
8e15ce
network interface can be setup through the parameters in that obtained packet.
8e15ce
8e15ce
Signed-off-by: Michael Chang <mchang@suse.com>
8e15ce
Signed-off-by: Ken Lin <ken.lin@hpe.com>
8e15ce
---
8e15ce
 grub-core/net/drivers/efi/efinet.c |  2 ++
8e15ce
 include/grub/efi/api.h             | 71 +++++++++++++++++++++++---------------
8e15ce
 2 files changed, 46 insertions(+), 27 deletions(-)
8e15ce
8e15ce
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
8e15ce
index 8e25680db0c..014e5bf9802 100644
8e15ce
--- a/grub-core/net/drivers/efi/efinet.c
8e15ce
+++ b/grub-core/net/drivers/efi/efinet.c
8e15ce
@@ -409,6 +409,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
8e15ce
 	  grub_print_error ();
8e15ce
 	if (device && path)
8e15ce
 	  grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
8e15ce
+	if (grub_errno)
8e15ce
+	  grub_print_error ();
8e15ce
       }
8e15ce
     else
8e15ce
       {
8e15ce
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
8e15ce
index 7614b58dca8..91ab528e4d0 100644
8e15ce
--- a/include/grub/efi/api.h
8e15ce
+++ b/include/grub/efi/api.h
8e15ce
@@ -1524,31 +1524,6 @@ typedef union
8e15ce
   grub_efi_pxe_dhcpv6_packet_t dhcpv6;
8e15ce
 } grub_efi_pxe_packet_t;
8e15ce
 
8e15ce
-#define GRUB_EFI_PXE_MAX_IPCNT 8
8e15ce
-#define GRUB_EFI_PXE_MAX_ARP_ENTRIES 8
8e15ce
-#define GRUB_EFI_PXE_MAX_ROUTE_ENTRIES 8
8e15ce
-
8e15ce
-typedef struct grub_efi_pxe_ip_filter
8e15ce
-{
8e15ce
-  grub_efi_uint8_t filters;
8e15ce
-  grub_efi_uint8_t ip_count;
8e15ce
-  grub_efi_uint16_t reserved;
8e15ce
-  grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_MAX_IPCNT];
8e15ce
-} grub_efi_pxe_ip_filter_t;
8e15ce
-
8e15ce
-typedef struct grub_efi_pxe_arp_entry
8e15ce
-{
8e15ce
-  grub_efi_ip_address_t ip_addr;
8e15ce
-  grub_efi_mac_address_t mac_addr;
8e15ce
-} grub_efi_pxe_arp_entry_t;
8e15ce
-
8e15ce
-typedef struct grub_efi_pxe_route_entry
8e15ce
-{
8e15ce
-  grub_efi_ip_address_t ip_addr;
8e15ce
-  grub_efi_ip_address_t subnet_mask;
8e15ce
-  grub_efi_ip_address_t gateway_addr;
8e15ce
-} grub_efi_pxe_route_entry_t;
8e15ce
-
8e15ce
 typedef struct grub_efi_pxe_icmp_error
8e15ce
 {
8e15ce
   grub_efi_uint8_t type;
8e15ce
@@ -1574,6 +1549,48 @@ typedef struct grub_efi_pxe_tftp_error
8e15ce
   grub_efi_char8_t error_string[127];
8e15ce
 } grub_efi_pxe_tftp_error_t;
8e15ce
 
8e15ce
+typedef struct {
8e15ce
+  grub_uint8_t addr[4];
8e15ce
+} grub_efi_pxe_ipv4_address_t;
8e15ce
+
8e15ce
+typedef struct {
8e15ce
+  grub_uint8_t addr[16];
8e15ce
+} grub_efi_pxe_ipv6_address_t;
8e15ce
+
8e15ce
+typedef struct {
8e15ce
+  grub_uint8_t addr[32];
8e15ce
+} grub_efi_pxe_mac_address_t;
8e15ce
+
8e15ce
+typedef union {
8e15ce
+  grub_uint32_t addr[4];
8e15ce
+  grub_efi_pxe_ipv4_address_t v4;
8e15ce
+  grub_efi_pxe_ipv6_address_t v6;
8e15ce
+} grub_efi_pxe_ip_address_t;
8e15ce
+
8e15ce
+#define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8
8e15ce
+typedef struct grub_efi_pxe_ip_filter
8e15ce
+{
8e15ce
+  grub_efi_uint8_t filters;
8e15ce
+  grub_efi_uint8_t ip_count;
8e15ce
+  grub_efi_uint16_t reserved;
8e15ce
+  grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT];
8e15ce
+} grub_efi_pxe_ip_filter_t;
8e15ce
+
8e15ce
+typedef struct {
8e15ce
+  grub_efi_pxe_ip_address_t ip_addr;
8e15ce
+  grub_efi_pxe_mac_address_t mac_addr;
8e15ce
+} grub_efi_pxe_arp_entry_t;
8e15ce
+
8e15ce
+typedef struct {
8e15ce
+  grub_efi_pxe_ip_address_t ip_addr;
8e15ce
+  grub_efi_pxe_ip_address_t subnet_mask;
8e15ce
+  grub_efi_pxe_ip_address_t gw_addr;
8e15ce
+} grub_efi_pxe_route_entry_t;
8e15ce
+
8e15ce
+
8e15ce
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8
8e15ce
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8
8e15ce
+
8e15ce
 typedef struct grub_efi_pxe_mode
8e15ce
 {
8e15ce
   grub_efi_boolean_t started;
8e15ce
@@ -1605,9 +1622,9 @@ typedef struct grub_efi_pxe_mode
8e15ce
   grub_efi_pxe_packet_t pxe_bis_reply;
8e15ce
   grub_efi_pxe_ip_filter_t ip_filter;
8e15ce
   grub_efi_uint32_t arp_cache_entries;
8e15ce
-  grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_MAX_ARP_ENTRIES];
8e15ce
+  grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES];
8e15ce
   grub_efi_uint32_t route_table_entries;
8e15ce
-  grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_MAX_ROUTE_ENTRIES];
8e15ce
+  grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES];
8e15ce
   grub_efi_pxe_icmp_error_t icmp_error;
8e15ce
   grub_efi_pxe_tftp_error_t tftp_error;
8e15ce
 } grub_efi_pxe_mode_t;