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

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