Blob Blame History Raw
From 80e52895f206fcb40a60f031e7b721627bb193ca Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Mon, 28 May 2018 17:42:56 +0800
Subject: [PATCH 06/62] httpboot: allow the IPv4 gateway to be empty

The gateway is not mandatory.

Signed-off-by: Gary Lin <glin@suse.com>
Upstream-commit-id: 69089e9c678
---
 httpboot.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/httpboot.c b/httpboot.c
index 6f27b01bf71..16dd6621f66 100644
--- a/httpboot.c
+++ b/httpboot.c
@@ -299,7 +299,7 @@ out:
 }
 
 static BOOLEAN
-is_unspecified_addr (EFI_IPv6_ADDRESS ip6)
+is_unspecified_ip6addr (EFI_IPv6_ADDRESS ip6)
 {
 	UINT8 i;
 
@@ -351,7 +351,7 @@ set_ip6(EFI_HANDLE *nic, IPv6_DEVICE_PATH *ip6node)
 	}
 
 	gateway = ip6node->GatewayIpAddress;
-	if (is_unspecified_addr(gateway))
+	if (is_unspecified_ip6addr(gateway))
 		return EFI_SUCCESS;
 
 	efi_status = ip6cfg->SetData(ip6cfg, Ip6ConfigDataTypeGateway,
@@ -365,6 +365,19 @@ set_ip6(EFI_HANDLE *nic, IPv6_DEVICE_PATH *ip6node)
 	return EFI_SUCCESS;
 }
 
+static BOOLEAN
+is_unspecified_ip4addr (EFI_IPv4_ADDRESS ip4)
+{
+	UINT8 i;
+
+	for (i = 0; i<4; i++) {
+		if (ip4.Addr[i] != 0)
+			return FALSE;
+	}
+
+	return TRUE;
+}
+
 static inline void
 print_ip4_addr(EFI_IPv4_ADDRESS ip4addr)
 {
@@ -399,6 +412,9 @@ set_ip4(EFI_HANDLE *nic, IPv4_DEVICE_PATH *ip4node)
 	}
 
 	gateway = ip4node->GatewayIpAddress;
+	if (is_unspecified_ip4addr(gateway))
+		return EFI_SUCCESS;
+
 	efi_status = ip4cfg2->SetData(ip4cfg2, Ip4Config2DataTypeGateway,
 				      sizeof(gateway), &gateway);
 	if (EFI_ERROR(efi_status)) {
-- 
2.26.2