nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0266-efinet-Setting-network-from-UEFI-device-path.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Michael Chang <mchang@suse.com>
4fe85b
Date: Sun, 10 Jul 2016 23:46:31 +0800
4fe85b
Subject: [PATCH] efinet: Setting network from UEFI device path
4fe85b
4fe85b
The PXE Base Code protocol used to obtain cached PXE DHCPACK packet is no
4fe85b
longer provided for HTTP Boot. Instead, we have to get the HTTP boot
4fe85b
information from the device path nodes defined in following UEFI Specification
4fe85b
sections.
4fe85b
4fe85b
 9.3.5.12 IPv4 Device Path
4fe85b
 9.3.5.13 IPv6 Device Path
4fe85b
 9.3.5.23 Uniform Resource Identifiers (URI) Device Path
4fe85b
4fe85b
This patch basically does:
4fe85b
4fe85b
include/grub/efi/api.h:
4fe85b
Add new structure of Uniform Resource Identifiers (URI) Device Path
4fe85b
4fe85b
grub-core/net/drivers/efi/efinet.c:
4fe85b
Check if PXE Base Code is available, if not it will try to obtain the netboot
4fe85b
information from the device path where the image booted from. The DHCPACK
4fe85b
packet is recoverd from the information in device patch and feed into the same
4fe85b
DHCP packet processing functions to ensure the network interface is setting up
4fe85b
the same way it used to be.
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 | 14 +++++---------
4fe85b
 1 file changed, 5 insertions(+), 9 deletions(-)
4fe85b
4fe85b
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
4fe85b
index 3bea6221745..a161e7a5f26 100644
4fe85b
--- a/grub-core/net/drivers/efi/efinet.c
4fe85b
+++ b/grub-core/net/drivers/efi/efinet.c
4fe85b
@@ -475,9 +475,6 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
4fe85b
   grub_err_t err;
4fe85b
 
4fe85b
   ddp = grub_efi_duplicate_device_path (dp);
4fe85b
-  if (!ddp)
4fe85b
-    return NULL;
4fe85b
-
4fe85b
   ldp = grub_efi_find_last_device_path (ddp);
4fe85b
 
4fe85b
   if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
4fe85b
@@ -754,7 +751,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
4fe85b
   {
4fe85b
     grub_efi_device_path_t *cdp;
4fe85b
     struct grub_efi_pxe *pxe;
4fe85b
-    struct grub_efi_pxe_mode *pxe_mode;
4fe85b
+    struct grub_efi_pxe_mode *pxe_mode = NULL;
4fe85b
     grub_uint8_t *packet_buf;
4fe85b
     grub_size_t packet_bufsz ;
4fe85b
     int ipv6;
4fe85b
@@ -841,11 +838,10 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
4fe85b
     if (ipv6)
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
-		      pxe_mode->dhcp_ack_received ? "" : " cannot continue");
4fe85b
-	if (!pxe_mode->dhcp_ack_received)
4fe85b
-	  continue;
4fe85b
+	if (pxe_mode)
4fe85b
+	  grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n",
4fe85b
+			pxe_mode->dhcp_ack_received ? "yes" : "no",
4fe85b
+			pxe_mode->dhcp_ack_received ? "" : " cannot continue");
4fe85b
 
4fe85b
 	grub_net_configure_by_dhcpv6_reply (card->name, card, 0,
4fe85b
 					    (struct grub_net_dhcp6_packet *)