Hi Mike: Here are the updated patches, based on your feedback:
0001-Code-cleanup-no-functional-changes.patch 0002-Represent-DHCP-origin-as-an-enum-not-a-string.patch 0003-fwparam_ibft-Check-iBFT-target-and-NIC-flags.patch 0004-Allow-modifications-for-iface.gateway-and-iface.subn.patch Changes from last version: patch 2: uses an enum now. Not sure if the state should be kept as an integer or an enum. feedback welcome also, the original path 4 was removed, for later discussion (once we get prefix-len figured out). Patches are attached (since the groups.google.com interface doesn't easily do plain text) Thanks. -- Lee Duncan -- 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 7517894b701e13f43aafb0dc7f8301a53cf67d97 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke <[email protected]> Date: Wed, 29 Oct 2014 11:03:56 -0700 Subject: [PATCH 1/4] 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)); -- 2.1.2
>From 6d094af5064206b36f99c338f6447293f197425e Mon Sep 17 00:00:00 2001 From: Hannes Reinecke <[email protected]> Date: Fri, 14 Nov 2014 11:19:10 -0800 Subject: [PATCH 2/4] Represent DHCP "origin" as an enum, not a string. See IBFT standard for location of "origin" field in iBFT table, and see MS document: http://msdn.microsoft.com/en-us/library/aa366281.aspx for description of enums, duplicated here in part: typedef enum { IpPrefixOriginOther = 0, IpPrefixOriginManual, IpPrefixOriginWellKnown, IpPrefixOriginDhcp, IpPrefixOriginRouterAdvertisement, IpPrefixOriginUnchanged = 16 } IP_PREFIX_ORIGIN; --- include/fw_context.h | 11 ++++++++++- utils/fwparam_ibft/fw_entry.c | 5 +++-- utils/fwparam_ibft/fwparam_sysfs.c | 3 +-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/fw_context.h b/include/fw_context.h index 295b54d3d0c9..6a7ec1a64967 100644 --- a/include/fw_context.h +++ b/include/fw_context.h @@ -28,6 +28,15 @@ #include "list.h" #include "auth.h" +enum ibft_ip_prefix_origin { + IBFT_IP_PREFIX_ORIGIN_OTHER = 0, + IBFT_IP_PREFIX_ORIGIN_MANUAL, + IBFT_IP_PREFIX_ORIGIN_WELL_KNOWN, + IBFT_IP_PREFIX_ORIGIN_DHCP, + IBFT_IP_PREFIX_ORIGIN_ROUTER_ADVERTISEMENT, + IBFT_IP_PREFIX_ORIGIN_UNCHANGED = 16 +}; + struct boot_context { struct list_head list; char boot_root[BOOT_NAME_MAXLEN]; @@ -48,7 +57,7 @@ struct boot_context { char initiatorname[TARGET_NAME_MAXLEN + 1]; /* network settings */ - char origin[2]; + enum ibft_ip_prefix_origin 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..f94a03531988 100644 --- a/utils/fwparam_ibft/fw_entry.c +++ b/utils/fwparam_ibft/fw_entry.c @@ -192,11 +192,12 @@ static void dump_network(struct boot_context *context) if (strlen(context->mac)) printf("%s = %s\n", IFACE_HWADDR, context->mac); /* - * If the 'origin' field is '3' then DHCP is used. + * If the 'origin' field is 3 (IBFT_IP_PREFIX_ORIGIN_DHCP), + * 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->origin) && !strcmp(context->origin, "3")) || + if ((context->origin == IBFT_IP_PREFIX_ORIGIN_DHCP) || (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..cd87b68d02ad 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", (int *)&context->origin); return 0; } -- 2.1.2
>From ad0d7d5cbe6ebc603ea57d8fe15b1e5ec47ebb06 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke <[email protected]> Date: Thu, 30 Oct 2014 18:00:30 -0700 Subject: [PATCH 3/4] 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 6a7ec1a64967..44053d868544 100644 --- a/include/fw_context.h +++ b/include/fw_context.h @@ -44,6 +44,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]; @@ -57,6 +58,7 @@ struct boot_context { char initiatorname[TARGET_NAME_MAXLEN + 1]; /* network settings */ + int nic_flags; enum ibft_ip_prefix_origin 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 cd87b68d02ad..c5b0b004c657 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) -- 2.1.2
>From 6102ded59288bfd08d17a08af5e66d8bdc57a3ac Mon Sep 17 00:00:00 2001 From: Hannes Reinecke <[email protected]> Date: Fri, 14 Nov 2014 11:29:56 -0800 Subject: [PATCH 4/4] 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 1ade0994d338..cd5462a9aeaa 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); /* * svn 780 compat: older versions used node.transport_name and * rec->transport_name @@ -283,10 +285,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); -- 2.1.2
