Hi Mike:
Attached are 5 patches. These are based on the patch set I sent in September
of this year.
0001-Code-cleanup-no-functional-changes.patch
I broke out the cleanup changes, as you requested
0002-Represent-DHCP-origin-as-an-integer-not-string.patch
This just changes the "origin" attribute from a string, to a number,
which
is what it really is.
0003-fwparam_ibft-Check-iBFT-target-and-NIC-flags.patch
This was the patch that you had problems with last time, and
for good reason, as it checks iBFT flags for Bit-0, as per the
iBFT standard, but as you pointed out many adapters don't
follow the standard and instead set Bit-1. So now we just check
for any bit being set. This *has* been tested with more adapters.
Good catch on the first version.
0004-Fixup-IPv6-iBFT-interface-description.patch
This patch adds "prefix-len" to the open-iscsi attributes, as it
is needed for IPv6, which doesn't use "mask" like IPv4 does.
0005-Allow-modifications-for-iface.gateway-and-iface.subn.patch
This patch just allows gateway and subnet to be even if the
target isn't connected to the local network.
--
You received this message because you are subscribed to the Google Groups
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.
>From 329e752c50a0ac1393c0a4d02708db9fd8f9232d Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[email protected]>
Date: Wed, 29 Oct 2014 11:03:56 -0700
Subject: [PATCH 1/5] Code cleanup: no functional changes
---
usr/iface.c | 3 ++-
utils/fwparam_ibft/fw_entry.c | 8 ++++----
utils/fwparam_ibft/fwparam_sysfs.c | 4 ++--
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/usr/iface.c b/usr/iface.c
index 870dba0a1fcc..940ee2388945 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -1002,7 +1002,8 @@ int iface_setup_from_boot_context(struct iface_rec *iface,
sizeof(iface->iname));
if (strlen(context->scsi_host_name)) {
- if (sscanf(context->scsi_host_name, "iscsi_boot%u", &hostno) != 1) {
+ if (sscanf(context->scsi_host_name,
+ "iscsi_boot%u", &hostno) != 1) {
log_error("Could not parse %s's host no.",
context->scsi_host_name);
return 0;
diff --git a/utils/fwparam_ibft/fw_entry.c b/utils/fwparam_ibft/fw_entry.c
index 295e905620eb..9f0797fdceb2 100644
--- a/utils/fwparam_ibft/fw_entry.c
+++ b/utils/fwparam_ibft/fw_entry.c
@@ -67,15 +67,15 @@ int fw_setup_nics(void)
* to force iSCSI traffic through correct NIC
*/
list_for_each_entry(context, &targets, list) {
- /* if it is a offload nic ignore it */
- if (!net_get_transport_name_from_netdev(context->iface,
+ /* if it is a offload nic ignore it */
+ if (!net_get_transport_name_from_netdev(context->iface,
transport))
continue;
if (iface_prev == NULL || strcmp(context->iface, iface_prev)) {
/* Note: test above works because there is a
- * maximum of two targets in the iBFT
- */
+ * maximum of two targets in the iBFT
+ */
iface_prev = context->iface;
needs_bringup = 1;
}
diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c
index 09dd9fd5cbbc..b5319063785b 100644
--- a/utils/fwparam_ibft/fwparam_sysfs.c
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
@@ -325,7 +325,7 @@ static int get_boot_info(struct boot_context *context, char *rootdir,
nic_cnt = 0;
tgt_cnt = 0;
if (file_exist(initiator_dir)) {
- /* Find the target's and the ethernet's */
+ /* Find the targets and the ethernets */
rc = nftw(rootdir, find_sysfs_dirs, 20, 1);
/* Find wihch target and which ethernet have
@@ -401,7 +401,7 @@ static int get_targets(struct list_head *list, char *rootdir, char *subsys)
nic_cnt = 0;
tgt_cnt = 0;
- /* Find the target's and the ethernet's */
+ /* Find the targets and the ethernets */
nftw(rootdir, find_sysfs_dirs, 20, 1);
for (i = 0; i < tgt_cnt; i++) {
context = calloc(1, sizeof(*context));
--
1.8.4.5
>From d996429fb9c373c6c4f44aeb8a16664b6fc10f64 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[email protected]>
Date: Wed, 29 Oct 2014 09:07:45 -0700
Subject: [PATCH 2/5] Represent DHCP "origin" as an integer, not string.
---
include/fw_context.h | 2 +-
utils/fwparam_ibft/fw_entry.c | 2 +-
utils/fwparam_ibft/fwparam_sysfs.c | 3 +--
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/include/fw_context.h b/include/fw_context.h
index 295b54d3d0c9..57371b55c049 100644
--- a/include/fw_context.h
+++ b/include/fw_context.h
@@ -48,7 +48,7 @@ struct boot_context {
char initiatorname[TARGET_NAME_MAXLEN + 1];
/* network settings */
- char origin[2];
+ int origin;
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 9f0797fdceb2..79396ff39630 100644
--- a/utils/fwparam_ibft/fw_entry.c
+++ b/utils/fwparam_ibft/fw_entry.c
@@ -196,7 +196,7 @@ static void dump_network(struct boot_context *context)
* Otherwise evaluate the 'dhcp' field, if this has a valid
* address then DHCP was used (broadcom sends 0.0.0.0).
*/
- if ((strlen(context->origin) && !strcmp(context->origin, "3")) ||
+ if ((context->origin == 3) ||
(strlen(context->dhcp) && strcmp(context->dhcp, "0.0.0.0")))
printf("%s = DHCP\n", IFACE_BOOT_PROTO);
else
diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c
index b5319063785b..9f156ef1fd68 100644
--- a/utils/fwparam_ibft/fwparam_sysfs.c
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
@@ -217,8 +217,7 @@ 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));
+ sysfs_get_int(id, subsys, "origin", &context->origin);
return 0;
}
--
1.8.4.5
>From 5731cb0e533f12d20743061f86ee0caa808f8db5 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[email protected]>
Date: Thu, 30 Oct 2014 18:00:30 -0700
Subject: [PATCH 3/5] fwparam_ibft: Check iBFT target and NIC flags
Check the iBFT NIC and Target flags for valid boot.
Since some adapters correctly set Bit 0 and others
set Bit 1 for NICs, allow either value there.
Signed-off-by: Lee Duncan <[email protected]>
---
include/fw_context.h | 2 ++
utils/fwparam_ibft/fwparam_sysfs.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/include/fw_context.h b/include/fw_context.h
index 57371b55c049..8544d5eff52a 100644
--- a/include/fw_context.h
+++ b/include/fw_context.h
@@ -35,6 +35,7 @@ struct boot_context {
char boot_target[BOOT_NAME_MAXLEN];
/* target settings */
+ int target_flags;
int target_port;
char targetname[TARGET_NAME_MAXLEN + 1];
char target_ipaddr[NI_MAXHOST];
@@ -48,6 +49,7 @@ struct boot_context {
char initiatorname[TARGET_NAME_MAXLEN + 1];
/* network settings */
+ int nic_flags;
int origin;
char dhcp[NI_MAXHOST];
char iface[IF_NAMESIZE];
diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c
index 9f156ef1fd68..1d7762e34c24 100644
--- a/utils/fwparam_ibft/fwparam_sysfs.c
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
@@ -170,6 +170,18 @@ static int fill_nic_context(char *subsys, char *id,
{
int rc;
+ rc = sysfs_get_int(id, subsys, "flags", &context->nic_flags);
+ /*
+ * Per spec we would need to check against Bit 0
+ * (Block Valid Flag), but some firmware only
+ * sets Bit 1 (Firmware Booting Selected).
+ * So any setting is deemed okay.
+ */
+ if (!rc && (context->nic_flags == 0))
+ rc = ENODEV;
+ if (rc)
+ return rc;
+
rc = sysfs_get_str(id, subsys, "mac", context->mac,
sizeof(context->mac));
if (rc)
@@ -236,6 +248,18 @@ static int fill_tgt_context(char *subsys, char *id,
{
int rc;
+ rc = sysfs_get_int(id, subsys, "flags", &context->target_flags);
+ /*
+ * Per spec we would need to check against Bit 0
+ * (Block Valid Flag), but some firmware only
+ * sets Bit 1 (Firmware Booting Selected).
+ * So any setting is deemed okay.
+ */
+ if (!rc && (context->nic_flags == 0))
+ rc = ENODEV;
+ if (rc)
+ return rc;
+
rc = sysfs_get_str(id, subsys, "target-name", context->targetname,
sizeof(context->targetname));
if (rc)
--
1.8.4.5
>From bf87ef4c5a10bd5165fd9f5f6b9f97b93648c8a7 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[email protected]>
Date: Wed, 29 Oct 2014 11:36:15 -0700
Subject: [PATCH 4/5] Fixup IPv6 iBFT interface description
The kernel iBFT implementation had an issue with IPv6 addresses,
which required the implementation of an additional 'prefix-len'
parameter. This patch updates the open-iscsi code to use and
display this attribute if present.
---
include/fw_context.h | 1 +
usr/config.h | 1 +
usr/idbm.c | 3 +++
usr/idbm_fields.h | 1 +
utils/fwparam_ibft/fw_entry.c | 2 ++
utils/fwparam_ibft/fwparam_sysfs.c | 1 +
6 files changed, 9 insertions(+)
diff --git a/include/fw_context.h b/include/fw_context.h
index 8544d5eff52a..76fd14ac4ef8 100644
--- a/include/fw_context.h
+++ b/include/fw_context.h
@@ -51,6 +51,7 @@ struct boot_context {
/* network settings */
int nic_flags;
int origin;
+ int prefix;
char dhcp[NI_MAXHOST];
char iface[IF_NAMESIZE];
char mac[18];
diff --git a/usr/config.h b/usr/config.h
index fd31a54d0130..2e36a0a164b6 100644
--- a/usr/config.h
+++ b/usr/config.h
@@ -225,6 +225,7 @@ typedef struct iface_rec {
char ipv6_autocfg[NI_MAXHOST];
char linklocal_autocfg[NI_MAXHOST];
char router_autocfg[NI_MAXHOST];
+ uint8_t prefix_len;
uint16_t vlan_id;
uint8_t vlan_priority;
char vlan_state[ISCSI_MAX_STR_LEN];
diff --git a/usr/idbm.c b/usr/idbm.c
index 1ade0994d338..d91ccb1577d9 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -262,6 +262,8 @@ idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
__recinfo_str(IFACE_IPADDR, ri, r, iface.ipaddress, IDBM_SHOW, num, 1);
__recinfo_str(IFACE_ISCSINAME, ri, r, iface.name, IDBM_SHOW, num, 1);
__recinfo_str(IFACE_NETNAME, ri, r, iface.netdev, IDBM_SHOW, num, 1);
+ __recinfo_uint8(IFACE_PREFIX_LEN, ri, r, iface.prefix_len,
+ IDBM_SHOW, num, 1);
/*
* svn 780 compat: older versions used node.transport_name and
* rec->transport_name
@@ -533,6 +535,7 @@ void idbm_recinfo_iface(iface_rec_t *r, recinfo_t *ri)
__recinfo_str(IFACE_ISCSINAME, ri, r, name, IDBM_SHOW, num, 0);
__recinfo_str(IFACE_NETNAME, ri, r, netdev, IDBM_SHOW, num, 1);
__recinfo_str(IFACE_IPADDR, ri, r, ipaddress, IDBM_SHOW, num, 1);
+ __recinfo_uint8(IFACE_PREFIX_LEN, ri, r, prefix_len, IDBM_SHOW, num, 1);
__recinfo_str(IFACE_HWADDR, ri, r, hwaddress, IDBM_SHOW, num, 1);
__recinfo_str(IFACE_TRANSPORTNAME, ri, r, transport_name,
IDBM_SHOW, num, 1);
diff --git a/usr/idbm_fields.h b/usr/idbm_fields.h
index 5790a033d241..c6af3cde2ee8 100644
--- a/usr/idbm_fields.h
+++ b/usr/idbm_fields.h
@@ -73,6 +73,7 @@
#define IFACE_ISID "iface.isid"
#define IFACE_BOOT_PROTO "iface.bootproto"
#define IFACE_IPADDR "iface.ipaddress"
+#define IFACE_PREFIX_LEN "iface.prefix_len"
#define IFACE_SUBNET_MASK "iface.subnet_mask"
#define IFACE_GATEWAY "iface.gateway"
#define IFACE_PRIMARY_DNS "iface.primary_dns"
diff --git a/utils/fwparam_ibft/fw_entry.c b/utils/fwparam_ibft/fw_entry.c
index 79396ff39630..ddcf516556d9 100644
--- a/utils/fwparam_ibft/fw_entry.c
+++ b/utils/fwparam_ibft/fw_entry.c
@@ -203,6 +203,8 @@ static void dump_network(struct boot_context *context)
printf("%s = STATIC\n", IFACE_BOOT_PROTO);
if (strlen(context->ipaddr))
printf("%s = %s\n", IFACE_IPADDR, context->ipaddr);
+ if (context->prefix)
+ printf("%s = %d\n", IFACE_PREFIX_LEN, context->prefix);
if (strlen(context->mask))
printf("%s = %s\n", IFACE_SUBNET_MASK, context->mask);
if (strlen(context->gateway))
diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c
index 1d7762e34c24..4e3fd0dd780e 100644
--- a/utils/fwparam_ibft/fwparam_sysfs.c
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
@@ -221,6 +221,7 @@ static int fill_nic_context(char *subsys, char *id,
sizeof(context->vlan));
sysfs_get_str(id, subsys, "subnet-mask", context->mask,
sizeof(context->mask));
+ sysfs_get_int(id, subsys, "prefix-len", &context->prefix);
sysfs_get_str(id, subsys, "gateway", context->gateway,
sizeof(context->gateway));
sysfs_get_str(id, subsys, "primary-dns", context->primary_dns,
--
1.8.4.5
>From b429ad58c95658355edc26cf76aa275de9e2ee8b Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[email protected]>
Date: Wed, 29 Oct 2014 11:47:24 -0700
Subject: [PATCH 5/5] Allow modifications for iface.gateway and
iface.subnet_mask
For proper operations we need to set gateway and subnet_mask
of the individual interfaces. Not every target is connected
to the local network.
---
usr/idbm.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/usr/idbm.c b/usr/idbm.c
index d91ccb1577d9..d281414f156a 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -262,6 +262,8 @@ idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
__recinfo_str(IFACE_IPADDR, ri, r, iface.ipaddress, IDBM_SHOW, num, 1);
__recinfo_str(IFACE_ISCSINAME, ri, r, iface.name, IDBM_SHOW, num, 1);
__recinfo_str(IFACE_NETNAME, ri, r, iface.netdev, IDBM_SHOW, num, 1);
+ __recinfo_str(IFACE_GATEWAY, ri, r, iface.gateway, IDBM_SHOW, num, 1);
+ __recinfo_str(IFACE_SUBNET_MASK, ri, r, iface.subnet_mask, IDBM_SHOW, num, 1);
__recinfo_uint8(IFACE_PREFIX_LEN, ri, r, iface.prefix_len,
IDBM_SHOW, num, 1);
/*
@@ -285,10 +287,6 @@ idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
if (iface_type == ISCSI_IFACE_TYPE_IPV4) {
__recinfo_str(IFACE_BOOT_PROTO, ri, r, iface.bootproto,
IDBM_SHOW, num, 1);
- __recinfo_str(IFACE_SUBNET_MASK, ri, r, iface.subnet_mask,
- IDBM_SHOW, num, 1);
- __recinfo_str(IFACE_GATEWAY, ri, r, iface.gateway, IDBM_SHOW,
- num, 1);
__recinfo_str(IFACE_DHCP_ALT_CID, ri, r,
iface.dhcp_alt_client_id_state, IDBM_SHOW,
num, 1);
--
1.8.4.5