Blame SOURCES/0006-httpboot-allow-the-IPv4-gateway-to-be-empty.patch

d84fc6
From 80e52895f206fcb40a60f031e7b721627bb193ca Mon Sep 17 00:00:00 2001
d84fc6
From: Gary Lin <glin@suse.com>
d84fc6
Date: Mon, 28 May 2018 17:42:56 +0800
d84fc6
Subject: [PATCH 06/62] httpboot: allow the IPv4 gateway to be empty
d84fc6
d84fc6
The gateway is not mandatory.
d84fc6
d84fc6
Signed-off-by: Gary Lin <glin@suse.com>
d84fc6
Upstream-commit-id: 69089e9c678
d84fc6
---
d84fc6
 httpboot.c | 20 ++++++++++++++++++--
d84fc6
 1 file changed, 18 insertions(+), 2 deletions(-)
d84fc6
d84fc6
diff --git a/httpboot.c b/httpboot.c
d84fc6
index 6f27b01bf71..16dd6621f66 100644
d84fc6
--- a/httpboot.c
d84fc6
+++ b/httpboot.c
d84fc6
@@ -299,7 +299,7 @@ out:
d84fc6
 }
d84fc6
 
d84fc6
 static BOOLEAN
d84fc6
-is_unspecified_addr (EFI_IPv6_ADDRESS ip6)
d84fc6
+is_unspecified_ip6addr (EFI_IPv6_ADDRESS ip6)
d84fc6
 {
d84fc6
 	UINT8 i;
d84fc6
 
d84fc6
@@ -351,7 +351,7 @@ set_ip6(EFI_HANDLE *nic, IPv6_DEVICE_PATH *ip6node)
d84fc6
 	}
d84fc6
 
d84fc6
 	gateway = ip6node->GatewayIpAddress;
d84fc6
-	if (is_unspecified_addr(gateway))
d84fc6
+	if (is_unspecified_ip6addr(gateway))
d84fc6
 		return EFI_SUCCESS;
d84fc6
 
d84fc6
 	efi_status = ip6cfg->SetData(ip6cfg, Ip6ConfigDataTypeGateway,
d84fc6
@@ -365,6 +365,19 @@ set_ip6(EFI_HANDLE *nic, IPv6_DEVICE_PATH *ip6node)
d84fc6
 	return EFI_SUCCESS;
d84fc6
 }
d84fc6
 
d84fc6
+static BOOLEAN
d84fc6
+is_unspecified_ip4addr (EFI_IPv4_ADDRESS ip4)
d84fc6
+{
d84fc6
+	UINT8 i;
d84fc6
+
d84fc6
+	for (i = 0; i<4; i++) {
d84fc6
+		if (ip4.Addr[i] != 0)
d84fc6
+			return FALSE;
d84fc6
+	}
d84fc6
+
d84fc6
+	return TRUE;
d84fc6
+}
d84fc6
+
d84fc6
 static inline void
d84fc6
 print_ip4_addr(EFI_IPv4_ADDRESS ip4addr)
d84fc6
 {
d84fc6
@@ -399,6 +412,9 @@ set_ip4(EFI_HANDLE *nic, IPv4_DEVICE_PATH *ip4node)
d84fc6
 	}
d84fc6
 
d84fc6
 	gateway = ip4node->GatewayIpAddress;
d84fc6
+	if (is_unspecified_ip4addr(gateway))
d84fc6
+		return EFI_SUCCESS;
d84fc6
+
d84fc6
 	efi_status = ip4cfg2->SetData(ip4cfg2, Ip4Config2DataTypeGateway,
d84fc6
 				      sizeof(gateway), &gateway);
d84fc6
 	if (EFI_ERROR(efi_status)) {
d84fc6
-- 
d84fc6
2.26.2
d84fc6