This commit is contained in:
Mike Christie 2008-04-06 06:44:04 +00:00
parent f18d872723
commit 5003024128
10 changed files with 472 additions and 28 deletions

View File

@ -0,0 +1,94 @@
diff -aurp open-iscsi-2.0-868-test1/usr/initiator.c open-iscsi-2.0-868-test1.work/usr/initiator.c
--- open-iscsi-2.0-868-test1/usr/initiator.c 2008-03-03 09:36:11.000000000 -0600
+++ open-iscsi-2.0-868-test1.work/usr/initiator.c 2008-03-03 09:39:17.000000000 -0600
@@ -602,7 +602,10 @@ session_conn_shutdown(iscsi_conn_t *conn
{
iscsi_session_t *session = conn->session;
- if (!conn->ksetup)
+ if (session->id == -1)
+ goto disconnect_conn;
+
+ if (!sysfs_session_has_leadconn(session->id))
goto disconnect_conn;
if (conn->state == STATE_IN_LOGIN ||
@@ -623,7 +626,6 @@ session_conn_shutdown(iscsi_conn_t *conn
log_error("can not safely destroy connection %d", conn->id);
return MGMT_IPC_ERR_INTERNAL;
}
- conn->ksetup = 0;
disconnect_conn:
log_debug(2, "disconnect conn");
@@ -1720,7 +1722,6 @@ static void session_conn_poll(void *data
err = MGMT_IPC_ERR_INTERNAL;
goto cleanup;
}
- conn->ksetup = 1;
log_debug(3, "created new iSCSI connection "
"%d:%d", session->id, conn->id);
}
diff -aurp open-iscsi-2.0-868-test1/usr/initiator.h open-iscsi-2.0-868-test1.work/usr/initiator.h
--- open-iscsi-2.0-868-test1/usr/initiator.h 2008-03-03 09:36:11.000000000 -0600
+++ open-iscsi-2.0-868-test1.work/usr/initiator.h 2008-03-03 09:39:17.000000000 -0600
@@ -116,7 +116,6 @@ struct iscsi_conn_context;
/* daemon's connection structure */
typedef struct iscsi_conn {
uint32_t id;
- int ksetup;
struct iscsi_session *session;
iscsi_login_context_t login_context;
struct iscsi_conn_context *recv_context;
diff -aurp open-iscsi-2.0-868-test1/usr/iscsi_sysfs.c open-iscsi-2.0-868-test1.work/usr/iscsi_sysfs.c
--- open-iscsi-2.0-868-test1/usr/iscsi_sysfs.c 2008-03-03 09:36:11.000000000 -0600
+++ open-iscsi-2.0-868-test1.work/usr/iscsi_sysfs.c 2008-03-03 09:39:17.000000000 -0600
@@ -38,6 +38,12 @@
#define ISCSI_MAX_SYSFS_BUFFER NI_MAXHOST
+/*
+ * TODO: make this into a real API and check inputs better and add doc.
+ * We should also use a common lib and search sysfs according to the sysfs
+ * doc in the kernel documetnation.
+ */
+
/* tmp buffer used by sysfs functions */
static char sysfs_file[PATH_MAX];
int num_transports = 0;
@@ -439,6 +445,24 @@ free_info:
return rc;
}
+/**
+ * sysfs_session_has_leadconn - checks if session has lead conn in kernel
+ * @sid: session id
+ *
+ * return 1 if session has lead conn and 0 if not.
+ */
+int sysfs_session_has_leadconn(uint32_t sid)
+{
+ struct stat statb;
+
+ memset(sysfs_file, 0, PATH_MAX);
+ sprintf(sysfs_file, ISCSI_CONN_DIR"/connection%u:0", sid);
+ if (!stat(sysfs_file, &statb))
+ return 1;
+ else
+ return 0;
+}
+
int get_sessioninfo_by_sysfs_id(struct session_info *info, char *session)
{
int ret, pers_failed = 0;
diff -aurp open-iscsi-2.0-868-test1/usr/iscsi_sysfs.h open-iscsi-2.0-868-test1.work/usr/iscsi_sysfs.h
--- open-iscsi-2.0-868-test1/usr/iscsi_sysfs.h 2008-03-03 09:36:11.000000000 -0600
+++ open-iscsi-2.0-868-test1.work/usr/iscsi_sysfs.h 2008-03-03 09:39:17.000000000 -0600
@@ -53,6 +53,7 @@ extern int get_iscsi_kernel_version(char
extern int check_class_version(void);
extern int get_sessioninfo_by_sysfs_id(struct session_info *info,
char *sys_session);
+extern int sysfs_session_has_leadconn(uint32_t sid);
typedef int (sysfs_session_op_fn)(void *, struct session_info *);
typedef int (sysfs_host_op_fn)(void *, struct host_info *);

View File

@ -0,0 +1,12 @@
diff -aurp open-iscsi-2.0-868-test1/usr/io.c open-iscsi-2.0-868-test1.work/usr/io.c
--- open-iscsi-2.0-868-test1/usr/io.c 2008-03-18 17:41:06.000000000 -0500
+++ open-iscsi-2.0-868-test1.work/usr/io.c 2008-03-18 17:41:36.000000000 -0500
@@ -794,7 +794,7 @@ iscsi_io_recv_pdu(iscsi_conn_t *conn, st
if (dlength == 0)
goto done;
- if (data + dlength >= end) {
+ if (data + dlength > end) {
log_warning("buffer size %u too small for data length %u",
max_data_length, dlength);
failed = 1;

View File

@ -0,0 +1,40 @@
diff -aurp open-iscsi-2.0-868-test1/usr/iscsid.c open-iscsi-2.0-868-test1.work/usr/iscsid.c
--- open-iscsi-2.0-868-test1/usr/iscsid.c 2008-03-11 17:25:29.000000000 -0500
+++ open-iscsi-2.0-868-test1.work/usr/iscsid.c 2008-03-11 17:25:50.000000000 -0500
@@ -177,7 +177,7 @@ setup_rec_from_negotiated_values(idbm_t
static int sync_session(void *data, struct session_info *info)
{
idbm_t *db = data;
- node_rec_t rec;
+ node_rec_t rec, sysfsrec;
iscsiadm_req_t req;
iscsiadm_rsp_t rsp;
struct iscsi_transport *t;
@@ -219,6 +219,27 @@ static int sync_session(void *data, stru
log_warning("Could not read data from db. Using default and "
"currently negotiated values\n");
setup_rec_from_negotiated_values(db, &rec, info);
+ } else {
+ /*
+ * we have a valid record and iface so lets merge
+ * the values from them and sysfs to try and get
+ * the most uptodate values.
+ *
+ * Currenlty that means we will use the CHAP, target and
+ * and portal values from sysfs and use timer, queue depth,
+ * and segment length values from the record. In the future
+ * when boot supports iface binding we will want to use
+ * those values from sysfs.
+ */
+ memset(&sysfsrec, 0, sizeof(node_rec_t));
+ setup_rec_from_negotiated_values(db, &sysfsrec, info);
+ /*
+ * target and portal values have to be the same or
+ * we would not have found the record, so just copy
+ * CHAP.
+ */
+ memcpy(&rec.session.auth, &sysfsrec.session.auth,
+ sizeof(struct iscsi_auth_config));
}
/* multiple drivers could be connected to the same portal */

View File

@ -0,0 +1,15 @@
diff -aurp open-iscsi-2.0-868-test1/usr/isns.c open-iscsi-2.0-868-test1.work/usr/isns.c
--- open-iscsi-2.0-868-test1/usr/isns.c 2008-03-03 09:36:11.000000000 -0600
+++ open-iscsi-2.0-868-test1.work/usr/isns.c 2008-03-03 09:38:03.000000000 -0600
@@ -286,7 +286,10 @@ static void add_new_target_node(char *ta
char dst[INET6_ADDRSTRLEN];
memset(dst, 0, sizeof(dst));
- if (!memcmp(ip, dst, 10) && ip[10] == 0xff && ip[11] == 0xff)
+ /*
+ * some servers are sending compat instead of mapped
+ */
+ if (IN6_IS_ADDR_V4MAPPED(ip) || IN6_IS_ADDR_V4COMPAT(ip))
inet_ntop(AF_INET, ip + 12, dst, sizeof(dst));
else
inet_ntop(AF_INET6, ip, dst, sizeof(dst));

View File

@ -0,0 +1,221 @@
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;
}

View File

@ -0,0 +1,37 @@
--- open-iscsi-2.0-868-test1/README 2008-03-14 12:28:27.000000000 -0500
+++ open-iscsi-2.0-868-test1.work/README 2008-03-14 12:29:06.000000000 -0500
@@ -225,11 +225,11 @@ Usage: iscsiadm [OPTION]
Stats prints the iSCSI stats for the session.
-m node --logoutall=[all|manual|automatic]
Logout "all" the running sessions or just the ones
- with a node or conn startup value manual or automatic.
+ with a node startup value manual or automatic.
Nodes marked as ONBOOT are skipped.
-m node --loginall=[all|manual|automatic]
Login "all" the running sessions or just the ones
- with a node or conn startup value manual or automatic.
+ with a node startup value manual or automatic.
Nodes marked as ONBOOT are skipped.
-m session display all active sessions and connections
-m session --sid=[sid] [ --print=level | --rescan | --logout ]
@@ -769,16 +769,16 @@ Note: this may only work for distros wit
To automate login to a node, use the following with the record ID
(record ID is the targetname and portal) of the node discovered in the
discovery above:
- iscsiadm -m node -T targetname -p ip:port --op update -n node.conn[0].startup -v automatic
+ iscsiadm -m node -T targetname -p ip:port --op update -n node.startup -v automatic
To set the automatic setting to all portals on a target through every
interface setup for each protal, the following can be run:
- iscsiadm -m node -T targetname --op update -n node.conn[0].startup -v automatic
+ iscsiadm -m node -T targetname --op update -n node.startup -v automatic
-Or to set the "node.conn[0].statup" attribute to "startup" as default for
+Or to set the "node.startup" attribute to "startup" as default for
all sessions add the following to the /etc/iscsi/iscsid.conf:
- node.conn[0].startup = automatic
+ node.startup = automatic
Setting this in iscsid.conf, will not affect existing nodes. It will only
affect nodes that are discovered after setting the value.

View File

@ -1,7 +1,7 @@
Summary: iSCSI daemon and utility programs
Name: iscsi-initiator-utils
Version: 6.2.0.868
Release: 0.3%{?dist}
Release: 0.6%{?dist}
Source0: http://www.open-iscsi.org/bits/open-iscsi-2.0-868-test1.tar.gz
Source1: iscsid.init
Source2: iscsidevs.init
@ -12,6 +12,12 @@ Patch3: iscsi-initiator-utils-ibft-sysfs.patch
Patch4: iscsi-initiator-utils-add-fw-login.patch
Patch5: iscsi-initiator-utils-use-new-tpgt.patch
Patch6: iscsi-initiator-utils-fix-compile-err-include-limits.patch
Patch7: iscsi-initiator-utils-handle-ipv6-compat-addrs.patch
Patch8: iscsi-initiator-utils-Fix-connection-cleanup-when-iscsid-is-restarted.patch
Patch9: iscsi-initiator-utils-fix-sync-up.patch
Patch10: iscsi-initiator-utils-update-startup-doc.patch
Patch11: iscsi-initiator-utils-fix-segment-len-check.patch
Patch12: iscsi-initiator-utils-print-ibft-net-info.patch
Group: System Environment/Daemons
License: GPLv2+
@ -37,6 +43,13 @@ Protocol networks.
%patch4 -p1 -b .add-fw-login
%patch5 -p1 -b .use-new-tpgt
%patch6 -p1 -b .fix-compile-err-include-limits
%patch7 -p1 -b .handle-ipv6-compat-addrs
%patch8 -p1 -b .Fix-connection-cleanup-when-iscsid-is-restarted
%patch9 -p1 -b .fix-sync-up
%patch10 -p1 -b .update-startup-doc
%patch11 -p1 -b .fix-segment-len-check
%patch12 -p1 -b .print-ibft-net-info
%build
make OPTFLAGS="%{optflags}" -C utils/fwparam_ibft
@ -111,6 +124,11 @@ fi
%changelog
* Fri Apr 4 2008 Mike Christie <mchristie@redhat.com> - 6.2.0.868-0.6
- Rebase to RHEL5 to bring in bug fixes.
- 437522 iscsi startup does not need to modify with network startup.
- 436175 Check for running sessions when stopping service.
* Wed Feb 5 2008 Mike Christie <mchristie@redhat.com> - 6.2.0.868-0.3
- Rebase to upstream and RHEL5.
- 246960 LSB init script changes.

View File

@ -16,14 +16,6 @@ RETVAL=0
start()
{
echo -n $"Turning off network shutdown."
# we do not want iscsi or network to run during system shutdown
# incase there are RAID or multipath devices using
# iscsi disks
chkconfig --level 06 network off
rm /etc/rc0.d/*network
rm /etc/rc6.d/*network
echo -n $"Starting iSCSI initiator service: "
modprobe -q iscsi_tcp
modprobe -q ib_iser

View File

@ -32,14 +32,6 @@ start()
return
fi
echo -n $"Turning off network shutdown. "
# we do not want iscsi or network to run during system shutdown
# incase there are RAID or multipath devices using
# iscsi disks
chkconfig --level 06 network off
rm /etc/rc0.d/*network
rm /etc/rc6.d/*network
echo -n $"Starting iSCSI daemon: "
modprobe -q iscsi_tcp
modprobe -q ib_iser
@ -54,6 +46,17 @@ start()
echo
}
stop_iscsid()
{
killproc iscsid
echo
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/iscsid
modprobe -r ib_iser 2>/dev/null
modprobe -r iscsi_tcp 2>/dev/null
}
stop()
{
if [ ! -f /var/lock/subsys/iscsid ]; then
@ -62,6 +65,13 @@ stop()
return
fi
declare -a iparams=( $(iscsiadm -m session 2>/dev/null | egrep "tcp|iser") )
if [[ -z "${iparams[*]}" ]]; then
# no sessions so we can just quit
stop_iscsid
return
fi
# If this is a final shutdown/halt, do nothing since
# we may need iscsid for as long as possible (halt script kills
# us at the last second)
@ -79,13 +89,7 @@ stop()
fi
echo -n $"Stopping iSCSI daemon: "
killproc iscsid
echo
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/iscsid
modprobe -r ib_iser 2>/dev/null
modprobe -r iscsi_tcp 2>/dev/null
stop_iscsid
}
restart()

View File

@ -22,7 +22,6 @@ RETVAL=0
start()
{
echo -n $"Setting up iSCSI targets: "
if [ -f /var/lock/subsys/iscsi ] ; then
echo
success
@ -49,6 +48,13 @@ start()
echo
}
cleanup_iscsi()
{
/etc/init.d/iscsid stop
rm -f /var/lock/subsys/iscsi
success
}
stop()
{
if [ ! -f /var/lock/subsys/iscsi ]; then
@ -57,6 +63,13 @@ stop()
return
fi
declare -a iparams=( $(iscsiadm -m session 2>/dev/null | egrep "tcp|iser") )
if [[ -z "${iparams[*]}" ]]; then
# no sessions so we can just quit
cleanup_iscsi
return
fi
# If this is a final shutdown/halt, do nothing since
# lvm/dm, md, power path, etc do not always handle this nicely.
# The kernel will do the right thing and shutdown devices (send
@ -75,9 +88,7 @@ stop()
fi
iscsiadm -m node --logoutall=all
/etc/init.d/iscsid stop
rm -f /var/lock/subsys/iscsi
success
cleanup_iscsi
}
case "$1" in