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

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