Hannes Reinecke wrote:
> 
> For boot from iSCSI we need to the fwparam_ibft program
> to setup the network correctly. This patch moves the
> fwparam_ibft files into a library and adds a new program
> fwparam_ibft to print out the network parameter.
> 

Why do you need a new program to print out the network info? I was 
working on the same problem, and was working on a patch to print it out 
with the rest of the ibft info. The patch was made over some RHEL/FC 
stuff that is used with the ibft sysfs module Konrad did (I or Konard 
will post the rest of the code later (I thought he had, but I did not 
see it on the list)).

I am not sure I care much which one we do. I just do not like the extra 
program because it is one more thing to remember, so I started the way I 
did.

Oh yeah, have you tried the ppc stuff yet? What does it print out for 
the netdevice? The ibft kernel module links to the net device sysfs dir 
which is nice, so you do not have to match MAC addrs.

Also what you going to do for DHCP? Are you just going to use the ip 
values from ibft? Makes sense. I am just asking, because I noticed weird 
behavior for that with intel and broadcom cards, and were wondering if 
you saw the same.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

diff -aurp open-iscsi-2.0-868-test1/include/fw_context.h open-iscsi-2.0-868-test1.work/include/fw_context.h
--- open-iscsi-2.0-868-test1/include/fw_context.h	2008-03-25 03:37:26.000000000 -0500
+++ open-iscsi-2.0-868-test1.work/include/fw_context.h	2008-03-25 03:37:37.000000000 -0500
@@ -23,21 +23,30 @@
 
 struct boot_context {
 #define IQNSZ (223+1)
+	/* target settings */
 	int target_port;
-	char initiatorname[IQNSZ];
 	char targetname[IQNSZ];
 	char target_ipaddr[32];
 	char chap_name[127];
 	char chap_password[16];
 	char chap_name_in[127];
 	char chap_password_in[16];
+
+	/* initiator settings */
+	char isid[10];
+	char initiatorname[IQNSZ];
+
+	/* network settings */
+	char dhcp[18];
 	char iface[42];
 	char mac[18];
 	char ipaddr[18];
+	char gateway[18];
+	char primary_dns[18];
+	char secondary_dns[18];
 	char mask[18];
 	char lun[17];
 	char vlan[15];
-	char isid[10];
 };
 
 extern int fw_get_entry(struct boot_context *context, const char *filepath);
diff -aurp open-iscsi-2.0-868-test1/utils/fwparam_ibft/fw_entry.c open-iscsi-2.0-868-test1.work/utils/fwparam_ibft/fw_entry.c
--- open-iscsi-2.0-868-test1/utils/fwparam_ibft/fw_entry.c	2008-03-25 03:37:26.000000000 -0500
+++ open-iscsi-2.0-868-test1.work/utils/fwparam_ibft/fw_entry.c	2008-03-25 03:37:37.000000000 -0500
@@ -34,24 +34,13 @@ int fw_get_entry(struct boot_context *co
 	return ret;
 }
 
-/*
- * Dump the 8 byte mac address
- */
-static void dump_mac(struct boot_context *context)
-{
-	int i;
-
-	if (!strlen(context->mac))
-		return;
-
-	printf("iface.hwaddress = %s\n", context->mac);
-}
-
 static void dump_initiator(struct boot_context *context)
 {
-	if (!strlen(context->initiatorname))
-		return;
-	printf("iface.initiatorname = %s\n", context->initiatorname);
+	if (strlen(context->initiatorname))
+		printf("iface.initiatorname = %s\n", context->initiatorname);
+
+	if (strlen(context->isid))
+		printf("iface.isid = %s\n", context->isid);
 }
 
 static void dump_target(struct boot_context *context)
