Drop some unused patch files

This commit is contained in:
Hans de Goede 2011-04-26 13:44:28 +02:00
parent 2d4a526aa6
commit ed7c748574
15 changed files with 0 additions and 6015 deletions

View File

@ -1,27 +0,0 @@
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/be2iscsi.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/be2iscsi.c
--- open-iscsi-2.0-872-rc1-bnx2i/usr/be2iscsi.c 2010-05-05 09:21:40.000000000 -0500
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/be2iscsi.c 2010-05-05 09:21:52.000000000 -0500
@@ -24,11 +24,11 @@ void be2iscsi_create_conn(struct iscsi_c
if (conn->max_recv_dlength > 65536)
conn->max_recv_dlength = 65536;
- if (conn->session->first_burst > 8192)
- conn->session->first_burst = 8192;
+ if (session->first_burst > 8192)
+ session->first_burst = 8192;
- if (conn->session->max_burst > 262144)
- conn->session->max_burst = 262144;
+ if (session->max_burst > 262144)
+ session->max_burst = 262144;
if (conn->max_xmit_dlength > 65536)
conn->max_xmit_dlength = 65536;
@@ -37,5 +37,6 @@ void be2iscsi_create_conn(struct iscsi_c
conn_rec->iscsi.MaxXmitDataSegmentLength > 65536)
conn_rec->iscsi.MaxXmitDataSegmentLength = 65536;
- conn->session->erl = 0;
+ session->erl = 0;
+ session->initial_r2t_en = 1;
}

View File

