3f3ec35
From 78e24f50ab754f35f4aa208ade7c9fd794d82036 Mon Sep 17 00:00:00 2001
3f3ec35
From: Hannes Reinecke <hare@suse.de>
3f3ec35
Date: Tue, 1 Jul 2014 11:14:57 +0200
3f3ec35
Subject: [PATCH] Parse 'origin' value from iBFT
3f3ec35
3f3ec35
iBFT has an 'origin' field which indicates the origin of the
3f3ec35
network address. If that is set to '3' it indicates that
3f3ec35
DHCP has been used; there is no need to evaluate the 'dhcp'
3f3ec35
field here.
3f3ec35
In fact. latest iPXE sets the 'origin' field, but not the
3f3ec35
'dhcp' field.
3f3ec35
3f3ec35
Signed-off-by: Hannes Reinecke <hare@suse.de>
3f3ec35
---
3f3ec35
 include/fw_context.h                    | 1 +
3f3ec35
 utils/fwparam_ibft/fw_entry.c           | 8 +++++---
3f3ec35
 utils/fwparam_ibft/fwparam_ibft_sysfs.c | 2 ++
3f3ec35
 utils/fwparam_ibft/fwparam_sysfs.c      | 2 ++
3f3ec35
 4 files changed, 10 insertions(+), 3 deletions(-)
3f3ec35
3f3ec35
diff --git a/include/fw_context.h b/include/fw_context.h
3f3ec35
index 6563d68..295b54d 100644
3f3ec35
--- a/include/fw_context.h
3f3ec35
+++ b/include/fw_context.h
3f3ec35
@@ -48,6 +48,7 @@ struct boot_context {
3f3ec35
 	char initiatorname[TARGET_NAME_MAXLEN + 1];
3f3ec35
 
3f3ec35
 	/* network settings */
3f3ec35
+	char origin[2];
3f3ec35
 	char dhcp[NI_MAXHOST];
3f3ec35
 	char iface[IF_NAMESIZE];
3f3ec35
 	char mac[18];
3f3ec35
diff --git a/utils/fwparam_ibft/fw_entry.c b/utils/fwparam_ibft/fw_entry.c
3f3ec35
index b6f05c1..295e905 100644
3f3ec35
--- a/utils/fwparam_ibft/fw_entry.c
3f3ec35
+++ b/utils/fwparam_ibft/fw_entry.c
3f3ec35
@@ -192,10 +192,12 @@ static void dump_network(struct boot_context *context)
3f3ec35
 	if (strlen(context->mac))
3f3ec35
 		printf("%s = %s\n", IFACE_HWADDR, context->mac);
3f3ec35
 	/*
3f3ec35
-	 * If this has a valid address then DHCP was used (broadcom sends
3f3ec35
-	 * 0.0.0.0).
3f3ec35
+	 * If the 'origin' field is '3' then DHCP is used.
3f3ec35
+	 * Otherwise evaluate the 'dhcp' field, if this has a valid
3f3ec35
+	 * address then DHCP was used (broadcom sends 0.0.0.0).
3f3ec35
 	 */
3f3ec35
-	if (strlen(context->dhcp) && strcmp(context->dhcp, "0.0.0.0"))
3f3ec35
+	if ((strlen(context->origin) && !strcmp(context->origin, "3")) ||
3f3ec35
+	    (strlen(context->dhcp) && strcmp(context->dhcp, "0.0.0.0")))
3f3ec35
 		printf("%s = DHCP\n", IFACE_BOOT_PROTO);
3f3ec35
 	else
3f3ec35
 		printf("%s = STATIC\n", IFACE_BOOT_PROTO);
3f3ec35
diff --git a/utils/fwparam_ibft/fwparam_ibft_sysfs.c b/utils/fwparam_ibft/fwparam_ibft_sysfs.c
3f3ec35
index 9185c85..2dc6f6d 100644
3f3ec35
--- a/utils/fwparam_ibft/fwparam_ibft_sysfs.c
3f3ec35
+++ b/utils/fwparam_ibft/fwparam_ibft_sysfs.c
3f3ec35
@@ -201,6 +201,8 @@ static int fill_nic_context(char *id, struct boot_context *context)
3f3ec35
 		      sizeof(context->secondary_dns));
3f3ec35
 	sysfs_get_str(id, IBFT_SUBSYS, "dhcp", context->dhcp,
3f3ec35
 		      sizeof(context->dhcp));
3f3ec35
+	sysfs_get_str(id, IBFT_SUBSYS, "origin", context->origin,
3f3ec35
+		      sizeof(context->origin));
3f3ec35
 	return 0;
3f3ec35
 }
3f3ec35
 
3f3ec35
diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c
3f3ec35
index 2f37b59..09dd9fd 100644
3f3ec35
--- a/utils/fwparam_ibft/fwparam_sysfs.c
3f3ec35
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
3f3ec35
@@ -217,6 +217,8 @@ static int fill_nic_context(char *subsys, char *id,
3f3ec35
 		      sizeof(context->secondary_dns));
3f3ec35
 	sysfs_get_str(id, subsys, "dhcp", context->dhcp,
3f3ec35
 		      sizeof(context->dhcp));
3f3ec35
+	sysfs_get_str(id, subsys, "origin", context->origin,
3f3ec35
+		      sizeof(context->origin));
3f3ec35
 	return 0;
3f3ec35
 }
3f3ec35
 
3f3ec35
-- 
3f3ec35
1.9.3
3f3ec35