Blame SOURCES/0005-httpboot-print-more-messages-when-it-fails-to-set-IP.patch

d1e1c8
From 0ba6c87bdf55f749a0ec1c3b0fd24ebb8200d537 Mon Sep 17 00:00:00 2001
d1e1c8
From: Gary Lin <glin@suse.com>
d1e1c8
Date: Mon, 28 May 2018 17:24:30 +0800
d1e1c8
Subject: [PATCH 05/62] httpboot: print more messages when it fails to set IP
d1e1c8
d1e1c8
We previously only print the return status and it may not be clear
d1e1c8
enough in some situations. Print the IP address and the gateway to help
d1e1c8
the user to identify the possible errors.
d1e1c8
d1e1c8
Signed-off-by: Gary Lin <glin@suse.com>
d1e1c8
Upstream-commit-id: 3abe94516c7
d1e1c8
---
d1e1c8
 httpboot.c | 45 +++++++++++++++++++++++++++++++++++++++++----
d1e1c8
 1 file changed, 41 insertions(+), 4 deletions(-)
d1e1c8
d1e1c8
diff --git a/httpboot.c b/httpboot.c
d1e1c8
index d656073c633..6f27b01bf71 100644
d1e1c8
--- a/httpboot.c
d1e1c8
+++ b/httpboot.c
d1e1c8
@@ -311,6 +311,20 @@ is_unspecified_addr (EFI_IPv6_ADDRESS ip6)
d1e1c8
 	return TRUE;
d1e1c8
 }
d1e1c8
 
d1e1c8
+static inline void
d1e1c8
+print_ip6_addr(EFI_IPv6_ADDRESS ip6addr)
d1e1c8
+{
d1e1c8
+	perror(L"%x:%x:%x:%x:%x:%x:%x:%x\n",
d1e1c8
+	       ip6addr.Addr[0]  << 8 | ip6addr.Addr[1],
d1e1c8
+	       ip6addr.Addr[2]  << 8 | ip6addr.Addr[3],
d1e1c8
+	       ip6addr.Addr[4]  << 8 | ip6addr.Addr[5],
d1e1c8
+	       ip6addr.Addr[6]  << 8 | ip6addr.Addr[7],
d1e1c8
+	       ip6addr.Addr[8]  << 8 | ip6addr.Addr[9],
d1e1c8
+	       ip6addr.Addr[10] << 8 | ip6addr.Addr[11],
d1e1c8
+	       ip6addr.Addr[12] << 8 | ip6addr.Addr[13],
d1e1c8
+	       ip6addr.Addr[14] << 8 | ip6addr.Addr[15]);
d1e1c8
+}
d1e1c8
+
d1e1c8
 static EFI_STATUS
d1e1c8
 set_ip6(EFI_HANDLE *nic, IPv6_DEVICE_PATH *ip6node)
d1e1c8
 {
d1e1c8
@@ -329,8 +343,12 @@ set_ip6(EFI_HANDLE *nic, IPv6_DEVICE_PATH *ip6node)
d1e1c8
 	ip6.IsAnycast = FALSE;
d1e1c8
 	efi_status = ip6cfg->SetData(ip6cfg, Ip6ConfigDataTypeManualAddress,
d1e1c8
 				     sizeof(ip6), &ip6;;
d1e1c8
-	if (EFI_ERROR(efi_status))
d1e1c8
+	if (EFI_ERROR(efi_status)) {
d1e1c8
+		perror(L"Failed to set IPv6 Address:\nIP: ");
d1e1c8
+		print_ip6_addr(ip6.Address);
d1e1c8
+		perror(L"Prefix Length: %u\n", ip6.PrefixLength);
d1e1c8
 		return efi_status;
d1e1c8
+	}
d1e1c8
 
d1e1c8
 	gateway = ip6node->GatewayIpAddress;
d1e1c8
 	if (is_unspecified_addr(gateway))
d1e1c8
@@ -338,12 +356,23 @@ set_ip6(EFI_HANDLE *nic, IPv6_DEVICE_PATH *ip6node)
d1e1c8
 
d1e1c8
 	efi_status = ip6cfg->SetData(ip6cfg, Ip6ConfigDataTypeGateway,
d1e1c8
 				     sizeof(gateway), &gateway);
d1e1c8
-	if (EFI_ERROR(efi_status))
d1e1c8
+	if (EFI_ERROR(efi_status)) {
d1e1c8
+		perror(L"Failed to set IPv6 Gateway:\nIP: ");
d1e1c8
+		print_ip6_addr(gateway);
d1e1c8
 		return efi_status;
d1e1c8
+	}
d1e1c8
 
d1e1c8
 	return EFI_SUCCESS;
d1e1c8
 }
d1e1c8
 
d1e1c8
+static inline void
d1e1c8
+print_ip4_addr(EFI_IPv4_ADDRESS ip4addr)
d1e1c8
+{
d1e1c8
+	perror(L"%u.%u.%u.%u\n",
d1e1c8
+	       ip4addr.Addr[0], ip4addr.Addr[1],
d1e1c8
+	       ip4addr.Addr[2], ip4addr.Addr[3]);
d1e1c8
+}
d1e1c8
+
d1e1c8
 static EFI_STATUS
d1e1c8
 set_ip4(EFI_HANDLE *nic, IPv4_DEVICE_PATH *ip4node)
d1e1c8
 {
d1e1c8
@@ -361,14 +390,22 @@ set_ip4(EFI_HANDLE *nic, IPv4_DEVICE_PATH *ip4node)
d1e1c8
 	ip4.SubnetMask = ip4node->SubnetMask;
d1e1c8
 	efi_status = ip4cfg2->SetData(ip4cfg2, Ip4Config2DataTypeManualAddress,
d1e1c8
 				      sizeof(ip4), &ip4;;
d1e1c8
-	if (EFI_ERROR(efi_status))
d1e1c8
+	if (EFI_ERROR(efi_status)) {
d1e1c8
+		perror(L"Failed to Set IPv4 Address:\nIP: ");
d1e1c8
+		print_ip4_addr(ip4.Address);
d1e1c8
+		perror(L"Mask: ");
d1e1c8
+		print_ip4_addr(ip4.SubnetMask);
d1e1c8
 		return efi_status;
d1e1c8
+	}
d1e1c8
 
d1e1c8
 	gateway = ip4node->GatewayIpAddress;
d1e1c8
 	efi_status = ip4cfg2->SetData(ip4cfg2, Ip4Config2DataTypeGateway,
d1e1c8
 				      sizeof(gateway), &gateway);
d1e1c8
-	if (EFI_ERROR(efi_status))
d1e1c8
+	if (EFI_ERROR(efi_status)) {
d1e1c8
+		perror(L"Failed to Set IPv4 Gateway:\nGateway: ");
d1e1c8
+		print_ip4_addr(gateway);
d1e1c8
 		return efi_status;
d1e1c8
+	}
d1e1c8
 
d1e1c8
 	return EFI_SUCCESS;
d1e1c8
 }
d1e1c8
-- 
d1e1c8
2.26.2
d1e1c8