@ -1,13 +0,0 @@
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 2d9f1a2..87dd4a0 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1646,7 +1646,7 @@ main(int argc, char **argv)
goto free_ifaces;
}
- if (mode != MODE_DISCOVERY && ip)
+ if (mode != MODE_DISCOVERY && ip && port == -1)
port = ISCSI_LISTEN_PORT;
switch (mode) {

View File

@ -1,59 +0,0 @@
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/be2iscsi.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/be2iscsi.c
--- open-iscsi-2.0-872-rc1-bnx2i/usr/be2iscsi.c 2010-04-16 14:15:44.000000000 -0500
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/be2iscsi.c 2010-04-16 14:17:00.000000000 -0500
@@ -18,6 +18,9 @@
void be2iscsi_create_conn(struct iscsi_conn *conn)
{
+ struct iscsi_session *session = conn->session;
+ conn_rec_t *conn_rec = &session->nrec.conn[conn->id];
+
if (conn->max_recv_dlength > 65536)
conn->max_recv_dlength = 65536;
@@ -30,5 +33,9 @@ void be2iscsi_create_conn(struct iscsi_c
if (conn->max_xmit_dlength > 65536)
conn->max_xmit_dlength = 65536;
+ if (!conn_rec->iscsi.MaxXmitDataSegmentLength ||
+ conn_rec->iscsi.MaxXmitDataSegmentLength > 65536)
+ conn_rec->iscsi.MaxXmitDataSegmentLength = 65536;
+
conn->session->erl = 0;
}
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/initiator.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/initiator.c
--- open-iscsi-2.0-872-rc1-bnx2i/usr/initiator.c 2010-04-16 14:16:30.000000000 -0500
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/initiator.c 2010-04-16 14:16:41.000000000 -0500
@@ -369,9 +369,10 @@ iscsi_copy_operational_params(iscsi_conn
/* zero indicates to use the target's value */
conn->max_xmit_dlength =
__padding(conn_rec->iscsi.MaxXmitDataSegmentLength);
- if (conn->max_xmit_dlength != 0 &&
- (conn->max_xmit_dlength < ISCSI_MIN_MAX_RECV_SEG_LEN ||
- conn->max_xmit_dlength > ISCSI_MAX_MAX_RECV_SEG_LEN)) {
+ if (conn->max_xmit_dlength == 0)
+ conn->max_xmit_dlength = ISCSI_DEF_MAX_RECV_SEG_LEN;
+ if (conn->max_xmit_dlength < ISCSI_MIN_MAX_RECV_SEG_LEN ||
+ conn->max_xmit_dlength > ISCSI_MAX_MAX_RECV_SEG_LEN) {
log_error("Invalid iscsi.MaxXmitDataSegmentLength. Must be "
"within %u and %u. Setting to %u\n",
ISCSI_MIN_MAX_RECV_SEG_LEN,
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/login.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/login.c
--- open-iscsi-2.0-872-rc1-bnx2i/usr/login.c 2010-04-16 14:16:30.000000000 -0500
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/login.c 2010-04-16 14:16:41.000000000 -0500
@@ -390,9 +390,14 @@ get_op_params_text_keys(iscsi_session_t
if (session->type == ISCSI_SESSION_TYPE_DISCOVERY ||
!session->t->template->rdma) {
int tgt_max_xmit;
+ conn_rec_t *conn_rec = &session->nrec.conn[cid];
tgt_max_xmit = strtoul(value, NULL, 0);
- if (conn->max_xmit_dlength == 0 ||
+ /*
+ * if the rec value is zero it means to use
+ * what the target gave us.
+ */
+ if (!conn_rec->iscsi.MaxXmitDataSegmentLength ||
tgt_max_xmit < conn->max_xmit_dlength)
conn->max_xmit_dlength = tgt_max_xmit;
}

View File

@ -1,696 +0,0 @@
diff --git a/include/fw_context.h b/include/fw_context.h
index abdff42..770b41a 100644
--- a/include/fw_context.h
+++ b/include/fw_context.h
@@ -54,6 +54,8 @@ struct boot_context {
char mask[18];
char lun[17];
char vlan[15];
+
+ char scsi_host_name[64];
};
extern int fw_get_entry(struct boot_context *context);
diff --git a/usr/iface.c b/usr/iface.c
index 27b59d0..9c74117 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -778,31 +778,62 @@ void iface_link_ifaces(struct list_head *ifaces)
iface_for_each_iface(ifaces, 1, &nr_found, iface_link);
}
-void iface_setup_from_boot_context(struct iface_rec *iface,
+/**
+ * iface_setup_from_boot_context - setup iface from boot context info
+ * @iface: iface t setup
+ * @context: boot context info
+ *
+ * Returns 1 if setup for offload.
+ */
+int iface_setup_from_boot_context(struct iface_rec *iface,
struct boot_context *context)
{
if (strlen(context->initiatorname))
strlcpy(iface->iname, context->initiatorname,
sizeof(iface->iname));
- if (strlen(context->iface)) {
- if (!net_get_transport_name_from_netdev(context->iface,
- iface->transport_name)) {
- /* set up for access through offload card */
- memset(iface->name, 0, sizeof(iface->name));
- snprintf(iface->name, sizeof(iface->name),
- "%s.%s", iface->transport_name,
- context->mac);
-
- strlcpy(iface->netdev, context->iface,
- sizeof(iface->netdev));
- strlcpy(iface->hwaddress, context->mac,
- sizeof(iface->hwaddress));
- strlcpy(iface->ipaddress, context->ipaddr,
- sizeof(iface->ipaddress));
+ if (strlen(context->scsi_host_name)) {
+ struct iscsi_transport *t;
+ uint32_t hostno;
+
+ if (sscanf(context->scsi_host_name, "iscsi_host%u", &hostno) != 1) {
+ log_error("Could not parse %s's host no.",
+ context->scsi_host_name);
+ return 0;
}
- }
+ t = iscsi_sysfs_get_transport_by_hba(hostno);
+ if (!t) {
+ log_error("Could not get transport for %s. "
+ "Make sure the iSCSI driver is loaded.",
+ context->scsi_host_name);
+ return 0;
+ }
+
+ log_debug(3, "boot context has %s transport %s",
+ context->scsi_host_name, t->name);
+ strcpy(iface->transport_name, t->name);
+ } else if (strlen(context->iface) &&
+ (!net_get_transport_name_from_netdev(context->iface,
+ iface->transport_name))) {
+ log_debug(3, "boot context has netdev %s",
+ context->iface);
+ strlcpy(iface->netdev, context->iface,
+ sizeof(iface->netdev));
+ } else
+ return 0;
+ /*
+ * set up for access through a offload card.
+ */
+ memset(iface->name, 0, sizeof(iface->name));
+ snprintf(iface->name, sizeof(iface->name), "%s.%s",
+ iface->transport_name, context->mac);
+
+ strlcpy(iface->hwaddress, context->mac,
+ sizeof(iface->hwaddress));
+ strlcpy(iface->ipaddress, context->ipaddr,
+ sizeof(iface->ipaddress));
log_debug(1, "iface " iface_fmt "\n", iface_str(iface));
+ return 1;
}
/**
@@ -817,32 +848,24 @@ void iface_setup_from_boot_context(struct iface_rec *iface,
int iface_create_ifaces_from_boot_contexts(struct list_head *ifaces,
struct list_head *targets)
{
- char transport_name[ISCSI_TRANSPORT_NAME_MAXLEN];
- char iface_name[ISCSI_MAX_IFACE_LEN];
struct boot_context *context;
struct iface_rec *iface, *tmp_iface;
int rc = 0;
list_for_each_entry(context, targets, list) {
- memset(transport_name, 0, ISCSI_TRANSPORT_NAME_MAXLEN);
-
- if (net_get_transport_name_from_netdev(context->iface,
- transport_name))
- continue;
-
- /* offload + ibft support */
- memset(iface_name, 0, ISCSI_MAX_IFACE_LEN);
- snprintf(iface_name, ISCSI_MAX_IFACE_LEN,
- "%s.%s", transport_name, context->mac);
-
rc = 0;
- iface = iface_alloc(iface_name, &rc);
+ /* use dummy name. If valid it will get overwritten below */
+ iface = iface_alloc(DEFAULT_IFACENAME, &rc);
if (!iface) {
log_error("Could not setup iface %s for boot\n",
- iface_name);
+ context->iface);
goto fail;
}
- iface_setup_from_boot_context(iface, context);
+ if (!iface_setup_from_boot_context(iface, context)) {
+ /* no offload so forget it */
+ free(iface);
+ continue;
+ }
rc = iface_conf_write(iface);
if (rc) {
diff --git a/usr/iface.h b/usr/iface.h
index f948686..9f6d47e 100644
--- a/usr/iface.h
+++ b/usr/iface.h
@@ -50,7 +50,7 @@ extern int iface_conf_write(struct iface_rec *iface);
extern int iface_conf_delete(struct iface_rec *iface);
extern int iface_is_valid(struct iface_rec *iface);
extern void iface_link_ifaces(struct list_head *ifaces);
-extern void iface_setup_from_boot_context(struct iface_rec *iface,
+extern int iface_setup_from_boot_context(struct iface_rec *iface,
struct boot_context *context);
extern int iface_create_ifaces_from_boot_contexts(struct list_head *ifaces,
struct list_head *targets);
diff --git a/utils/fwparam_ibft/Makefile b/utils/fwparam_ibft/Makefile
index b9e7988..ca07b76 100644
--- a/utils/fwparam_ibft/Makefile
+++ b/utils/fwparam_ibft/Makefile
@@ -22,7 +22,7 @@
#
SYSDEPS_OBJS = $(wildcard ../sysdeps/*.o)
-OBJS := fw_entry.o fwparam_ibft_sysfs.o $(SYSDEPS_OBJS) ../../usr/iscsi_net_util.o
+OBJS := fw_entry.o fwparam_sysfs.o $(SYSDEPS_OBJS) ../../usr/iscsi_net_util.o
OBJS += prom_lex.o prom_parse.tab.o fwparam_ppc.o
CLEANFILES = $(OBJS) *.output *~
diff --git a/utils/fwparam_ibft/fw_entry.c b/utils/fwparam_ibft/fw_entry.c
index ae5d34a..bbdb6d2 100644
--- a/utils/fwparam_ibft/fw_entry.c
+++ b/utils/fwparam_ibft/fw_entry.c
@@ -102,8 +102,7 @@ int fw_get_entry(struct boot_context *context)
ret = fwparam_ppc_boot_info(context);
if (ret)
- ret = fwparam_ibft_sysfs_boot_info(context);
-
+ ret = fwparam_sysfs_boot_info(context);
return ret;
}
@@ -124,8 +123,7 @@ int fw_get_targets(struct list_head *list)
ret = fwparam_ppc_get_targets(list);
if (ret)
- ret = fwparam_ibft_sysfs_get_targets(list);
-
+ ret = fwparam_sysfs_get_targets(list);
return ret;
}
diff --git a/utils/fwparam_ibft/fwparam.h b/utils/fwparam_ibft/fwparam.h
index a79213b..32e4961 100644
--- a/utils/fwparam_ibft/fwparam.h
+++ b/utils/fwparam_ibft/fwparam.h
@@ -24,8 +24,8 @@
struct boot_context;
-int fwparam_ibft_sysfs_boot_info(struct boot_context *context);
-int fwparam_ibft_sysfs_get_targets(struct list_head *list);
+int fwparam_sysfs_boot_info(struct boot_context *context);
+int fwparam_sysfs_get_targets(struct list_head *list);
int fwparam_ppc_boot_info(struct boot_context *context);
int fwparam_ppc_get_targets(struct list_head *list);
diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c
new file mode 100644
index 0000000..9b73d1a
--- /dev/null
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
@@ -0,0 +1,484 @@
+/*
+ * Copyright (C) IBM Corporation. 2007
+ * Author: Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
+ * Copyright (C) Red Hat, Inc. All rights reserved. 2008 - 2010
+ * Copyright (C) Mike Christie 2008 - 2010
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define _XOPEN_SOURCE 500
+#define _SVID_SOURCE
+#include <ftw.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "sysfs.h"
+#include "fw_context.h"
+#include "fwparam.h"
+#include "sysdeps.h"
+#include "iscsi_net_util.h"
+
+#define ISCSI_BOOT_MAX 255
+#define IBFT_SYSFS_ROOT "/sys/firmware/ibft/"
+#define IBFT_SUBSYS "ibft"
+
+#define ISCSI_LLD_ROOT "/sys/firmware/"
+#define ISCSI_LLD_SUBSYS_PREFIX "iscsi_host"
+
+static char *target_list[ISCSI_BOOT_MAX];
+static char *nic_list[ISCSI_BOOT_MAX];
+static int nic_cnt;
+static int tgt_cnt;
+
+static int file_exist(const char *file)
+{
+ struct stat bootpath_stat;
+
+ return !stat(file, &bootpath_stat);
+}
+
+/*
+ * Finds the etherrnetX and targetX under the sysfs directory.
+ */
+static int find_sysfs_dirs(const char *fpath, const struct stat *sb,
+ int tflag, struct FTW *ftw)
+{
+ if (tflag == FTW_D && (strstr(fpath + ftw->base, "target"))) {
+ if (tgt_cnt == ISCSI_BOOT_MAX) {
+ printf("Too many targets found in iSCSI boot data."
+ "Max number of targets %d\n", ISCSI_BOOT_MAX);
+ return 0;
+ }
+ target_list[tgt_cnt++] = strdup(strstr(fpath, "target"));
+ }
+
+ if (tflag == FTW_D && (strstr(fpath + ftw->base, "ethernet"))) {
+ if (nic_cnt == ISCSI_BOOT_MAX) {
+ printf("Too many nics found in iSCSI boot data."
+ "Max number of nics %d\n", ISCSI_BOOT_MAX);
+ return 0;
+ }
+ nic_list[nic_cnt++] = strdup(strstr(fpath, "ethernet"));
+ }
+
+ return 0;
+}
+
+static int get_iface_from_device(char *id, struct boot_context *context)
+{
+ char dev_dir[FILENAMESZ];
+ int rc = ENODEV;
+ DIR *dirfd;
+ struct dirent *dent;
+
+ memset(dev_dir, 0, FILENAMESZ);
+ snprintf(dev_dir, FILENAMESZ, IBFT_SYSFS_ROOT"/%s/device", id);
+
+ 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, "..") ||
+ strncmp(dent->d_name, "net:", 4))
+ continue;
+
+ if (!strncmp(dent->d_name, "net:", 4)) {
+ if ((strlen(dent->d_name) - 4) >
+ (sizeof(context->iface) - 1)) {
+ rc = EINVAL;
+ printf("Net device %s too big for iface "
+ "buffer.\n", dent->d_name);
+ break;
+ }
+
+ if (sscanf(dent->d_name, "net:%s", context->iface) != 1)
+ rc = EINVAL;
+ rc = 0;
+ break;
+ } else {
+ printf("Could not read ethernet to net link.\n");
+ rc = EOPNOTSUPP;
+ break;
+ }
+ }
+
+ closedir(dirfd);
+
+ if (rc != ENODEV)
+ return rc;
+
+ /* If not found try again with newer kernel networkdev sysfs layout */
+ strlcat(dev_dir, "/net", FILENAMESZ);
+
+ if (!file_exist(dev_dir))
+ return rc;
+
+ dirfd = opendir(dev_dir);
+ if (!dirfd)
+ return errno;
+
+ while ((dent = readdir(dirfd))) {
+ if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
+ continue;
+
+ /* Take the first "regular" directory entry */
+ if (strlen(dent->d_name) > (sizeof(context->iface) - 1)) {
+ rc = EINVAL;
+ printf("Net device %s too big for iface buffer.\n",
+ dent->d_name);
+ break;
+ }
+
+ strcpy(context->iface, dent->d_name);
+ rc = 0;
+ break;
+ }
+
+ closedir(dirfd);
+ return rc;
+}
+
+/*
+ * Routines to fill in the context values.
+ */
+static int fill_nic_context(char *subsys, char *id,
+ struct boot_context *context)
+{
+ int rc;
+
+ rc = sysfs_get_str(id, subsys, "mac", context->mac,
+ sizeof(context->mac));
+ if (rc)
+ return rc;
+
+ /*
+ * Some offload cards like bnx2i use different MACs for the net and
+ * iscsi functions, so we have to follow the sysfs links.
+ *
+ * Other ibft implementations may not be tied to a pci function,
+ * so there will not be any device/net link, so we drop down to
+ * the MAC matching.
+ *
+ * And finally, some cards like be2iscsi and qla4xxx do not have
+ * any linux network subsys representation. These hosts will
+ * not have the ibft subsys. Instead the subsys is the scsi host
+ * number.
+ */
+ if (!strcmp(IBFT_SUBSYS, subsys)) {
+ rc = get_iface_from_device(id, context);
+ if (rc) {
+ rc = net_get_netdev_from_hwaddress(context->mac,
+ context->iface);
+ if (rc)
+ return rc;
+ }
+ } else
+ strlcpy(context->scsi_host_name, subsys,
+ sizeof(context->scsi_host_name));
+
+ sysfs_get_str(id, subsys, "ip-addr", context->ipaddr,
+ sizeof(context->ipaddr));
+ sysfs_get_str(id, subsys, "vlan", context->vlan,
+ sizeof(context->vlan));
+ sysfs_get_str(id, subsys, "subnet-mask", context->mask,
+ sizeof(context->mask));
+ sysfs_get_str(id, subsys, "gateway", context->gateway,
+ sizeof(context->gateway));
+ sysfs_get_str(id, subsys, "primary-dns", context->primary_dns,
+ sizeof(context->primary_dns));
+ sysfs_get_str(id, subsys, "secondary-dns", context->secondary_dns,
+ sizeof(context->secondary_dns));
+ sysfs_get_str(id, subsys, "dhcp", context->dhcp,
+ sizeof(context->dhcp));
+ return 0;
+}
+
+static void fill_initiator_context(char *subsys, struct boot_context *context)
+{
+ sysfs_get_str("initiator", subsys, "initiator-name",
+ context->initiatorname,
+ sizeof(context->initiatorname));
+ sysfs_get_str("initiator", subsys, "isid", context->isid,
+ sizeof(context->isid));
+}
+static int fill_tgt_context(char *subsys, char *id,
+ struct boot_context *context)
+{
+ int rc;
+
+ rc = sysfs_get_str(id, subsys, "target-name", context->targetname,
+ sizeof(context->targetname));
+ if (rc)
+ return rc;
+
+ rc = sysfs_get_str(id, subsys, "ip-addr", context->target_ipaddr,
+ sizeof(context->target_ipaddr));
+ if (rc)
+ return rc;
+
+ /*
+ * We can live without the rest of they do not exist. If we
+ * failed to get them we will figure it out when we login.
+ */
+ if (sysfs_get_int(id, subsys, "port", &context->target_port))
+ context->target_port = ISCSI_LISTEN_PORT;
+
+ sysfs_get_str(id, subsys, "lun", context->lun,
+ sizeof(context->lun));
+ sysfs_get_str(id, subsys, "chap-name", context->chap_name,
+ sizeof(context->chap_name));
+ sysfs_get_str(id, subsys, "chap-secret", context->chap_password,
+ sizeof(context->chap_password));
+ sysfs_get_str(id, subsys, "rev-chap-name", context->chap_name_in,
+ sizeof(context->chap_name_in));
+ sysfs_get_str(id, subsys, "rev-chap-name-secret",
+ context->chap_password_in,
+ sizeof(context->chap_password_in));
+ return 0;
+}
+
+#define IBFT_SYSFS_FLAG_FW_SEL_BOOT 2
+
+static int find_boot_flag(char *subsys, char *list[], ssize_t size,
+ int *boot_idx)
+{
+ int rc = ENODEV;
+ int i, flag = 0;
+
+ for (i = 0; i < size; i++, flag = -1) {
+ rc = sysfs_get_int(list[i], subsys, "flags", &flag);
+ if (rc)
+ continue;
+
+ if (flag & IBFT_SYSFS_FLAG_FW_SEL_BOOT) {
+ *boot_idx = i;
+ rc = 0;
+ break;
+ }
+ rc = ENODEV;
+ flag = 0;
+
+ }
+
+ return rc;
+}
+
+static void deallocate_lists(void)
+{
+ int i;
+
+ for (i = 0; i < nic_cnt; i++)
+ free(nic_list[i]);
+
+ nic_cnt = 0;
+ for (i = 0; i < tgt_cnt; i++)
+ free(target_list[i]);
+
+ tgt_cnt = 0;
+
+}
+
+static int get_boot_info(struct boot_context *context, char *rootdir,
+ char *subsys)
+{
+ char initiator_dir[FILENAMESZ];
+ int rc = ENODEV;
+ int nic_idx = -1, tgt_idx = -1;
+
+ memset(&initiator_dir, 0 , FILENAMESZ);
+ snprintf(initiator_dir, FILENAMESZ, "%sinitiator", rootdir);
+
+ nic_cnt = 0;
+ tgt_cnt = 0;
+ if (file_exist(initiator_dir)) {
+ /* Find the target's and the ethernet's */
+ rc = nftw(rootdir, find_sysfs_dirs, 20, 1);
+
+ /* Find wihch target and which ethernet have
+ the boot flag set. */
+ rc = find_boot_flag(subsys, nic_list, nic_cnt, &nic_idx);
+ if (rc)
+ goto free;
+
+ rc = find_boot_flag(subsys, target_list, tgt_cnt, &tgt_idx);
+ if (rc)
+ goto free;
+
+ /* Fill in the context values */
+ rc = fill_nic_context(subsys, nic_list[nic_idx], context);
+ rc |= fill_tgt_context(subsys, target_list[tgt_idx], context);
+ fill_initiator_context(subsys, context);
+ }
+free:
+ deallocate_lists();
+ return rc;
+}
+
+int fwparam_sysfs_boot_info(struct boot_context *context)
+{
+ struct dirent *dent;
+ DIR *dirfd;
+ int rc = 0;
+
+ if (!get_boot_info(context, IBFT_SYSFS_ROOT, IBFT_SUBSYS))
+ return 0;
+ /*
+ * We could have multiple iscsi llds and each lld could have
+ * multiple targets/ethernet ports
+ */
+ dirfd = opendir(ISCSI_LLD_ROOT);
+ if (!dirfd)
+ return errno;
+
+ while ((dent = readdir(dirfd))) {
+ char lld_root[FILENAMESZ];
+
+ memset(&lld_root, 0 , FILENAMESZ);
+
+ if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
+ continue;
+
+ if (strncmp(dent->d_name, ISCSI_LLD_SUBSYS_PREFIX, 10))
+ continue;
+
+ snprintf(lld_root, FILENAMESZ, ISCSI_LLD_ROOT"%s",
+ dent->d_name);
+ if (!get_boot_info(context, lld_root, dent->d_name))
+ goto done;
+ }
+ rc = ENODEV;
+done:
+ closedir(dirfd);
+ return rc;
+}
+
+static int get_targets(struct list_head *list, char *rootdir, char *subsys)
+{
+ struct boot_context *context;
+ int rc = 0, i, nic_idx, nic;
+ char initiator_dir[FILENAMESZ];
+
+ memset(&initiator_dir, 0 , FILENAMESZ);
+ snprintf(initiator_dir, FILENAMESZ, "%sinitiator", rootdir);
+
+ if (!file_exist(initiator_dir))
+ return ENODEV;
+
+ nic_cnt = 0;
+ tgt_cnt = 0;
+
+ /* Find the target's and the ethernet's */
+ nftw(rootdir, find_sysfs_dirs, 20, 1);
+ for (i = 0; i < tgt_cnt; i++) {
+ context = calloc(1, sizeof(*context));
+ if (!context) {
+ rc = ENOMEM;
+ break;
+ }
+
+ rc = fill_tgt_context(subsys, target_list[i], context);
+ if (rc)
+ break;
+
+ rc = sysfs_get_int(target_list[i], subsys, "nic-assoc",
+ &nic_idx);
+ if (rc)
+ break;
+
+ for (nic = 0; nic < nic_cnt; nic++) {
+ int id;
+
+ rc = sysfs_get_int(nic_list[nic], subsys, "index",
+ &id);
+ if (!rc && (id == nic_idx))
+ break;
+ }
+
+ if (nic == nic_cnt) {
+ printf("Invalid nic-assoc of %d. Max id %d.\n",
+ nic_idx, nic_cnt);
+ break;
+ }
+
+ rc = fill_nic_context(subsys, nic_list[nic], context);
+ if (rc)
+ break;
+
+ fill_initiator_context(subsys, context);
+ list_add_tail(&context->list, list);
+ }
+
+ if (rc) {
+ if (context)
+ free(context);
+ fw_free_targets(list);
+ }
+
+ deallocate_lists();
+ return rc;
+}
+
+int fwparam_sysfs_get_targets(struct list_head *list)
+{
+ struct dirent *dent;
+ DIR *dirfd;
+ int rc = 0;
+
+ /* ibft only has one instance */
+ get_targets(list, IBFT_SYSFS_ROOT, IBFT_SUBSYS);
+ /*
+ * We could have multiple iscsi llds and each lld could have
+ * multiple targets/ethernet ports
+ */
+ dirfd = opendir(ISCSI_LLD_ROOT);
+ if (!dirfd) {
+ rc = errno;
+ goto done;
+ }
+
+ while ((dent = readdir(dirfd))) {
+ char lld_root[FILENAMESZ];
+
+ memset(&lld_root, 0 , FILENAMESZ);
+
+ if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
+ continue;
+
+ if (strncmp(dent->d_name, ISCSI_LLD_SUBSYS_PREFIX, 10))
+ continue;
+
+ snprintf(lld_root, FILENAMESZ, ISCSI_LLD_ROOT"%s",
+ dent->d_name);
+ get_targets(list, lld_root, dent->d_name);
+ }
+ closedir(dirfd);
+done:
+ if (!rc && list_empty(list))
+ rc = ENODEV;
+ if (rc)
+ fw_free_targets(list);
+ return rc;
+}
--
1.6.6.1

View File

@ -1,312 +0,0 @@
diff -Naurp open-iscsi-2.0-870-rc1/utils/fwparam_ibft/fw_entry.c open-iscsi-2.0-870-rc1.work/utils/fwparam_ibft/fw_entry.c
--- open-iscsi-2.0-870-rc1/utils/fwparam_ibft/fw_entry.c 2008-06-30 20:14:03.000000000 -0500
+++ open-iscsi-2.0-870-rc1.work/utils/fwparam_ibft/fw_entry.c 2008-06-30 21:21:57.000000000 -0500
@@ -29,7 +29,8 @@ int fw_get_entry(struct boot_context *co
ret = fwparam_ppc(context, filepath);
if (ret)
- ret = fwparam_ibft(context, filepath);
+ ret = fwparam_ibft_sysfs(context, filepath);
+
return ret;
}
diff -Naurp open-iscsi-2.0-870-rc1/utils/fwparam_ibft/fwparam_ibft.h open-iscsi-2.0-870-rc1.work/utils/fwparam_ibft/fwparam_ibft.h
--- open-iscsi-2.0-870-rc1/utils/fwparam_ibft/fwparam_ibft.h 2008-06-30 20:14:03.000000000 -0500
+++ open-iscsi-2.0-870-rc1.work/utils/fwparam_ibft/fwparam_ibft.h 2008-06-30 21:21:57.000000000 -0500
@@ -153,6 +153,7 @@ extern int dev_count;
#define TARGET "target"
extern int fwparam_ibft(struct boot_context *context, const char *filepath);
+extern int fwparam_ibft_sysfs(struct boot_context *context,
+ const char *filepath);
extern int fwparam_ppc(struct boot_context *context, const char *filepath);
-
#endif /* FWPARAM_IBFT_H_ */
diff -Naurp open-iscsi-2.0-870-rc1/utils/fwparam_ibft/fwparam_ibft_sysfs.c open-iscsi-2.0-870-rc1.work/utils/fwparam_ibft/fwparam_ibft_sysfs.c
--- open-iscsi-2.0-870-rc1/utils/fwparam_ibft/fwparam_ibft_sysfs.c 1969-12-31 18:00:00.000000000 -0600
+++ open-iscsi-2.0-870-rc1.work/utils/fwparam_ibft/fwparam_ibft_sysfs.c 2008-06-30 21:21:57.000000000 -0500
@@ -0,0 +1,271 @@
+/*
+ * Copyright (C) IBM Corporation. 2007
+ * Author: Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define _XOPEN_SOURCE 500
+#include <ftw.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "fwparam_ibft.h"
+#include <fw_context.h>
+
+#define IBFT_MAX 255
+#define IBFT_SYSFS_ROOT "/sys/firmware/ibft/"
+
+static char *target_list[IBFT_MAX];
+static char *nic_list[IBFT_MAX];
+static int nic_cnt;
+static int tgt_cnt;
+
+/*
+ * Helper routines.
+ */
+static int file_exist(const char *file)
+{
+
+ struct stat bootpath_stat;
+
+ return !stat(file, &bootpath_stat);
+}
+
+static int read_file(const char *file, char **contents)
+{
+ int error, fd, bytes_read;
+ struct stat bootpath_stat;
+
+ error = stat(file, &bootpath_stat);
+ if (error < 0) {
+ fprintf(stderr, "(%s:%d) stat %s, %s\n", __FILE__, __LINE__,
+ file, strerror(errno));
+ return error;
+ }
+
+ *contents = malloc(bootpath_stat.st_size);
+ if (!*contents) {
+ error = ENOMEM;
+ fprintf(stderr, "(%s:%d) Could not allocate enough memory for "\
+ "%s: %s (%d)\n",
+ __FILE__, __LINE__, file, strerror(error), error);
+ return errno;
+ }
+
+ fd = open(file, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "(%s:%d): Could not open %s: %s (%d)\n",
+ __FILE__, __LINE__, file, strerror(errno), errno);
+ free(*contents);
+ return errno;
+ }
+
+ bytes_read = read(fd, *contents, bootpath_stat.st_size);
+ close(fd);
+ if (bytes_read > bootpath_stat.st_size) {
+ fprintf(stderr, "(%s:%d) Read more data in than expected for "\
+ "%s: %s (%d)\n",
+ __FILE__, __LINE__, file, strerror(EIO), EIO);
+ free(*contents);
+ return errno;
+ }
+ /* chop() implementation */
+ if (*(*contents + (ssize_t)(bytes_read - 1)) == '\n')
+ *(*contents + (ssize_t) (bytes_read - 1)) = 0;
+
+ return 0;
+}
+
+static int read_data(const char *dir, const char *name, char *dst, ssize_t size)
+{
+ char *data = NULL;
+ char file[FILENAMESZ];
+ int rc = 0;
+
+ memset(file, 0, FILENAMESZ);
+ strncat(file, dir, FILENAMESZ);
+ strncat(file, name, FILENAMESZ);
+
+ if (file_exist(file)) {
+ rc = read_file(file, &data);
+ if (debug)
+ fprintf(stderr, "(%s:%d) Read from %s:[%s]\n",
+ __FILE__, __LINE__, file, data);
+ if (!rc)
+ memcpy(dst, data, size);
+ free(data);
+ }
+
+ return rc;
+}
+
+static int read_int_data(const char *dir, const char *name, int *dst)
+{
+ int rc = 0;
+ char contents[5]; /* The flag is a 1 byte value */
+
+ rc = read_data(dir, name, (char *)&contents, sizeof(contents));
+ if (!rc)
+ *dst = atoi(contents);
+
+ return rc;
+}
+
+/*
+ * Finds the etherrnetX and targetX under the sysfs directory.
+ */
+static int find_sysfs_dirs(const char *fpath, const struct stat *sb,
+ int tflag, struct FTW *ftw)
+{
+ if (tflag == FTW_D &&
+ (strstr(fpath + ftw->base, "target")))
+ target_list[tgt_cnt++] = strdup(fpath);
+
+ if (tflag == FTW_D &&
+ (strstr(fpath + ftw->base, "ethernet")))
+ nic_list[nic_cnt++] = strdup(fpath);
+
+ return 0;
+}
+
+/*
+ * Routines to fill in the context values.
+ */
+static int fill_nic_context(const char *dir, struct boot_context *context)
+{
+ int rc = 0;
+
+ rc |= read_data(dir, "/mac", context->mac, sizeof(context->mac));
+ 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));
+
+ return rc;
+}
+
+static int fill_initiator_context(const char *dir, struct boot_context *context)
+{
+ int rc = 0;
+
+ rc |= read_data(dir, "/initiator-name", context->initiatorname,
+ sizeof(context->initiatorname));
+ rc |= read_data(dir, "/isns-server", context->isid,
+ sizeof(context->isid));
+
+ return rc;
+}
+static int fill_tgt_context(const char *dir, struct boot_context *context)
+{
+ int rc = 0;
+
+ rc |= read_data(dir, "/target-name", context->targetname,
+ sizeof(context->targetname));
+ rc |= read_data(dir, "/ip-addr", context->target_ipaddr,
+ sizeof(context->target_ipaddr));
+ rc |= read_int_data(dir, "/port", &context->target_port);
+ rc |= read_data(dir, "/lun", context->lun,
+ sizeof(context->lun));
+ rc |= read_data(dir, "/chap-name", context->chap_name,
+ sizeof(context->chap_name));
+ rc |= read_data(dir, "/chap-secret", context->chap_password,
+ sizeof(context->chap_password));
+ rc |= read_data(dir, "/rev-chap-name", context->chap_name_in,
+ sizeof(context->chap_name_in));
+ rc |= read_data(dir, "/rev-chap-name-secret", context->chap_password_in,
+ sizeof(context->chap_password_in));
+
+ return 0;
+}
+
+#define IBFT_SYSFS_FLAG_NAME "/flags"
+#define IBFT_SYSFS_FLAG_FW_SEL_BOOT 2
+
+static int find_boot_flag(char *list[], ssize_t size, int *boot_idx)
+{
+ int rc = -1;
+ int i, flag = -1;
+
+ for (i = 0; i < size; i++, flag = -1) {
+ rc = read_int_data(list[i], IBFT_SYSFS_FLAG_NAME, &flag);
+ if (flag & IBFT_SYSFS_FLAG_FW_SEL_BOOT) {
+ *boot_idx = i;
+ rc = 0;
+ break;
+ }
+
+ }
+
+ return rc;
+}
+
+static void deallocate_lists(void)
+{
+ int i;
+
+ for (i = 0; i < nic_cnt; i++)
+ free(nic_list[i]);
+
+ nic_cnt = 0;
+ for (i = 0; i < tgt_cnt; i++)
+ free(target_list[i]);
+
+ tgt_cnt = 0;
+
+}
+
+int fwparam_ibft_sysfs(struct boot_context *context, const char *filepath)
+{
+ char initiator_dir[FILENAMESZ];
+ char *root_sysfs = NULL;
+ int rc = 1;
+ int nic_idx = -1, tgt_idx = -1;
+
+ if (filepath)
+ root_sysfs = (char *)filepath;
+ else
+ root_sysfs = IBFT_SYSFS_ROOT;
+
+ memset(&initiator_dir, 0 , FILENAMESZ);
+ strncat(initiator_dir, root_sysfs, FILENAMESZ);
+ strncat(initiator_dir, "initiator", FILENAMESZ);
+
+ if (file_exist(initiator_dir)) {
+
+ /* Find the target's and the ethernet's */
+ rc = nftw(root_sysfs, find_sysfs_dirs, 20, 1);
+
+ /* Find wihch target and which ethernet have
+ the boot flag set. */
+ rc = find_boot_flag(nic_list, nic_cnt, &nic_idx);
+ if (rc)
+ goto free;
+
+ rc = find_boot_flag(target_list, tgt_cnt, &tgt_idx);
+ if (rc)
+ goto free;
+
+ /* Fill in the context values */
+ rc = fill_nic_context(nic_list[nic_idx], context);
+ rc |= fill_tgt_context(target_list[tgt_idx], context);
+ rc |= fill_initiator_context(initiator_dir, context);
+ }
+free:
+ deallocate_lists();
+ return rc;
+}
diff -Naurp open-iscsi-2.0-870-rc1/utils/fwparam_ibft/Makefile open-iscsi-2.0-870-rc1.work/utils/fwparam_ibft/Makefile
--- open-iscsi-2.0-870-rc1/utils/fwparam_ibft/Makefile 2008-06-30 20:14:03.000000000 -0500
+++ open-iscsi-2.0-870-rc1.work/utils/fwparam_ibft/Makefile 2008-06-30 21:22:44.000000000 -0500
@@ -22,7 +22,7 @@
#
OBJS := fwparam_ibft.o fw_entry.o
-OBJS += prom_lex.o prom_parse.tab.o fwparam_ppc.o
+OBJS += prom_lex.o prom_parse.tab.o fwparam_ppc.o fwparam_ibft_sysfs.o
CLEANFILES = $(OBJS) *.output *~
OPTFLAGS ?= -O2 -g -fPIC

View File

@ -1,127 +0,0 @@
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/log.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/log.c
--- open-iscsi-2.0-872-rc1-bnx2i/usr/log.c 2010-05-06 15:26:01.000000000 -0500
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/log.c 2010-05-06 15:51:47.000000000 -0500
@@ -281,10 +281,15 @@ void log_do_log_daemon(int prio, void *p
void log_do_log_stderr(int prio, void *priv, const char *fmt, va_list ap)
{
- fprintf(stderr, "%s: ", log_name);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- fflush(stderr);
+ if (prio == LOG_INFO) {
+ vfprintf(stdout, fmt, ap);
+ fprintf(stdout, "\n");
+ } else {
+ fprintf(stderr, "%s: ", log_name);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+ }
}
void log_warning(const char *fmt, ...)
@@ -313,6 +318,14 @@ void log_debug(int level, const char *fm
}
}
+void log_info(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ log_func(LOG_INFO, log_func_priv, fmt, ap);
+ va_end(ap);
+}
+
static void __dump_line(int level, unsigned char *buf, int *cp)
{
char line[16*3+5], *lp = line;
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/log.h open-iscsi-2.0-872-rc1-bnx2i.work/usr/log.h
--- open-iscsi-2.0-872-rc1-bnx2i/usr/log.h 2010-05-06 15:26:01.000000000 -0500
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/log.h 2010-05-06 15:39:58.000000000 -0500
@@ -71,6 +71,8 @@ extern int log_init(char *program_name,
void *priv);
extern void log_close (pid_t pid);
extern void dump_logmsg (void *);
+extern void log_info(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
extern void log_warning(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
extern void log_error(const char *fmt, ...)
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/session_mgmt.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/session_mgmt.c
--- open-iscsi-2.0-872-rc1-bnx2i/usr/session_mgmt.c 2010-05-06 15:26:01.000000000 -0500
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/session_mgmt.c 2010-05-06 15:43:28.000000000 -0500
@@ -42,10 +42,10 @@ static void log_login_msg(struct node_re
rec->conn[0].port);
iscsid_handle_error(rc);
} else
- log_warning("Login to [iface: %s, target: %s, portal: "
- "%s,%d] successful.", rec->iface.name,
- rec->name, rec->conn[0].address,
- rec->conn[0].port);
+ log_info("Login to [iface: %s, target: %s, portal: "
+ "%s,%d] successful.", rec->iface.name,
+ rec->name, rec->conn[0].address,
+ rec->conn[0].port);
}
struct iscsid_async_req {
@@ -100,15 +100,15 @@ int iscsi_login_portal(void *data, struc
struct iscsid_async_req *async_req = NULL;
int rc = 0, fd;
- log_warning("Logging in to [iface: %s, target: %s, portal: %s,%d]",
- rec->iface.name, rec->name, rec->conn[0].address,
- rec->conn[0].port);
+ log_info("Logging in to [iface: %s, target: %s, portal: %s,%d]",
+ rec->iface.name, rec->name, rec->conn[0].address,
+ rec->conn[0].port);
if (list) {
async_req = calloc(1, sizeof(*async_req));
if (!async_req)
- log_error("Could not allocate memory for async login "
- "handling. Using sequential login instead.");
+ log_info("Could not allocate memory for async login "
+ "handling. Using sequential login instead.");
else
INIT_LIST_HEAD(&async_req->list);
}
@@ -215,10 +215,10 @@ static void log_logout_msg(struct sessio
info->persistent_address, info->port);
iscsid_handle_error(rc);
} else
- log_warning("Logout of [sid: %d, target: %s, "
- "portal: %s,%d] successful.",
- info->sid, info->targetname,
- info->persistent_address, info->port);
+ log_info("Logout of [sid: %d, target: %s, "
+ "portal: %s,%d] successful.",
+ info->sid, info->targetname,
+ info->persistent_address, info->port);
}
static int iscsid_logout_reqs_wait(struct list_head *list)
@@ -252,16 +252,16 @@ int iscsi_logout_portal(struct session_i
int fd, rc;
/* TODO: add fn to add session prefix info like dev_printk */
- log_warning("Logging out of session [sid: %d, target: %s, portal: "
- "%s,%d]",
- info->sid, info->targetname, info->persistent_address,
- info->port);
+ log_info("Logging out of session [sid: %d, target: %s, portal: "
+ "%s,%d]",
+ info->sid, info->targetname, info->persistent_address,
+ info->port);
if (list) {
async_req = calloc(1, sizeof(*async_req));
if (!async_req)
- log_error("Could not allocate memory for async logout "
- "handling. Using sequential logout instead.");
+ log_info("Could not allocate memory for async logout "
+ "handling. Using sequential logout instead.");
}
if (!async_req)

View File

@ -1,16 +0,0 @@
diff -up open-iscsi-2.0-870-rc1/usr/iscsiadm.c.error open-iscsi-2.0-870-rc1/usr/iscsiadm.c
--- open-iscsi-2.0-870-rc1/usr/iscsiadm.c.error 2008-09-30 10:20:15.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/iscsiadm.c 2008-09-30 10:20:15.000000000 +0200
@@ -2141,6 +2141,12 @@ main(int argc, char **argv)
if (mode < 0)
usage(0);
+ if (getuid()) {
+ log_error("Must be run as root.");
+ rc = -1;
+ goto free_ifaces;
+ }
+
if (mode == MODE_FW) {
if ((rc = verify_mode_params(argc, argv, "ml", 0))) {
log_error("fw mode: option '-%c' is not "

View File

@ -1,219 +0,0 @@
diff -aurp open-iscsi-2.0-870.1/include/fw_context.h open-iscsi-2.0-870.1.work/include/fw_context.h
--- open-iscsi-2.0-870.1/include/fw_context.h 2008-11-22 11:06:46.000000000 -0600
+++ open-iscsi-2.0-870.1.work/include/fw_context.h 2008-11-25 11:31:09.000000000 -0600
@@ -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-870.1/utils/fwparam_ibft/fw_entry.c open-iscsi-2.0-870.1.work/utils/fwparam_ibft/fw_entry.c
--- open-iscsi-2.0-870.1/utils/fwparam_ibft/fw_entry.c 2008-11-25 11:34:56.000000000 -0600
+++ open-iscsi-2.0-870.1.work/utils/fwparam_ibft/fw_entry.c 2008-11-25 11:34:25.000000000 -0600
@@ -34,22 +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)
-{
- 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)
@@ -73,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-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c open-iscsi-2.0-870.1.work/utils/fwparam_ibft/fwparam_ibft_sysfs.c
--- open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c 2008-11-25 11:34:56.000000000 -0600
+++ open-iscsi-2.0-870.1.work/utils/fwparam_ibft/fwparam_ibft_sysfs.c 2008-11-25 11:31:09.000000000 -0600
@@ -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

@ -1,202 +0,0 @@
diff -up open-iscsi-2.0-870-rc1/usr/discovery.c.start-iscsid open-iscsi-2.0-870-rc1/usr/discovery.c
--- open-iscsi-2.0-870-rc1/usr/discovery.c.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/discovery.c 2008-09-30 10:41:57.000000000 +0200
@@ -87,7 +87,7 @@ int discovery_offload_sendtargets(int ho
* and get back the results. We should do this since it would
* allows us to then process the results like software iscsi.
*/
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 1);
if (rc) {
log_error("Could not offload sendtargets to %s.\n",
drec->address);
@@ -521,7 +521,7 @@ static int request_initiator_name(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_CONFIG_INAME;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 1);
if (rc)
return EIO;
@@ -531,7 +531,7 @@ static int request_initiator_name(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_CONFIG_IALIAS;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 0);
if (rc)
/* alias is optional so return ok */
return 0;
diff -up open-iscsi-2.0-870-rc1/usr/iscsiadm.c.start-iscsid open-iscsi-2.0-870-rc1/usr/iscsiadm.c
--- open-iscsi-2.0-870-rc1/usr/iscsiadm.c.start-iscsid 2008-09-30 10:41:57.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/iscsiadm.c 2008-09-30 10:41:57.000000000 +0200
@@ -191,7 +191,7 @@ static void kill_iscsid(int priority)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_IMMEDIATE_STOP;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 0);
if (rc) {
iscsid_handle_error(rc);
log_error("Could not stop iscsid. Trying sending iscsid "
@@ -823,7 +823,7 @@ static char *get_config_file(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_CONFIG_FILE;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 1);
if (rc)
return NULL;
@@ -883,7 +883,7 @@ static int print_iscsi_state(int sid)
req.command = MGMT_IPC_SESSION_INFO;
req.u.session.sid = sid;
- err = do_iscsid(&req, &rsp);
+ err = do_iscsid(&req, &rsp, 1);
/*
* for drivers like qla4xxx, iscsid does not display
* anything here since it does not know about it.
@@ -1151,7 +1151,7 @@ session_stats(void *data, struct session
req.command = MGMT_IPC_SESSION_STATS;
req.u.session.sid = info->sid;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 1);
if (rc)
return EIO;
@@ -1617,7 +1617,7 @@ static int isns_dev_attr_query(discovery
memset(&req, 0, sizeof(iscsiadm_req_t));
req.command = MGMT_IPC_ISNS_DEV_ATTR_QUERY;
- err = do_iscsid(&req, &rsp);
+ err = do_iscsid(&req, &rsp, 1);
if (err) {
iscsid_handle_error(err);
return EIO;
diff -up open-iscsi-2.0-870-rc1/usr/iscsid.c.start-iscsid open-iscsi-2.0-870-rc1/usr/iscsid.c
--- open-iscsi-2.0-870-rc1/usr/iscsid.c.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/iscsid.c 2008-09-30 10:41:57.000000000 +0200
@@ -252,7 +252,7 @@ static int sync_session(void *data, stru
req.u.session.sid = info->sid;
memcpy(&req.u.session.rec, &rec, sizeof(node_rec_t));
- do_iscsid(&req, &rsp);
+ do_iscsid(&req, &rsp, 0);
return 0;
}
diff -up open-iscsi-2.0-870-rc1/usr/iscsistart.c.start-iscsid open-iscsi-2.0-870-rc1/usr/iscsistart.c
--- open-iscsi-2.0-870-rc1/usr/iscsistart.c.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/iscsistart.c 2008-09-30 10:41:57.000000000 +0200
@@ -112,7 +112,7 @@ static int stop_event_loop(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_IMMEDIATE_STOP;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 0);
if (rc) {
iscsid_handle_error(rc);
log_error("Could not stop event_loop\n");
@@ -142,7 +142,7 @@ static int setup_session(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_SESSION_LOGIN;
memcpy(&req.u.session.rec, &config_rec, sizeof(node_rec_t));
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 0);
if (rc)
iscsid_handle_error(rc);
diff -up open-iscsi-2.0-870-rc1/usr/util.c.start-iscsid open-iscsi-2.0-870-rc1/usr/util.c
--- open-iscsi-2.0-870-rc1/usr/util.c.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/util.c 2008-09-30 11:25:38.000000000 +0200
@@ -120,7 +120,7 @@ int increase_max_files(void)
#define MAXSLEEP 128
-static mgmt_ipc_err_e iscsid_connect(int *fd)
+static mgmt_ipc_err_e iscsid_connect(int *fd, int iscsid_start)
{
int nsec;
struct sockaddr_un addr;
@@ -145,8 +145,12 @@ static mgmt_ipc_err_e iscsid_connect(int
/* If iscsid isn't there, there's no sense
* in retrying. */
- if (errno == ECONNREFUSED)
- break;
+ if (errno == ECONNREFUSED) {
+ if (iscsid_start && nsec == 1)
+ system("/etc/rc.d/init.d/iscsid force-start");
+ else
+ break;
+ }
/*
* Delay before trying again
@@ -158,11 +162,11 @@ static mgmt_ipc_err_e iscsid_connect(int
return MGMT_IPC_ERR_ISCSID_COMM_ERR;
}
-mgmt_ipc_err_e iscsid_request(int *fd, iscsiadm_req_t *req)
+mgmt_ipc_err_e iscsid_request(int *fd, iscsiadm_req_t *req, int start_iscsid)
{
int err;
- err = iscsid_connect(fd);
+ err = iscsid_connect(fd, start_iscsid);
if (err)
return err;
@@ -192,12 +196,13 @@ mgmt_ipc_err_e iscsid_response(int fd, i
return iscsi_err;
}
-mgmt_ipc_err_e do_iscsid(iscsiadm_req_t *req, iscsiadm_rsp_t *rsp)
+mgmt_ipc_err_e do_iscsid(iscsiadm_req_t *req, iscsiadm_rsp_t *rsp,
+ int start_iscsid)
{
int fd;
mgmt_ipc_err_e err;
- err = iscsid_request(&fd, req);
+ err = iscsid_request(&fd, req, start_iscsid);
if (err)
return err;
@@ -220,7 +225,7 @@ int iscsid_req_by_rec_async(iscsiadm_cmd
req.command = cmd;
memcpy(&req.u.session.rec, rec, sizeof(node_rec_t));
- return iscsid_request(fd, &req);
+ return iscsid_request(fd, &req, 1);
}
int iscsid_req_by_rec(iscsiadm_cmd_e cmd, node_rec_t *rec)
@@ -241,7 +246,7 @@ int iscsid_req_by_sid_async(iscsiadm_cmd
req.command = cmd;
req.u.session.sid = sid;
- return iscsid_request(fd, &req);
+ return iscsid_request(fd, &req, 1);
}
int iscsid_req_by_sid(iscsiadm_cmd_e cmd, int sid)
diff -up open-iscsi-2.0-870-rc1/usr/util.h.start-iscsid open-iscsi-2.0-870-rc1/usr/util.h
--- open-iscsi-2.0-870-rc1/usr/util.h.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/util.h 2008-09-30 10:41:57.000000000 +0200
@@ -13,9 +13,10 @@ extern int oom_adjust(void);
extern void daemon_init(void);
extern int increase_max_files(void);
-extern int do_iscsid(struct iscsiadm_req *req, struct iscsiadm_rsp *rsp);
+extern int do_iscsid(struct iscsiadm_req *req, struct iscsiadm_rsp *rsp,
+ int iscsid_start);
extern void iscsid_handle_error(int err);
-extern int iscsid_request(int *fd, struct iscsiadm_req *req);
+extern int iscsid_request(int *fd, struct iscsiadm_req *req, int iscsid_start);
extern int iscsid_response(int fd, int cmd, struct iscsiadm_rsp *rsp);
extern int iscsid_req_wait(int cmd, int fd);
extern int iscsid_req_by_rec_async(int cmd, struct node_rec *rec, int *fd);

View File

@ -1,38 +0,0 @@
diff -up open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c~ open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c
--- open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c~ 2009-02-12 15:30:52.000000000 +0100
+++ open-iscsi-2.0-870.1/libiscsi/pylibiscsi.c 2009-02-12 15:48:30.000000000 +0100
@@ -485,19 +485,28 @@ static PyObject *pylibiscsi_discover_sen
char *kwlist[] = {"address", "port", "authinfo", NULL};
const char *address = NULL;
int i, nr_found, port = 3260;
- PyIscsiChapAuthInfo *pyauthinfo = NULL;
+ PyObject *authinfo_arg = NULL;
const struct libiscsi_auth_info *authinfo = NULL;
struct libiscsi_node *found_nodes;
PyObject* found_node_list;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|iO!",
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|iO",
kwlist, &address, &port,
- &PyIscsiChapAuthInfo_Type,
- &pyauthinfo))
+ &authinfo_arg))
return NULL;
- if (pyauthinfo)
- authinfo = &pyauthinfo->info;
+ if (authinfo_arg) {
+ if (PyObject_IsInstance(authinfo_arg, (PyObject *)
+ &PyIscsiChapAuthInfo_Type)) {
+ PyIscsiChapAuthInfo *pyauthinfo =
+ (PyIscsiChapAuthInfo *)authinfo_arg;
+ authinfo = &pyauthinfo->info;
+ } else if (authinfo_arg != Py_None) {
+ PyErr_SetString(PyExc_ValueError,
+ "invalid authinfo type");
+ return NULL;
+ }
+ }
if (libiscsi_discover_sendtargets(context, address, port, authinfo,
&nr_found, &found_nodes)) {

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
diff -up open-iscsi-2.0-870.1/usr/iscsi_sysfs.c~ open-iscsi-2.0-870.1/usr/iscsi_sysfs.c
--- open-iscsi-2.0-870.1/usr/iscsi_sysfs.c~ 2008-11-22 18:06:46.000000000 +0100
+++ open-iscsi-2.0-870.1/usr/iscsi_sysfs.c 2010-02-14 10:28:45.030720189 +0100
@@ -22,6 +22,8 @@
#include <string.h>
#include <errno.h>
#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "log.h"
#include "initiator.h"

View File

@ -1,55 +0,0 @@
diff -up open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ppc.c.crash open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ppc.c
--- open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ppc.c.crash 2008-11-22 18:06:46.000000000 +0100
+++ open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ppc.c 2009-04-27 20:33:33.000000000 +0200
@@ -341,6 +341,7 @@ static int loop_devs(const char *devtree
int i;
char prefix[256];
+ nic_count = 0;
error = nftw(devtree, find_nics, 20, 0);
if (error)
return error;
@@ -352,6 +353,7 @@ static int loop_devs(const char *devtree
qsort(niclist, nic_count, sizeof(char *), nic_cmp);
snprintf(prefix, sizeof(prefix), "%s/%s", devtree, "aliases");
+ dev_count = 0;
error = nftw(prefix, find_initiator, 20, 0);
if (error)
return error;
@@ -366,8 +368,6 @@ static int loop_devs(const char *devtree
}
}
- if (!error)
- putchar('\n');
return error;
}
@@ -425,7 +425,7 @@ static void fill_context(struct boot_con
int fwparam_ppc(struct boot_context *context, const char *filepath)
{
int error;
- int fplen = 0;
+ int dev_count;
char *devtree;
/*
@@ -435,13 +435,10 @@ int fwparam_ppc(struct boot_context *con
* systems that can support iscsi are the ones that provide
* the appropriate FCODE with a load method.
*/
- if (filepath) {
- strncat(filename, filepath, FILENAMESZ);
- fplen = strlen(filename);
- } else
- strncat(filename, DT_TOP, FILENAMESZ);
-
- strncat(filename + fplen, BOOTPATH, FILENAMESZ - fplen);
+ if (filepath)
+ snprintf(filename, FILENAMESZ, "%s%s", filepath, BOOTPATH);
+ else
+ snprintf(filename, FILENAMESZ, "%s%s", DT_TOP, BOOTPATH);
if (debug)
fprintf(stderr, "%s: file:%s; debug:%d\n", __func__, filename,

View File

@ -1,44 +0,0 @@
diff -up open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c~ open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c
--- open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c~ 2009-01-28 22:09:21.000000000 +0100
+++ open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c 2009-01-28 22:10:29.000000000 +0100
@@ -186,6 +186,40 @@ static int get_iface_from_device(const c
break;
}
+ closedir(dirfd);
+
+ if (rc != ENODEV)
+ return rc;
+
+ /* If not found try again with newer kernel networkdev sysfs layout */
+ strncat(dev_dir, "/net", FILENAMESZ);
+
+ if (!file_exist(dev_dir))
+ return rc;
+
+ dirfd = opendir(dev_dir);
+ if (!dirfd)
+ return errno;
+
+ while ((dent = readdir(dirfd))) {
+ if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
+ continue;
+
+ /* Take the first "regular" directory entry */
+ if (strlen(dent->d_name) > (sizeof(context->iface) - 1)) {
+ rc = EINVAL;
+ printf("Net device %s too bug for iface buffer.\n",
+ dent->d_name);
+ break;
+ }
+
+ strcpy(context->iface, dent->d_name);
+ rc = 0;
+ break;
+ }
+
+ closedir(dirfd);
+
return rc;
}

View File

@ -1,221 +0,0 @@
--- open-iscsi-2.0-870.1/usr/idbm.c~ 2009-01-28 13:23:47.000000000 +0100
+++ open-iscsi-2.0-870.1/usr/idbm.c 2009-01-28 13:25:06.000000000 +0100
@@ -843,7 +843,7 @@ int idbm_lock(void)
if (access(LOCK_DIR, F_OK) != 0) {
if (mkdir(LOCK_DIR, 0660) != 0) {
log_error("Could not open %s. Exiting\n", LOCK_DIR);
- exit(-1);
+ return errno;
}
}
@@ -857,10 +857,10 @@ int idbm_lock(void)
break;
if (errno != EEXIST) {
+ log_error("Maybe you are not root?");
log_error("Could not lock discovery DB: %s: %s",
LOCK_WRITE_FILE, strerror(errno));
- log_error("Maybe you are not root?");
- exit(-1);
+ return errno;
} else if (i == 0)
log_debug(2, "Waiting for discovery DB lock");
@@ -915,7 +915,10 @@ static int __idbm_rec_read(node_rec_t *o
if (!info)
return ENOMEM;
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ goto free_info;
+
f = fopen(conf, "r");
if (!f) {
log_debug(5, "Could not open %s err %d\n", conf, errno);
@@ -931,6 +934,7 @@ static int __idbm_rec_read(node_rec_t *o
unlock:
idbm_unlock();
+free_info:
free(info);
return rc;
}
@@ -1386,14 +1390,18 @@ idbm_discovery_read(discovery_rec_t *out
return ENOMEM;
portal = malloc(PATH_MAX);
- if (!portal)
+ if (!portal) {
+ rc = ENOMEM;
goto free_info;
+ }
snprintf(portal, PATH_MAX, "%s/%s,%d", ST_CONFIG_DIR,
addr, port);
log_debug(5, "Looking for config file %s\n", portal);
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ goto free_info;
f = idbm_open_rec_r(portal, ST_CONFIG_NAME);
if (!f) {
@@ -1494,7 +1502,9 @@ static int idbm_rec_write(node_rec_t *re
rec->name, rec->conn[0].address, rec->conn[0].port);
log_debug(5, "Looking for config file %s", portal);
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ goto free_portal;
rc = stat(portal, &statb);
if (rc) {
@@ -1579,13 +1589,16 @@ idbm_discovery_write(discovery_rec_t *re
return ENOMEM;
}
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ goto free_portal;
+
snprintf(portal, PATH_MAX, "%s", ST_CONFIG_DIR);
if (access(portal, F_OK) != 0) {
if (mkdir(portal, 0660) != 0) {
log_error("Could not make %s\n", portal);
rc = errno;
- goto free_portal;
+ goto unlock;
}
}
@@ -1596,13 +1609,14 @@ idbm_discovery_write(discovery_rec_t *re
if (!f) {
log_error("Could not open %s err %d\n", portal, errno);
rc = errno;
- goto free_portal;
+ goto unlock;
}
idbm_print(IDBM_PRINT_TYPE_DISCOVERY, rec, 1, f);
fclose(f);
-free_portal:
+unlock:
idbm_unlock();
+free_portal:
free(portal);
return rc;
}
@@ -1722,7 +1736,10 @@ int idbm_add_node(node_rec_t *newrec, di
log_debug(7, "node addition making link from %s to %s", node_portal,
disc_portal);
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ goto free_portal;
+
if (symlink(node_portal, disc_portal)) {
if (errno == EEXIST)
log_debug(7, "link from %s to %s exists", node_portal,
@@ -2009,7 +2026,10 @@ static int idbm_remove_disc_to_node_link
if (rc)
goto done;
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ goto done;
+
if (!stat(portal, &statb)) {
if (unlink(portal)) {
log_error("Could not remove link %s err %d\n",
@@ -2046,7 +2066,10 @@ int idbm_delete_node(node_rec_t *rec)
log_debug(5, "Removing config file %s iface id %s\n",
portal, rec->iface.name);
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ goto free_portal;
+
if (!stat(portal, &statb))
goto rm_conf;
diff -up open-iscsi-2.0-870.1/usr/iface.c~ open-iscsi-2.0-870.1/usr/iface.c
--- open-iscsi-2.0-870.1/usr/iface.c~ 2009-01-28 13:29:31.000000000 +0100
+++ open-iscsi-2.0-870.1/usr/iface.c 2009-01-28 13:29:31.000000000 +0100
@@ -208,7 +208,10 @@ int iface_conf_read(struct iface_rec *if
return 0;
}
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ return rc;
+
rc = __iface_conf_read(iface);
idbm_unlock();
return rc;
@@ -232,11 +235,15 @@ int iface_conf_delete(struct iface_rec *
return ENOMEM;
sprintf(iface_conf, "%s/%s", IFACE_CONFIG_DIR, iface->name);
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ goto free_conf;
+
if (unlink(iface_conf))
rc = errno;
idbm_unlock();
+free_conf:
free(iface_conf);
return rc;
}
@@ -267,10 +274,14 @@ int iface_conf_write(struct iface_rec *i
goto free_conf;
}
- idbm_lock();
+ rc = idbm_lock();
+ if (rc)
+ goto close_f;
+
idbm_print(IDBM_PRINT_TYPE_IFACE, iface, 1, f);
idbm_unlock();
+close_f:
fclose(f);
free_conf:
free(iface_conf);
@@ -471,7 +482,9 @@ void iface_setup_host_bindings(void)
{
int nr_found = 0;
- idbm_lock();
+ if (idbm_lock())
+ return;
+
if (access(IFACE_CONFIG_DIR, F_OK) != 0) {
if (mkdir(IFACE_CONFIG_DIR, 0660) != 0) {
log_error("Could not make %s. HW/OFFLOAD iscsi "
@@ -658,7 +671,12 @@ int iface_for_each_iface(void *data, int
continue;
}
- idbm_lock();
+ err = idbm_lock();
+ if (err) {
+ free(iface);
+ continue;
+ }
+
err = __iface_conf_read(iface);
idbm_unlock();
if (err) {