@@ -75,11 +64,44 @@ static void dump_target(struct boot_cont
 	if (strlen(context->chap_password_in))
 		printf("node.session.auth.password_in = %s\n",
 		       context->chap_password_in);
+
+	if (strlen(context->lun))
+		printf("node.boot_lun = %s\n", context->lun);
+}
+
+/* TODO: add defines for all the idbm strings in this file and add a macro */
+static void dump_network(struct boot_context *context)
+{
+	/* Dump the 8 byte mac address (not iser support) */
+	if (strlen(context->mac))
+		printf("iface.hwaddress = %s\n", context->mac);
+	/*
+	 * 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"))
+		printf("iface.bootproto = DHCP\n");
+	else
+		printf("iface.bootproto = STATIC\n");
+	if (strlen(context->ipaddr))
+		printf("iface.ipaddress = %s\n", context->ipaddr);
+	if (strlen(context->mask))
+		printf("iface.subnet_mask = %s\n", context->mask);
+	if (strlen(context->gateway))
+		printf("iface.gateway = %s\n", context->gateway);
+	if (strlen(context->primary_dns))
+		printf("iface.primary_dns = %s\n", context->primary_dns);
+	if (strlen(context->secondary_dns))
+		printf("iface.secondary_dns = %s\n", context->secondary_dns);
+	if (strlen(context->vlan))
+		printf("iface.vlan = %s\n", context->vlan);
+	if (strlen(context->iface))
+		printf("iface.net_ifacename = %s\n", context->iface);
 }
 
 void fw_print_entry(struct boot_context *context)
 {
 	dump_initiator(context);
-	dump_mac(context);
+	dump_network(context);
 	dump_target(context);
 }
diff -aurp open-iscsi-2.0-868-test1/utils/fwparam_ibft/fwparam_ibft_sysfs.c open-iscsi-2.0-868-test1.work/utils/fwparam_ibft/fwparam_ibft_sysfs.c
--- open-iscsi-2.0-868-test1/utils/fwparam_ibft/fwparam_ibft_sysfs.c	2008-03-25 03:37:26.000000000 -0500
+++ open-iscsi-2.0-868-test1.work/utils/fwparam_ibft/fwparam_ibft_sysfs.c	2008-03-25 04:08:10.000000000 -0500
@@ -24,11 +24,15 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
-#include "fwparam_ibft.h"
+#include <dirent.h>
 #include <fw_context.h>
+#include <sys/types.h>
+
+#include "fwparam_ibft.h"
 
 #define IBFT_MAX 255
 #define IBFT_SYSFS_ROOT "/sys/firmware/ibft/"
+#define IBFT_SYSFS_DE
 
 static char *target_list[IBFT_MAX];
 static char *nic_list[IBFT_MAX];
@@ -143,6 +147,48 @@ static int find_sysfs_dirs(const char *f
 	return 0;
 }
 
+static int get_iface_from_device(const char *eth_dir,
+				 struct boot_context *context)
+{
+	char dev_dir[FILENAMESZ];
+	int rc = ENODEV;
+	DIR *dirfd;
+	struct dirent *dent;
+
+	memset(dev_dir, 0, FILENAMESZ);
+	strncat(dev_dir, eth_dir, FILENAMESZ);
+	strncat(dev_dir, "/device", FILENAMESZ);
+
+	if (!file_exist(dev_dir))
+		return 0;
+
+	dirfd = opendir(dev_dir);
+	if (!dirfd)
+		return errno;
+
+	while ((dent = readdir(dirfd))) {
+		if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
+			continue;
+
+		if (strncmp(dent->d_name, "net:", 4))
+			continue;
+
+		if ((strlen(dent->d_name) - 4) > (sizeof(context->iface) - 1)) {
+			rc = EINVAL;
+			printf("Net device %s too bug for iface buffer.\n",
+			       dent->d_name);
+			break;
+		}
+
+		if (sscanf(dent->d_name, "net:%s", context->iface) != 1)
+			rc = EINVAL;
+		rc = 0;
+		break;
+	}
+
+	return rc;
+}
+
 /*
  * Routines to fill in the context values.
  */
@@ -154,7 +200,17 @@ static int fill_nic_context(const char *
 	rc |= read_data(dir, "/vlan", context->vlan, sizeof(context->vlan));
 	rc |= read_data(dir, "/ip-addr", context->ipaddr,
 		sizeof(context->ipaddr));
-	rc |= read_data(dir, "/mask", context->mask, sizeof(context->mask));
+	rc |= read_data(dir, "/subnet-mask", context->mask,
+			sizeof(context->mask));
+	rc |= read_data(dir, "/gateway", context->gateway,
+			sizeof(context->gateway));
+	rc |= read_data(dir, "/primary-dns", context->primary_dns,
+			sizeof(context->primary_dns));
+	rc |= read_data(dir, "/secondary-dns", context->secondary_dns,
+			sizeof(context->secondary_dns));
+	rc |= read_data(dir, "/dhcp", context->dhcp, sizeof(context->dhcp));
+
+	rc |= get_iface_from_device(dir, context);
 
 	return rc;
 }
@@ -199,7 +255,7 @@ static int fill_tgt_context(const char *
 static int find_boot_flag(char *list[], ssize_t size, int *boot_idx)
 {
 	int rc = -1;
-	int i, flag = -1;
+	int i, flag = 0;
 
 	for (i = 0; i < size; i++, flag = -1) {
 		rc = read_int_data(list[i], IBFT_SYSFS_FLAG_NAME, &flag);
@@ -208,6 +264,8 @@ static int find_boot_flag(char *list[], 
 			rc = 0;
 			break;
 		}
+		rc = -1;
+		flag = 0;
 
 	}
 

Reply via email to