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

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