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

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