Blob Blame History Raw
From 78e24f50ab754f35f4aa208ade7c9fd794d82036 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 1 Jul 2014 11:14:57 +0200
Subject: [PATCH] Parse 'origin' value from iBFT

iBFT has an 'origin' field which indicates the origin of the
network address. If that is set to '3' it indicates that
DHCP has been used; there is no need to evaluate the 'dhcp'
field here.
In fact. latest iPXE sets the 'origin' field, but not the
'dhcp' field.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 include/fw_context.h                    | 1 +
 utils/fwparam_ibft/fw_entry.c           | 8 +++++---
 utils/fwparam_ibft/fwparam_ibft_sysfs.c | 2 ++
 utils/fwparam_ibft/fwparam_sysfs.c      | 2 ++
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/fw_context.h b/include/fw_context.h
index 6563d68..295b54d 100644
--- a/include/fw_context.h
+++ b/include/fw_context.h
@@ -48,6 +48,7 @@ struct boot_context {
 	char initiatorname[TARGET_NAME_MAXLEN + 1];
 
 	/* network settings */
+	char origin[2];
 	char dhcp[NI_MAXHOST];
 	char iface[IF_NAMESIZE];
 	char mac[18];
diff --git a/utils/fwparam_ibft/fw_entry.c b/utils/fwparam_ibft/fw_entry.c
index b6f05c1..295e905 100644
--- a/utils/fwparam_ibft/fw_entry.c
+++ b/utils/fwparam_ibft/fw_entry.c
@@ -192,10 +192,12 @@ static void dump_network(struct boot_context *context)
 	if (strlen(context->mac))
 		printf("%s = %s\n", IFACE_HWADDR, context->mac);
 	/*
-	 * If this has a valid address then DHCP was used (broadcom sends
-	 * 0.0.0.0).
+	 * If the 'origin' field is '3' then DHCP is used.
+	 * Otherwise evaluate the 'dhcp' field, if this has a valid
+	 * address then DHCP was used (broadcom sends 0.0.0.0).
 	 */
-	if (strlen(context->dhcp) && strcmp(context->dhcp, "0.0.0.0"))
+	if ((strlen(context->origin) && !strcmp(context->origin, "3")) ||
+	    (strlen(context->dhcp) && strcmp(context->dhcp, "0.0.0.0")))
 		printf("%s = DHCP\n", IFACE_BOOT_PROTO);
 	else
 		printf("%s = STATIC\n", IFACE_BOOT_PROTO);
diff --git a/utils/fwparam_ibft/fwparam_ibft_sysfs.c b/utils/fwparam_ibft/fwparam_ibft_sysfs.c
index 9185c85..2dc6f6d 100644
--- a/utils/fwparam_ibft/fwparam_ibft_sysfs.c
+++ b/utils/fwparam_ibft/fwparam_ibft_sysfs.c
@@ -201,6 +201,8 @@ static int fill_nic_context(char *id, struct boot_context *context)
 		      sizeof(context->secondary_dns));
 	sysfs_get_str(id, IBFT_SUBSYS, "dhcp", context->dhcp,
 		      sizeof(context->dhcp));
+	sysfs_get_str(id, IBFT_SUBSYS, "origin", context->origin,
+		      sizeof(context->origin));
 	return 0;
 }
 
diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c
index 2f37b59..09dd9fd 100644
--- a/utils/fwparam_ibft/fwparam_sysfs.c
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
@@ -217,6 +217,8 @@ static int fill_nic_context(char *subsys, char *id,
 		      sizeof(context->secondary_dns));
 	sysfs_get_str(id, subsys, "dhcp", context->dhcp,
 		      sizeof(context->dhcp));
+	sysfs_get_str(id, subsys, "origin", context->origin,
+		      sizeof(context->origin));
 	return 0;
 }
 
-- 
1.9.3