Antw: [PATCH] iscsi tools: Convert '-r' argument to an integer before checking if it is a path
Jim Ramsay jim_ram...@dell.com schrieb am 03.10.2012 um 15:57 in Nachricht 1349272663-18322-1-git-send-email-jim_ram...@dell.com: If there is a file in the CWD named '1' and you were trying to run 'iscsiadm -m session -r 1 ...', the command would fail with 1 is not a directory. Root cause: The code that parses the -r option's argument tries lstat(2) first, falling back to atoi(3) only if lstat fails. This change inverts the order of checks, first with strtol(3) to see if the argument given is a positive integer, then falling back to lstat(2) only if it is not. Signed-off-by: Jim Ramsay jim_ram...@dell.com --- usr/iscsi_sysfs.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c index 123dde3..4015b35 100644 --- a/usr/iscsi_sysfs.c +++ b/usr/iscsi_sysfs.c [...] @@ -748,15 +748,16 @@ int iscsi_sysfs_get_sid_from_path(char *session) struct sysfs_device *dev_parent, *dev; struct stat statb; char devpath[PATH_SIZE]; + char *end; + int sid; + + sid = strtol(session, end, 10); + if (sid 0 *session != '\0' *end == '\0') Hi! I think the *session != '\0' is redundant as compared to sid 0. Regards, Ulrich + return sid; if (lstat(session, statb)) { - log_debug(1, Could not stat %s failed with %d, - session, errno); - if (index(session, '/')) { - log_error(%s is an invalid session path\n, session); - exit(1); - } - return atoi(session); + log_error(%s is an invalid session ID or path\n, session); + exit(1); } if (!S_ISDIR(statb.st_mode) !S_ISLNK(statb.st_mode)) { -- 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 open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
[PATCH 0/4] ISCSITOOLS: Patchset to add the extraction of ibft net attributes
For the case when iscsid is invoked for the first time after pivot root during iSCSI boot, the boot connection would fail to re-connect if the ibft/iscsi_boot sysfs entry contains tagged vlan. The problem was caused by the lack of such info in the iscsi_session sysfs for sync_session to inherit from. The enclosed patchset does the following: 1. Extract and save the ibft-ethernetN name to the boot_context-boot_nic 2. Pass the boot_nic info to be saved to the sessionN sysfs 3. Extract the sessionN boot_nic sysfs info and retrieve the corresponding net params This 'boot_nic' kernel session sysfs entry will only be present for ibft boot. Corresponding kernel drivers will have to add the ISCSI_PARAM_BOOT_NIC attribute to its attr_is_visible table. The last patch provides the fix for the unconditional overwrite of the iface struct even after the ibft net info was already extracted. Please review. Thanks. Eddie Eddie Wai (4): ISCSISTART: Saved ibft ethernetN to the session sysfs LIBISCSI: Added boot_nic session sysfs ISCSID: Added the extraction of the session boot_nic info ISCSID: Added iface content override fix include/fw_context.h |1 + include/iscsi_if.h |3 +++ kernel/libiscsi.c |6 ++ kernel/libiscsi.h |2 ++ kernel/scsi_transport_iscsi.c |2 ++ usr/config.h |1 + usr/idbm.c |2 ++ usr/initiator_common.c |6 +- usr/iscsi_sysfs.c | 25 - usr/iscsid.c |8 +++- utils/fwparam_ibft/fwparam_sysfs.c |4 11 files changed, 53 insertions(+), 7 deletions(-) -- 1.7.7.4 -- 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 open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
[PATCH 3/4] ISCSID: Added the extraction of the session boot_nic info
This patch does the work to extract the corresponding ibft-ethernetN net params as specified from the kernel session boot_nic sysfs entry. Signed-off-by: Eddie Wai eddie@broadcom.com --- include/iscsi_if.h |3 +++ usr/iscsi_sysfs.c | 25 - 2 files changed, 27 insertions(+), 1 deletions(-) diff --git a/include/iscsi_if.h b/include/iscsi_if.h index dad9fd8..498117d 100644 --- a/include/iscsi_if.h +++ b/include/iscsi_if.h @@ -460,6 +460,9 @@ enum iscsi_param { ISCSI_PARAM_TGT_RESET_TMO, ISCSI_PARAM_TARGET_ALIAS, + + ISCSI_PARAM_BOOT_NIC, + /* must always be last */ ISCSI_PARAM_MAX, }; diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c index 4015b35..a4095b5 100644 --- a/usr/iscsi_sysfs.c +++ b/usr/iscsi_sysfs.c @@ -53,6 +53,7 @@ #define ISCSI_IFACE_SUBSYS iscsi_iface #define SCSI_HOST_SUBSYS scsi_host #define SCSI_SUBSYSscsi +#define ISCSI_IBFT_SUBSYS ibft #define ISCSI_SESSION_ID session%d #define ISCSI_CONN_ID connection%d:0 @@ -793,7 +794,7 @@ int iscsi_sysfs_get_sid_from_path(char *session) int iscsi_sysfs_get_sessioninfo_by_id(struct session_info *info, char *session) { - char id[NAME_SIZE]; + char id[NAME_SIZE], boot_nic[NAME_SIZE]; int ret, pers_failed = 0; uint32_t host_no; @@ -920,6 +921,28 @@ int iscsi_sysfs_get_sessioninfo_by_id(struct session_info *info, char *session) iscsi_sysfs_read_iface(info-iface, host_no, session, NULL); + ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, boot_nic, + boot_nic, NAME_SIZE); + if (!ret) { + /* If boot_nic exist, then extract the info from the boot nic */ + ret = sysfs_get_str(boot_nic, ISCSI_IBFT_SUBSYS, + vlan, id, NAME_SIZE); + if (ret) + log_debug(5, could not read %s/vlan: %d, + boot_nic, ret); + else + info-iface.vlan_id = atoi(id); + + ret = sysfs_get_str(boot_nic, ISCSI_IBFT_SUBSYS, + subnet-mask, info-iface.subnet_mask, + NI_MAXHOST); + if (ret) + log_debug(5, could not read %s/subnet: %d, + boot_nic, ret); + } else { + log_debug(5, could not read boot_nic: %d, ret); + } + log_debug(7, found targetname %s address %s pers address %s port %d pers port %d driver %s iface name %s ipaddress %s netdev %s hwaddress %s iname %s, -- 1.7.7.4 -- 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 open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
[PATCH 2/4] LIBISCSI: Added boot_nic session sysfs
Kernel component to enable the new 'boot_nic' param in the kernel session sysfs. Signed-off-by: Eddie Wai eddie@broadcom.com --- kernel/libiscsi.c |6 ++ kernel/libiscsi.h |2 ++ kernel/scsi_transport_iscsi.c |2 ++ 3 files changed, 10 insertions(+), 0 deletions(-) diff --git a/kernel/libiscsi.c b/kernel/libiscsi.c index 59e3a5f..56cf22a 100644 --- a/kernel/libiscsi.c +++ b/kernel/libiscsi.c @@ -2833,6 +2833,7 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) kfree(session-username_in); kfree(session-targetname); kfree(session-initiatorname); + kfree(session-boot_nic); kfree(session-ifacename); iscsi_destroy_session(cls_session); @@ -3279,6 +3280,8 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn, return iscsi_switch_str_param(session-ifacename, buf); case ISCSI_PARAM_INITIATOR_NAME: return iscsi_switch_str_param(session-initiatorname, buf); + case ISCSI_PARAM_BOOT_NIC: + return iscsi_switch_str_param(session-boot_nic, buf); default: return -ENOSYS; } @@ -3354,6 +3357,9 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session, case ISCSI_PARAM_INITIATOR_NAME: len = sprintf(buf, %s\n, session-initiatorname); break; + case ISCSI_PARAM_BOOT_NIC: + len = sprintf(buf, %s\n, session-boot_nic); + break; default: return -ENOSYS; } diff --git a/kernel/libiscsi.h b/kernel/libiscsi.h index 0563539..762692c 100644 --- a/kernel/libiscsi.h +++ b/kernel/libiscsi.h @@ -287,6 +287,8 @@ struct iscsi_session { char*targetname; char*ifacename; char*initiatorname; + char*boot_nic; + /* control data */ struct iscsi_transport *tt; struct Scsi_Host*host; diff --git a/kernel/scsi_transport_iscsi.c b/kernel/scsi_transport_iscsi.c index fed8c9e..6f23318 100644 --- a/kernel/scsi_transport_iscsi.c +++ b/kernel/scsi_transport_iscsi.c @@ -1764,6 +1764,7 @@ iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0); iscsi_session_attr(tgt_reset_tmo, ISCSI_PARAM_TGT_RESET_TMO, 0); iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0); iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0) +iscsi_session_attr(boot_nic, ISCSI_PARAM_BOOT_NIC, 0) static ssize_t show_priv_session_state(struct device *dev, struct device_attribute *attr, @@ -2006,6 +2007,7 @@ iscsi_register_transport(struct iscsi_transport *tt) SETUP_SESSION_RD_ATTR(tgt_reset_tmo,ISCSI_TGT_RESET_TMO); SETUP_SESSION_RD_ATTR(ifacename, ISCSI_IFACE_NAME); SETUP_SESSION_RD_ATTR(initiatorname, ISCSI_INITIATOR_NAME); + SETUP_SESSION_RD_ATTR(boot_nic, ISCSI_BOOT_NIC); SETUP_PRIV_SESSION_RD_ATTR(recovery_tmo); SETUP_PRIV_SESSION_RD_ATTR(state); -- 1.7.7.4 -- 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 open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
Re: [PATCH 2/4] LIBISCSI: Added boot_nic session sysfs
On 10/22/2012 05:13 PM, Eddie Wai wrote: Kernel component to enable the new 'boot_nic' param in the kernel session sysfs. Signed-off-by: Eddie Wai eddie@broadcom.com --- kernel/libiscsi.c |6 ++ kernel/libiscsi.h |2 ++ kernel/scsi_transport_iscsi.c |2 ++ You should not bother modifing this kernel code. It is only for old kernels, so not bother touching it. As you know kernel patches should be against the upstream kernel. -- 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 open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
Re: [PATCH 0/4] ISCSITOOLS: Patchset to add the extraction of ibft net attributes
Could you post the patch that sets the boot nic value on the session? On 10/22/2012 05:13 PM, Eddie Wai wrote: For the case when iscsid is invoked for the first time after pivot root during iSCSI boot, the boot connection would fail to re-connect if the ibft/iscsi_boot sysfs entry contains tagged vlan. The problem was caused by the lack of such info in the iscsi_session sysfs for sync_session to inherit from. The enclosed patchset does the following: 1. Extract and save the ibft-ethernetN name to the boot_context-boot_nic 2. Pass the boot_nic info to be saved to the sessionN sysfs 3. Extract the sessionN boot_nic sysfs info and retrieve the corresponding net params This 'boot_nic' kernel session sysfs entry will only be present for ibft boot. Corresponding kernel drivers will have to add the ISCSI_PARAM_BOOT_NIC attribute to its attr_is_visible table. The last patch provides the fix for the unconditional overwrite of the iface struct even after the ibft net info was already extracted. Please review. Thanks. Eddie Eddie Wai (4): ISCSISTART: Saved ibft ethernetN to the session sysfs LIBISCSI: Added boot_nic session sysfs ISCSID: Added the extraction of the session boot_nic info ISCSID: Added iface content override fix include/fw_context.h |1 + include/iscsi_if.h |3 +++ kernel/libiscsi.c |6 ++ kernel/libiscsi.h |2 ++ kernel/scsi_transport_iscsi.c |2 ++ usr/config.h |1 + usr/idbm.c |2 ++ usr/initiator_common.c |6 +- usr/iscsi_sysfs.c | 25 - usr/iscsid.c |8 +++- utils/fwparam_ibft/fwparam_sysfs.c |4 11 files changed, 53 insertions(+), 7 deletions(-) -- 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 open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
Re: [PATCH 0/4] ISCSITOOLS: Patchset to add the extraction of ibft net attributes
On 10/22/2012 05:21 PM, Mike Christie wrote: Could you post the patch that sets the boot nic value on the session? Ignore this. I see it. I was thinking you were having the kernel/driver set it. -- 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 open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
[PATCH] LIBISCSI: Added the new boot_nic entry in the session sysfs
This is the kernel part of the modification to extract the net params from the ibft sysfs to the iface struct used for the connection request upon sync_session in the open-iscsi util. Signed-off-by: Eddie Wai eddie@broadcom.com --- drivers/scsi/libiscsi.c |6 ++ drivers/scsi/scsi_transport_iscsi.c |4 include/scsi/iscsi_if.h |2 ++ include/scsi/libiscsi.h |2 ++ 4 files changed, 14 insertions(+), 0 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 82c3fd4..4f4c154 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2809,6 +2809,7 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) kfree(session-targetname); kfree(session-targetalias); kfree(session-initiatorname); + kfree(session-boot_nic); kfree(session-ifacename); iscsi_destroy_session(cls_session); @@ -3248,6 +3249,8 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn, return iscsi_switch_str_param(session-ifacename, buf); case ISCSI_PARAM_INITIATOR_NAME: return iscsi_switch_str_param(session-initiatorname, buf); + case ISCSI_PARAM_BOOT_NIC: + return iscsi_switch_str_param(session-boot_nic, buf); default: return -ENOSYS; } @@ -3326,6 +3329,9 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session, case ISCSI_PARAM_INITIATOR_NAME: len = sprintf(buf, %s\n, session-initiatorname); break; + case ISCSI_PARAM_BOOT_NIC: + len = sprintf(buf, %s\n, session-boot_nic); + break; default: return -ENOSYS; } diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 31969f2..2cc28fe 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2484,6 +2484,7 @@ iscsi_session_attr(tgt_reset_tmo, ISCSI_PARAM_TGT_RESET_TMO, 0); iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0); iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0); iscsi_session_attr(targetalias, ISCSI_PARAM_TARGET_ALIAS, 0); +iscsi_session_attr(boot_nic, ISCSI_PARAM_BOOT_NIC, 0); static ssize_t show_priv_session_state(struct device *dev, struct device_attribute *attr, @@ -2570,6 +2571,7 @@ static struct attribute *iscsi_session_attrs[] = { dev_attr_sess_ifacename.attr, dev_attr_sess_initiatorname.attr, dev_attr_sess_targetalias.attr, + dev_attr_sess_boot_nic.attr, dev_attr_priv_sess_recovery_tmo.attr, dev_attr_priv_sess_state.attr, dev_attr_priv_sess_creator.attr, @@ -2632,6 +2634,8 @@ static umode_t iscsi_session_attr_is_visible(struct kobject *kobj, param = ISCSI_PARAM_INITIATOR_NAME; else if (attr == dev_attr_sess_targetalias.attr) param = ISCSI_PARAM_TARGET_ALIAS; + else if (attr == dev_attr_sess_boot_nic.attr) + param = ISCSI_PARAM_BOOT_NIC; else if (attr == dev_attr_priv_sess_recovery_tmo.attr) return S_IRUGO | S_IWUSR; else if (attr == dev_attr_priv_sess_state.attr) diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h index 917741b..874c8f3 100644 --- a/include/scsi/iscsi_if.h +++ b/include/scsi/iscsi_if.h @@ -452,6 +452,8 @@ enum iscsi_param { ISCSI_PARAM_TGT_RESET_TMO, ISCSI_PARAM_TARGET_ALIAS, + ISCSI_PARAM_BOOT_NIC, + ISCSI_PARAM_CHAP_IN_IDX, ISCSI_PARAM_CHAP_OUT_IDX, /* must always be last */ diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 6e33386..7ba5cc8 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -287,6 +287,8 @@ struct iscsi_session { char*targetalias; char*ifacename; char*initiatorname; + char*boot_nic; + /* control data */ struct iscsi_transport *tt; struct Scsi_Host*host; -- 1.7.7.4 -- 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 open-iscsi+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.