Resolves: #689359
This commit is contained in:
parent
0206720847
commit
0d27aa2281
@ -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;
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
diff --git a/libiscsi/Makefile b/libiscsi/Makefile
|
|
||||||
index 4aeb44f..a91d6b8 100644
|
|
||||||
--- a/libiscsi/Makefile
|
|
||||||
+++ b/libiscsi/Makefile
|
|
||||||
@@ -3,7 +3,7 @@
|
|
||||||
OSNAME=$(shell uname -s)
|
|
||||||
OPTFLAGS ?= -O2 -g
|
|
||||||
WARNFLAGS ?= -Wall -Wstrict-prototypes
|
|
||||||
-CFLAGS = $(OPTFLAGS) $(WARNFLAGS) -I../include -I../usr -I../utils/open-isns \
|
|
||||||
+CFLAGS = $(OPTFLAGS) $(WARNFLAGS) -I../include -I../usr \
|
|
||||||
-D$(OSNAME) -fPIC -D_GNU_SOURCE -fvisibility=hidden
|
|
||||||
LIB = libiscsi.so.0
|
|
||||||
TESTS = tests/test_discovery_sendtargets tests/test_discovery_firmware
|
|
||||||
@@ -43,11 +43,10 @@ fw-objs/%.o: ../utils/fwparam_ibft/%.c
|
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
$(LIB): $(COMMON_OBJS) $(FW_OBJS) $(USR_OBJS) libiscsi.o
|
|
||||||
- $(CC) $(CFLAGS) -L../utils/open-isns -lisns -shared -Wl,-soname,$(LIB) $^ -o $@
|
|
||||||
+ $(CC) $(CFLAGS) -shared -Wl,-soname,$(LIB) $^ -o $@
|
|
||||||
ln -s -f $(LIB) libiscsi.so
|
|
||||||
|
|
||||||
$(TESTS): $(FW_OBJS) $(COMMON_OBJS) $(USR_OBJS) $(LIB)
|
|
||||||
- $(CC) $(CFLAGS) -L../utils/open-isns -lisns -c $< -o $@
|
|
||||||
|
|
||||||
html: libiscsi.h libiscsi.doxy
|
|
||||||
doxygen libiscsi.doxy
|
|
||||||
diff --git a/usr/Makefile b/usr/Makefile
|
|
||||||
index 8e505bf..13a60f9 100644
|
|
||||||
--- a/usr/Makefile
|
|
||||||
+++ b/usr/Makefile
|
|
||||||
@@ -31,7 +31,7 @@ endif
|
|
||||||
OPTFLAGS ?= -O2 -g
|
|
||||||
WARNFLAGS ?= -Wall -Wstrict-prototypes
|
|
||||||
CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -I../include -I. -I../utils/open-isns \
|
|
||||||
- -D$(OSNAME) $(IPC_CFLAGS)
|
|
||||||
+ -D$(OSNAME) $(IPC_CFLAGS) -DISNS_ENABLE
|
|
||||||
PROGRAMS = iscsid iscsiadm iscsistart
|
|
||||||
|
|
||||||
# libc compat files
|
|
||||||
diff --git a/usr/discovery.c b/usr/discovery.c
|
|
||||||
index 2233de7..02c6f25 100644
|
|
||||||
--- a/usr/discovery.c
|
|
||||||
+++ b/usr/discovery.c
|
|
||||||
@@ -45,9 +45,11 @@
|
|
||||||
#include "iscsid_req.h"
|
|
||||||
#include "iscsi_util.h"
|
|
||||||
/* libisns includes */
|
|
||||||
+#ifdef ISNS_ENABLE
|
|
||||||
#include "isns.h"
|
|
||||||
#include "paths.h"
|
|
||||||
#include "message.h"
|
|
||||||
+#endif
|
|
||||||
|
|
||||||
#ifdef SLP_ENABLE
|
|
||||||
#include "iscsi-slp-discovery.h"
|
|
||||||
@@ -94,6 +96,7 @@ static int request_initiator_name(void)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+#ifdef ISNS_ENABLE
|
|
||||||
void discovery_isns_free_servername(void)
|
|
||||||
{
|
|
||||||
if (isns_config.ic_server_name)
|
|
||||||
@@ -367,6 +370,7 @@ retry:
|
|
||||||
discovery_isns_free_servername();
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
+#endif
|
|
||||||
|
|
||||||
int discovery_fw(void *data, struct iface_rec *iface,
|
|
||||||
struct list_head *rec_list)
|
|
||||||
--
|
|
||||||
1.6.6.1
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
diff -aurp open-iscsi-2.0-871.1-bnx2i/brcm_iscsi_uio/src/unix/nic.c open-iscsi-2.0-871.1-bnx2i.work/brcm_iscsi_uio/src/unix/nic.c
|
|
||||||
--- open-iscsi-2.0-871.1-bnx2i/brcm_iscsi_uio/src/unix/nic.c 2010-05-20 20:16:05.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-871.1-bnx2i.work/brcm_iscsi_uio/src/unix/nic.c 2010-07-07 21:32:22.000000000 -0500
|
|
||||||
@@ -1168,6 +1168,7 @@ void *nic_loop(void *arg)
|
|
||||||
nic->start_time = time(NULL);
|
|
||||||
nic->flags &= ~NIC_UNITIALIZED;
|
|
||||||
nic->flags |= NIC_INITIALIZED;
|
|
||||||
+ nic->state &= ~NIC_STOPPED;
|
|
||||||
nic->state |= NIC_RUNNING;
|
|
||||||
|
|
||||||
/* Signal that the device enable is done */
|
|
||||||
diff -aurp open-iscsi-2.0-871.1-bnx2i/brcm_iscsi_uio/src/unix/nic_utils.c open-iscsi-2.0-871.1-bnx2i.work/brcm_iscsi_uio/src/unix/nic_utils.c
|
|
||||||
--- open-iscsi-2.0-871.1-bnx2i/brcm_iscsi_uio/src/unix/nic_utils.c 2010-05-20 20:16:05.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-871.1-bnx2i.work/brcm_iscsi_uio/src/unix/nic_utils.c 2010-07-07 21:32:22.000000000 -0500
|
|
||||||
@@ -831,13 +831,14 @@ int nic_disable(nic_t *nic)
|
|
||||||
if( (nic->flags & NIC_ENABLED) &&
|
|
||||||
(nic->state & NIC_RUNNING))
|
|
||||||
{
|
|
||||||
+ /* Wait for the device to be disabled */
|
|
||||||
+ pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
+
|
|
||||||
nic->flags &= ~NIC_ENABLED;
|
|
||||||
nic->flags |= NIC_DISABLED;
|
|
||||||
nic->state &= ~NIC_RUNNING;
|
|
||||||
nic->state |= NIC_STOPPED;
|
|
||||||
|
|
||||||
- /* Wait for the device to be disabled */
|
|
||||||
- pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
pthread_cond_wait(&nic->disable_wait_cond,
|
|
||||||
&nic->nic_mutex);
|
|
||||||
pthread_mutex_unlock(&nic->nic_mutex);
|
|
@ -1,289 +0,0 @@
|
|||||||
diff -aurp open-iscsi-2.0-872-rc1-bnx2i.base/usr/discoveryd.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/discoveryd.c
|
|
||||||
--- open-iscsi-2.0-872-rc1-bnx2i.base/usr/discoveryd.c 2010-05-18 17:58:00.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/discoveryd.c 2010-05-19 03:09:54.000000000 -0500
|
|
||||||
@@ -54,6 +54,7 @@
|
|
||||||
#define DISC_DEF_POLL_INVL 30
|
|
||||||
|
|
||||||
static LIST_HEAD(iscsi_targets);
|
|
||||||
+static int stop_discoveryd;
|
|
||||||
|
|
||||||
static LIST_HEAD(isns_initiators);
|
|
||||||
static LIST_HEAD(isns_refresh_list);
|
|
||||||
@@ -66,27 +67,64 @@ static void isns_reg_refresh_by_eid_qry(
|
|
||||||
typedef void (do_disc_and_login_fn)(const char *def_iname, char *addr,
|
|
||||||
int port, int poll_inval);
|
|
||||||
|
|
||||||
-static int logout_stale_session(void *data, struct list_head *list,
|
|
||||||
- struct session_info *info)
|
|
||||||
+static int logout_session(void *data, struct list_head *list,
|
|
||||||
+ struct session_info *info)
|
|
||||||
{
|
|
||||||
- struct list_head *stale_rec_list = data;
|
|
||||||
+ struct list_head *rec_list = data;
|
|
||||||
struct node_rec *rec;
|
|
||||||
|
|
||||||
- list_for_each_entry(rec, stale_rec_list, list) {
|
|
||||||
+ list_for_each_entry(rec, rec_list, list) {
|
|
||||||
if (iscsi_match_session(rec, info))
|
|
||||||
return iscsi_logout_portal(info, list);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void free_curr_targets(void)
|
|
||||||
+static void discoveryd_stop(void)
|
|
||||||
{
|
|
||||||
struct node_rec *rec, *tmp_rec;
|
|
||||||
+ int nr_found = 0;
|
|
||||||
|
|
||||||
+ if (list_empty(&iscsi_targets))
|
|
||||||
+ goto done;
|
|
||||||
+
|
|
||||||
+ /*
|
|
||||||
+ * User requested to just login and exit.
|
|
||||||
+ */
|
|
||||||
+ if (!stop_discoveryd)
|
|
||||||
+ goto done;
|
|
||||||
+
|
|
||||||
+ iscsi_logout_portals(&iscsi_targets, &nr_found, 1, logout_session);
|
|
||||||
list_for_each_entry_safe(rec, tmp_rec, &iscsi_targets, list) {
|
|
||||||
list_del(&rec->list);
|
|
||||||
free(rec);
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+done:
|
|
||||||
+ exit(0);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void catch_signal(int signo)
|
|
||||||
+{
|
|
||||||
+ log_debug(1, "%d caught signal -%d...", signo, getpid());
|
|
||||||
+ switch (signo) {
|
|
||||||
+ case SIGTERM:
|
|
||||||
+ stop_discoveryd = 1;
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void setup_signal_handler(void)
|
|
||||||
+{
|
|
||||||
+ struct sigaction sa_old;
|
|
||||||
+ struct sigaction sa_new;
|
|
||||||
+
|
|
||||||
+ sa_new.sa_handler = catch_signal;
|
|
||||||
+ sigemptyset(&sa_new.sa_mask);
|
|
||||||
+ sa_new.sa_flags = 0;
|
|
||||||
+ sigaction(SIGTERM, &sa_new, &sa_old );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
@@ -158,7 +196,7 @@ static void update_sessions(struct list_
|
|
||||||
|
|
||||||
if (!list_empty(&stale_rec_list)) {
|
|
||||||
iscsi_logout_portals(&stale_rec_list, &nr_found, 0,
|
|
||||||
- logout_stale_session);
|
|
||||||
+ logout_session);
|
|
||||||
list_for_each_entry_safe(rec, tmp_rec, &stale_rec_list, list) {
|
|
||||||
list_del(&rec->list);
|
|
||||||
free(rec);
|
|
||||||
@@ -194,6 +232,7 @@ static void do_disc_to_addrs(const char
|
|
||||||
|
|
||||||
pid = fork();
|
|
||||||
if (pid == 0) {
|
|
||||||
+ setup_signal_handler();
|
|
||||||
do_disc_and_login(def_iname, ip_str, portn, poll_inval);
|
|
||||||
exit(0);
|
|
||||||
} else if (pid < 0)
|
|
||||||
@@ -201,6 +240,7 @@ static void do_disc_to_addrs(const char
|
|
||||||
"to perform discovery to %s.\n",
|
|
||||||
errno, strerror(errno), ip_str);
|
|
||||||
else {
|
|
||||||
+ shutdown_callback(pid);
|
|
||||||
log_debug(1, "iSCSI disc and login helper pid=%d", pid);
|
|
||||||
reap_inc();
|
|
||||||
}
|
|
||||||
@@ -872,8 +912,7 @@ static int isns_scn_recv(isns_server_t *
|
|
||||||
|
|
||||||
log_debug(1, "isns_scn_recv");
|
|
||||||
|
|
||||||
- while (1) {
|
|
||||||
-
|
|
||||||
+ while (!stop_discoveryd) {
|
|
||||||
/* reap disc/login procs */
|
|
||||||
reap_proc();
|
|
||||||
/*
|
|
||||||
@@ -999,7 +1038,6 @@ static int isns_eventd(const char *def_i
|
|
||||||
isns_cancel_refresh_timers();
|
|
||||||
fail:
|
|
||||||
isns_clear_refresh_list();
|
|
||||||
- free_curr_targets();
|
|
||||||
|
|
||||||
list_for_each_entry_safe(node, tmp_node, &isns_initiators, list) {
|
|
||||||
list_del(&node->list);
|
|
||||||
@@ -1028,6 +1066,7 @@ static void start_isns(const char *def_i
|
|
||||||
|
|
||||||
rc = isns_eventd(def_iname, disc_addr, port, poll_inval);
|
|
||||||
log_debug(1, "start isns done %d.", rc);
|
|
||||||
+ discoveryd_stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SendTargets */
|
|
||||||
@@ -1087,9 +1126,9 @@ static void do_st_disc_and_login(const c
|
|
||||||
__do_st_disc_and_login(disc_addr, port);
|
|
||||||
if (!poll_inval)
|
|
||||||
break;
|
|
||||||
- } while (!sleep(poll_inval));
|
|
||||||
+ } while (!stop_discoveryd && !sleep(poll_inval));
|
|
||||||
|
|
||||||
- free_curr_targets();
|
|
||||||
+ discoveryd_stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void discoveryd_start(const char *def_iname)
|
|
||||||
diff -aurp open-iscsi-2.0-872-rc1-bnx2i.base/usr/event_poll.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/event_poll.c
|
|
||||||
--- open-iscsi-2.0-872-rc1-bnx2i.base/usr/event_poll.c 2010-05-18 17:58:00.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/event_poll.c 2010-05-19 04:26:20.000000000 -0500
|
|
||||||
@@ -62,21 +62,75 @@ void reap_proc(void)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+static LIST_HEAD(shutdown_callbacks);
|
|
||||||
+
|
|
||||||
+struct shutdown_callback {
|
|
||||||
+ struct list_head list;
|
|
||||||
+ pid_t pid;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+int shutdown_callback(pid_t pid)
|
|
||||||
+{
|
|
||||||
+ struct shutdown_callback *cb;
|
|
||||||
+
|
|
||||||
+ cb = calloc(1, sizeof(*cb));
|
|
||||||
+ if (!cb)
|
|
||||||
+ return ENOMEM;
|
|
||||||
+
|
|
||||||
+ INIT_LIST_HEAD(&cb->list);
|
|
||||||
+ cb->pid = pid;
|
|
||||||
+ log_debug(1, "adding %d for shutdown cb\n", pid);
|
|
||||||
+ list_add_tail(&cb->list, &shutdown_callbacks);
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void shutdown_notify_pids(void)
|
|
||||||
+{
|
|
||||||
+ struct shutdown_callback *cb;
|
|
||||||
+
|
|
||||||
+ list_for_each_entry(cb, &shutdown_callbacks, list) {
|
|
||||||
+ log_debug(1, "Killing %d\n", cb->pid);
|
|
||||||
+ kill(cb->pid, SIGTERM);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int shutdown_wait_pids(void)
|
|
||||||
+{
|
|
||||||
+ struct shutdown_callback *cb, *tmp;
|
|
||||||
+
|
|
||||||
+ list_for_each_entry_safe(cb, tmp, &shutdown_callbacks, list) {
|
|
||||||
+ /*
|
|
||||||
+ * the proc reaper could clean it up, so wait for any
|
|
||||||
+ * sign that it is gone.
|
|
||||||
+ */
|
|
||||||
+ if (waitpid(cb->pid, NULL, WNOHANG)) {
|
|
||||||
+ log_debug(1, "%d done\n", cb->pid);
|
|
||||||
+ list_del(&cb->list);
|
|
||||||
+ free(cb);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return list_empty(&shutdown_callbacks);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
#define POLL_CTRL 0
|
|
||||||
#define POLL_IPC 1
|
|
||||||
#define POLL_MAX 2
|
|
||||||
|
|
||||||
static int event_loop_stop;
|
|
||||||
+static queue_task_t *shutdown_qtask;
|
|
||||||
+
|
|
||||||
|
|
||||||
-void event_loop_exit(void)
|
|
||||||
+void event_loop_exit(queue_task_t *qtask)
|
|
||||||
{
|
|
||||||
+ shutdown_qtask = qtask;
|
|
||||||
event_loop_stop = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void event_loop(struct iscsi_ipc *ipc, int control_fd, int mgmt_ipc_fd)
|
|
||||||
{
|
|
||||||
struct pollfd poll_array[POLL_MAX];
|
|
||||||
- int res;
|
|
||||||
+ int res, has_shutdown_children = 0;
|
|
||||||
|
|
||||||
poll_array[POLL_CTRL].fd = control_fd;
|
|
||||||
poll_array[POLL_CTRL].events = POLLIN;
|
|
||||||
@@ -84,7 +138,16 @@ void event_loop(struct iscsi_ipc *ipc, i
|
|
||||||
poll_array[POLL_IPC].events = POLLIN;
|
|
||||||
|
|
||||||
event_loop_stop = 0;
|
|
||||||
- while (!event_loop_stop) {
|
|
||||||
+ while (1) {
|
|
||||||
+ if (event_loop_stop) {
|
|
||||||
+ if (!has_shutdown_children) {
|
|
||||||
+ has_shutdown_children = 1;
|
|
||||||
+ shutdown_notify_pids();
|
|
||||||
+ }
|
|
||||||
+ if (shutdown_wait_pids())
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
res = poll(poll_array, POLL_MAX, ACTOR_RESOLUTION);
|
|
||||||
if (res > 0) {
|
|
||||||
log_debug(6, "poll result %d", res);
|
|
||||||
@@ -110,4 +173,6 @@ void event_loop(struct iscsi_ipc *ipc, i
|
|
||||||
*/
|
|
||||||
sysfs_cleanup();
|
|
||||||
}
|
|
||||||
+ if (shutdown_qtask)
|
|
||||||
+ mgmt_ipc_write_rsp(shutdown_qtask, MGMT_IPC_OK);
|
|
||||||
}
|
|
||||||
diff -aurp open-iscsi-2.0-872-rc1-bnx2i.base/usr/event_poll.h open-iscsi-2.0-872-rc1-bnx2i.work/usr/event_poll.h
|
|
||||||
--- open-iscsi-2.0-872-rc1-bnx2i.base/usr/event_poll.h 2010-05-18 17:58:00.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/event_poll.h 2010-05-19 03:24:24.000000000 -0500
|
|
||||||
@@ -20,10 +20,12 @@
|
|
||||||
#define EVENT_POLL_H
|
|
||||||
|
|
||||||
struct iscsi_ipc;
|
|
||||||
+struct queue_task;
|
|
||||||
|
|
||||||
+int shutdown_callback(pid_t pid);
|
|
||||||
void reap_proc(void);
|
|
||||||
void reap_inc(void);
|
|
||||||
void event_loop(struct iscsi_ipc *ipc, int control_fd, int mgmt_ipc_fd);
|
|
||||||
-void event_loop_exit(void);
|
|
||||||
+void event_loop_exit(struct queue_task *qtask);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
diff -aurp open-iscsi-2.0-872-rc1-bnx2i.base/usr/mgmt_ipc.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/mgmt_ipc.c
|
|
||||||
--- open-iscsi-2.0-872-rc1-bnx2i.base/usr/mgmt_ipc.c 2010-05-18 17:58:00.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/mgmt_ipc.c 2010-05-19 03:24:33.000000000 -0500
|
|
||||||
@@ -74,7 +74,7 @@ mgmt_ipc_listen(void)
|
|
||||||
void
|
|
||||||
mgmt_ipc_close(int fd)
|
|
||||||
{
|
|
||||||
- event_loop_exit();
|
|
||||||
+ event_loop_exit(NULL);
|
|
||||||
if (fd >= 0)
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
@@ -190,8 +190,7 @@ mgmt_ipc_conn_add(queue_task_t *qtask)
|
|
||||||
static mgmt_ipc_err_e
|
|
||||||
mgmt_ipc_immediate_stop(queue_task_t *qtask)
|
|
||||||
{
|
|
||||||
- event_loop_exit();
|
|
||||||
- mgmt_ipc_write_rsp(qtask, MGMT_IPC_OK);
|
|
||||||
+ event_loop_exit(qtask);
|
|
||||||
return MGMT_IPC_OK;
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
|||||||
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
|
|
||||||
index b7d11b5..fcf2a3a 100644
|
|
||||||
--- a/usr/iscsiadm.c
|
|
||||||
+++ b/usr/iscsiadm.c
|
|
||||||
@@ -465,7 +465,8 @@ static int iface_fn(void *data, node_rec_t *rec)
|
|
||||||
return op_data->fn(op_data->data, rec);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int for_each_rec(struct node_rec *rec, void *data, idbm_iface_op_fn *fn)
|
|
||||||
+static int __for_each_rec(int verbose, struct node_rec *rec,
|
|
||||||
+ void *data, idbm_iface_op_fn *fn)
|
|
||||||
{
|
|
||||||
struct rec_op_data op_data;
|
|
||||||
int nr_found = 0, rc;
|
|
||||||
@@ -477,16 +478,25 @@ static int for_each_rec(struct node_rec *rec, void *data, idbm_iface_op_fn *fn)
|
|
||||||
|
|
||||||
rc = idbm_for_each_rec(&nr_found, &op_data, iface_fn);
|
|
||||||
if (rc) {
|
|
||||||
- log_error("Could not execute operation on all "
|
|
||||||
- "records. Err %d.", rc);
|
|
||||||
+ if (verbose)
|
|
||||||
+ log_error("Could not execute operation on all "
|
|
||||||
+ "records. Err %d.", rc);
|
|
||||||
} else if (!nr_found) {
|
|
||||||
- log_error("no records found!");
|
|
||||||
+ if (verbose)
|
|
||||||
+ log_error("no records found!");
|
|
||||||
rc = ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int for_each_rec(struct node_rec *rec, void *data,
|
|
||||||
+ idbm_iface_op_fn *fn)
|
|
||||||
+{
|
|
||||||
+ return __for_each_rec(1, rec, data, fn);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
static int login_portals(struct node_rec *pattern_rec)
|
|
||||||
{
|
|
||||||
struct list_head rec_list;
|
|
||||||
@@ -1098,9 +1108,9 @@ new_fail:
|
|
||||||
}
|
|
||||||
|
|
||||||
/* logout and delete records using it first */
|
|
||||||
- rc = for_each_rec(rec, NULL, delete_node);
|
|
||||||
- if (rc)
|
|
||||||
- break;
|
|
||||||
+ rc = __for_each_rec(0, rec, NULL, delete_node);
|
|
||||||
+ if (rc && rc != ENODEV)
|
|
||||||
+ goto delete_fail;
|
|
||||||
|
|
||||||
rc = iface_conf_delete(iface);
|
|
||||||
if (rc)
|
|
||||||
@@ -1167,9 +1177,11 @@ delete_fail:
|
|
||||||
if (rc)
|
|
||||||
goto update_fail;
|
|
||||||
|
|
||||||
- rc = for_each_rec(rec, &set_param, idbm_node_set_param);
|
|
||||||
- if (rc)
|
|
||||||
- break;
|
|
||||||
+ rc = __for_each_rec(0, rec, &set_param, idbm_node_set_param);
|
|
||||||
+ if (rc == ENODEV)
|
|
||||||
+ rc = 0;
|
|
||||||
+ else if (rc)
|
|
||||||
+ goto update_fail;
|
|
||||||
|
|
||||||
printf("%s updated.\n", iface->name);
|
|
||||||
break;
|
|
||||||
--
|
|
||||||
1.6.6.1
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
|||||||
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/libiscsi/libiscsi.c open-iscsi-2.0-872-rc1-bnx2i.work/libiscsi/libiscsi.c
|
|
||||||
--- open-iscsi-2.0-872-rc1-bnx2i/libiscsi/libiscsi.c 2010-05-18 17:57:59.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-872-rc1-bnx2i.work/libiscsi/libiscsi.c 2010-05-18 17:58:43.000000000 -0500
|
|
||||||
@@ -40,6 +40,9 @@
|
|
||||||
|
|
||||||
#define CHECK(a) { context->error_str[0] = 0; rc = a; if (rc) goto leave; }
|
|
||||||
|
|
||||||
+/* UGLY, not thread safe :( */
|
|
||||||
+static int sysfs_initialized = 0;
|
|
||||||
+
|
|
||||||
struct libiscsi_context {
|
|
||||||
char error_str[256];
|
|
||||||
/* For get_parameter_helper() */
|
|
||||||
@@ -66,7 +69,10 @@ struct libiscsi_context *libiscsi_init(v
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
log_init("libiscsi", 1024, libiscsi_log, context);
|
|
||||||
- sysfs_init();
|
|
||||||
+ if (!sysfs_initialized) {
|
|
||||||
+ sysfs_init();
|
|
||||||
+ sysfs_initialized = 1;
|
|
||||||
+ }
|
|
||||||
increase_max_files();
|
|
||||||
if (idbm_init(NULL)) {
|
|
||||||
sysfs_cleanup();
|
|
||||||
@@ -529,6 +535,11 @@ int libiscsi_get_firmware_network_config
|
|
||||||
{
|
|
||||||
struct boot_context fw_entry;
|
|
||||||
|
|
||||||
+ if (!sysfs_initialized) {
|
|
||||||
+ sysfs_init();
|
|
||||||
+ sysfs_initialized = 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
memset(config, 0, sizeof *config);
|
|
||||||
memset(&fw_entry, 0, sizeof fw_entry);
|
|
||||||
if (fw_get_entry(&fw_entry))
|
|
||||||
@@ -551,6 +562,11 @@ int libiscsi_get_firmware_initiator_name
|
|
||||||
{
|
|
||||||
struct boot_context fw_entry;
|
|
||||||
|
|
||||||
+ if (!sysfs_initialized) {
|
|
||||||
+ sysfs_init();
|
|
||||||
+ sysfs_initialized = 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
memset(initiatorname, 0, LIBISCSI_VALUE_MAXLEN);
|
|
||||||
memset(&fw_entry, 0, sizeof fw_entry);
|
|
||||||
if (fw_get_entry(&fw_entry))
|
|
@ -1,11 +0,0 @@
|
|||||||
--- open-iscsi-2.0-871.1.1-bnx2i/usr/iscsi_sysfs.c 2010-01-15 02:24:02.000000000 -0600
|
|
||||||
+++ open-iscsi-2.0-871.1.1-bnx2i.work/usr/iscsi_sysfs.c 2010-01-15 09:50:41.000000000 -0600
|
|
||||||
@@ -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"
|
|
@ -1,10 +0,0 @@
|
|||||||
--- open-iscsi-2.0-871.1.1-bnx2i/usr/log.h 2010-01-21 16:12:53.535261347 -0500
|
|
||||||
+++ open-iscsi-2.0-871.1.1-bnx2i.work/usr/log.h 2010-01-21 15:54:08.475338365 -0500
|
|
||||||
@@ -27,6 +27,7 @@
|
|
||||||
#define LOG_H
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
+#include <sys/types.h>
|
|
||||||
#include "iscsid.h"
|
|
||||||
|
|
||||||
union semun {
|
|
@ -1,82 +0,0 @@
|
|||||||
From d18f846d992629d39a8bd52df21bdc41f50ab325 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benjamin Li <benli@broadcom.com>
|
|
||||||
Date: Tue, 27 Jul 2010 13:59:37 -0700
|
|
||||||
Subject: [PATCH 2/4] This will fix many of the 10G ring wrapping problems:
|
|
||||||
|
|
||||||
* This will fix the CQE wrapping problem. One way to exhibit this is to login to the target to bring up the uIP stack. Then ping the IP address of the uIP stack. Around the 128th packet which is the size of the CQE ring, ping will start seeing duplicate packets. This is becuse the CQE was wrapping using the BD consumer index rather then the consumer index for the CQE when calculating the new CQE consumer index.
|
|
||||||
|
|
||||||
* Fix a bnx2x BD wrapping problem.
|
|
||||||
|
|
||||||
This will fix a BD wrapping problem where when running through the
|
|
||||||
entire BD ring, the next BD would be incorrect and push invalid data
|
|
||||||
through the stack.
|
|
||||||
|
|
||||||
Here the BD consumer index is properly anded with the maximum BD's in
|
|
||||||
the ring to properly keep the BD index.
|
|
||||||
|
|
||||||
* Always continue to process the RX ring. There could be other items
|
|
||||||
on the ring other then eth_rx_cqe which will need to be cleaned off
|
|
||||||
the ring.
|
|
||||||
---
|
|
||||||
brcm_iscsi_uio/src/unix/libs/bnx2x.c | 9 +++++----
|
|
||||||
brcm_iscsi_uio/src/unix/libs/bnx2x.h | 3 +++
|
|
||||||
2 files changed, 8 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/libs/bnx2x.c b/brcm_iscsi_uio/src/unix/libs/bnx2x.c
|
|
||||||
index ce71109..c1968cf 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/libs/bnx2x.c
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/libs/bnx2x.c
|
|
||||||
@@ -1138,8 +1138,8 @@ static int bnx2x_read(nic_t *nic, packet_t *pkt)
|
|
||||||
|
|
||||||
hw_cons = bp->get_rx_cons(bp);
|
|
||||||
sw_cons = bp->rx_cons;
|
|
||||||
- bd_cons = bp->rx_bd_cons;
|
|
||||||
- bd_prod = bp->rx_bd_prod;
|
|
||||||
+ bd_cons = BNX2X_RX_BD(bp->rx_bd_cons);
|
|
||||||
+ bd_prod = BNX2X_RX_BD(bp->rx_bd_prod);
|
|
||||||
|
|
||||||
if (sw_cons != hw_cons) {
|
|
||||||
uint16_t comp_ring_index = sw_cons & BNX2X_MAX_RCQ_DESC_CNT;
|
|
||||||
@@ -1147,7 +1147,8 @@ static int bnx2x_read(nic_t *nic, packet_t *pkt)
|
|
||||||
union eth_rx_cqe *cqe;
|
|
||||||
__u8 cqe_fp_flags;
|
|
||||||
void *rx_pkt;
|
|
||||||
- int len, pad = 0;;
|
|
||||||
+ int len, pad = 0;
|
|
||||||
+ rc = 1;
|
|
||||||
|
|
||||||
cqe = &bp->rx_comp_ring[comp_ring_index];
|
|
||||||
cqe_fp_flags = cqe->fast_path_cqe.type_error_flags;
|
|
||||||
@@ -1199,7 +1200,7 @@ static int bnx2x_read(nic_t *nic, packet_t *pkt)
|
|
||||||
bd_prod = BNX2X_NEXT_RX_IDX(bd_prod);
|
|
||||||
|
|
||||||
}
|
|
||||||
- sw_cons = BNX2X_NEXT_RCQ_IDX(bd_cons);
|
|
||||||
+ sw_cons = BNX2X_NEXT_RCQ_IDX(sw_cons);
|
|
||||||
bp->rx_prod = BNX2X_NEXT_RCQ_IDX(bp->rx_prod);
|
|
||||||
}
|
|
||||||
bp->rx_cons = sw_cons;
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/libs/bnx2x.h b/brcm_iscsi_uio/src/unix/libs/bnx2x.h
|
|
||||||
index 20c64ad..620f069 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/libs/bnx2x.h
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/libs/bnx2x.h
|
|
||||||
@@ -332,6 +332,8 @@ struct iro {
|
|
||||||
|
|
||||||
#define BNX2X_RX_DESC_CNT (4096 / sizeof(struct eth_rx_bd))
|
|
||||||
#define BNX2X_MAX_RX_DESC_CNT (BNX2X_RX_DESC_CNT - 2)
|
|
||||||
+#define BNX2X_NUM_RX_BD (BNX2X_RX_DESC_CNT * 1)
|
|
||||||
+#define BNX2X_MAX_RX_BD (BNX2X_NUM_RX_BD - 1)
|
|
||||||
|
|
||||||
#define BNX2X_TX_DESC_CNT (4096 / sizeof(struct eth_tx_start_bd))
|
|
||||||
#define BNX2X_MAX_TX_DESC_CNT (BNX2X_TX_DESC_CNT - 1)
|
|
||||||
@@ -341,6 +343,7 @@ struct iro {
|
|
||||||
|
|
||||||
#define BNX2X_NEXT_RCQ_IDX(x) ((((x) & BNX2X_MAX_RCQ_DESC_CNT) == \
|
|
||||||
(BNX2X_MAX_RCQ_DESC_CNT - 1)) ? (x) + 2 : (x) + 1)
|
|
||||||
+#define BNX2X_RX_BD(x) ((x) & BNX2X_MAX_RX_BD)
|
|
||||||
|
|
||||||
#define BNX2X_NEXT_TX_BD(x) (((x) & (BNX2X_MAX_TX_DESC_CNT - 1)) == \
|
|
||||||
(BNX2X_MAX_TX_DESC_CNT - 1)) ? \
|
|
||||||
--
|
|
||||||
1.7.1
|
|
||||||
|
|
@ -1,236 +0,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-05-18 17:58:00.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/initiator.c 2010-05-18 21:40:44.000000000 -0500
|
|
||||||
@@ -1096,6 +1096,18 @@ static void iscsi_login_timedout(void *d
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+static void iscsi_uio_poll_login_timedout(void *data)
|
|
||||||
+{
|
|
||||||
+ struct queue_task *qtask = data;
|
|
||||||
+ struct iscsi_conn *conn = qtask->conn;
|
|
||||||
+ iscsi_session_t *session = conn->session;
|
|
||||||
+
|
|
||||||
+ log_debug(3, "timeout waiting for UIO ...\n");
|
|
||||||
+ mgmt_ipc_write_rsp(qtask, MGMT_IPC_ERR_TRANS_TIMEOUT);
|
|
||||||
+ conn_delete_timers(conn);
|
|
||||||
+ __session_destroy(session);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static void iscsi_login_redirect(iscsi_conn_t *conn)
|
|
||||||
{
|
|
||||||
iscsi_session_t *session = conn->session;
|
|
||||||
@@ -2049,6 +2061,52 @@ cleanup:
|
|
||||||
session_conn_shutdown(conn, qtask, err);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static void session_conn_uio_poll(void *data)
|
|
||||||
+{
|
|
||||||
+ struct iscsi_conn_context *conn_context = data;
|
|
||||||
+ iscsi_conn_t *conn = conn_context->conn;
|
|
||||||
+ struct iscsi_session *session = conn->session;
|
|
||||||
+ queue_task_t *qtask = conn_context->data;
|
|
||||||
+ int rc;
|
|
||||||
+
|
|
||||||
+ log_debug(4, "retrying uio poll");
|
|
||||||
+ rc = __set_net_config(session->t, session, &conn->session->nrec.iface);
|
|
||||||
+ if (rc != 0) {
|
|
||||||
+ if (rc == -EAGAIN) {
|
|
||||||
+ conn_context->data = qtask;
|
|
||||||
+ iscsi_sched_conn_context(conn_context, conn, 2,
|
|
||||||
+ EV_UIO_POLL);
|
|
||||||
+ return;
|
|
||||||
+ } else {
|
|
||||||
+ log_error("session_conn_uio_poll() "
|
|
||||||
+ "connection failure [0x%x]", rc);
|
|
||||||
+ actor_delete(&conn->login_timer);
|
|
||||||
+ iscsi_login_eh(conn, qtask, MGMT_IPC_ERR_INTERNAL);
|
|
||||||
+ iscsi_conn_context_put(conn_context);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ iscsi_conn_context_put(conn_context);
|
|
||||||
+
|
|
||||||
+ actor_delete(&conn->login_timer);
|
|
||||||
+ log_debug(4, "UIO ready trying connect");
|
|
||||||
+
|
|
||||||
+ /* uIP is ready try to connect */
|
|
||||||
+ if (gettimeofday(&conn->initial_connect_time, NULL))
|
|
||||||
+ log_error("Could not get initial connect time. If "
|
|
||||||
+ "login errors iscsid may give up the initial "
|
|
||||||
+ "login early. You should manually login.");
|
|
||||||
+
|
|
||||||
+ conn->state = STATE_XPT_WAIT;
|
|
||||||
+ if (iscsi_conn_connect(conn, qtask)) {
|
|
||||||
+ int delay = ISCSI_CONN_ERR_REOPEN_DELAY;
|
|
||||||
+ log_debug(4, "Waiting %u seconds before trying to reconnect.\n",
|
|
||||||
+ delay);
|
|
||||||
+ queue_delayed_reopen(qtask, delay);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
void iscsi_sched_conn_context(struct iscsi_conn_context *conn_context,
|
|
||||||
struct iscsi_conn *conn, unsigned long tmo,
|
|
||||||
int event)
|
|
||||||
@@ -2085,6 +2143,11 @@ void iscsi_sched_conn_context(struct isc
|
|
||||||
conn_context);
|
|
||||||
actor_schedule(&conn_context->actor);
|
|
||||||
break;
|
|
||||||
+ case EV_UIO_POLL:
|
|
||||||
+ actor_new(&conn_context->actor, session_conn_uio_poll,
|
|
||||||
+ conn_context);
|
|
||||||
+ actor_schedule(&conn_context->actor);
|
|
||||||
+ break;
|
|
||||||
case EV_CONN_LOGOUT_TIMER:
|
|
||||||
actor_timer(&conn_context->actor, tmo * 1000,
|
|
||||||
iscsi_logout_timedout, conn_context);
|
|
||||||
@@ -2150,8 +2213,10 @@ static int session_is_running(node_rec_t
|
|
||||||
}
|
|
||||||
|
|
||||||
static int iface_set_param(struct iscsi_transport *t, struct iface_rec *iface,
|
|
||||||
- struct iscsi_session *session)
|
|
||||||
+ queue_task_t *qtask)
|
|
||||||
{
|
|
||||||
+ struct iscsi_conn *conn = qtask->conn;
|
|
||||||
+ struct iscsi_session *session = conn->session;
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
log_debug(3, "setting iface %s, dev %s, set ip %s, hw %s, "
|
|
||||||
@@ -2170,6 +2235,29 @@ static int iface_set_param(struct iscsi_
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = __set_net_config(t, session, iface);
|
|
||||||
+ if (rc == -EAGAIN && t->template->set_net_config) {
|
|
||||||
+ struct iscsi_conn_context *conn_context;
|
|
||||||
+
|
|
||||||
+ conn_context = iscsi_conn_context_get(conn, 0);
|
|
||||||
+ if (!conn_context) {
|
|
||||||
+ /* while reopening the recv pool should be full */
|
|
||||||
+ log_error("BUG: __session_conn_reopen could "
|
|
||||||
+ "not get conn context for recv.");
|
|
||||||
+ return ENOMEM;
|
|
||||||
+ }
|
|
||||||
+ conn_context->data = qtask;
|
|
||||||
+ conn->state = STATE_XPT_WAIT;
|
|
||||||
+
|
|
||||||
+ iscsi_sched_conn_context(conn_context, conn, 0, EV_UIO_POLL);
|
|
||||||
+
|
|
||||||
+ log_debug(3, "Setting login UIO poll timer "
|
|
||||||
+ "%p timeout %d", &conn->login_timer,
|
|
||||||
+ conn->login_timeout);
|
|
||||||
+ actor_timer(&conn->login_timer, conn->login_timeout * 1000,
|
|
||||||
+ iscsi_uio_poll_login_timedout, qtask);
|
|
||||||
+
|
|
||||||
+ return EAGAIN;
|
|
||||||
+ }
|
|
||||||
if (rc != 0)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
@@ -2203,6 +2291,7 @@ session_login_task(node_rec_t *rec, queu
|
|
||||||
iscsi_session_t *session;
|
|
||||||
iscsi_conn_t *conn;
|
|
||||||
struct iscsi_transport *t;
|
|
||||||
+ int rc;
|
|
||||||
|
|
||||||
if (session_is_running(rec))
|
|
||||||
return MGMT_IPC_ERR_EXISTS;
|
|
||||||
@@ -2276,7 +2365,16 @@ session_login_task(node_rec_t *rec, queu
|
|
||||||
conn = &session->conn[0];
|
|
||||||
qtask->conn = conn;
|
|
||||||
|
|
||||||
- if (iface_set_param(t, &rec->iface, session)) {
|
|
||||||
+ rc = iface_set_param(t, &rec->iface, qtask);
|
|
||||||
+ if (rc == EAGAIN) {
|
|
||||||
+ /*
|
|
||||||
+ * Cannot block iscsid, so caller is going to internally
|
|
||||||
+ * retry the operation.
|
|
||||||
+ */
|
|
||||||
+ qtask->rsp.command = MGMT_IPC_SESSION_LOGIN;
|
|
||||||
+ qtask->rsp.err = MGMT_IPC_OK;
|
|
||||||
+ return MGMT_IPC_OK;
|
|
||||||
+ } else if (rc) {
|
|
||||||
__session_destroy(session);
|
|
||||||
return MGMT_IPC_ERR_LOGIN_FAILURE;
|
|
||||||
}
|
|
||||||
Only in open-iscsi-2.0-872-rc1-bnx2i.work/usr/: initiator.c.orig
|
|
||||||
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/initiator.h open-iscsi-2.0-872-rc1-bnx2i.work/usr/initiator.h
|
|
||||||
--- open-iscsi-2.0-872-rc1-bnx2i/usr/initiator.h 2010-05-18 17:58:00.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/initiator.h 2010-05-18 18:13:12.000000000 -0500
|
|
||||||
@@ -88,6 +88,7 @@ typedef enum iscsi_event_e {
|
|
||||||
EV_CONN_ERROR,
|
|
||||||
EV_CONN_LOGOUT_TIMER,
|
|
||||||
EV_CONN_STOP,
|
|
||||||
+ EV_UIO_POLL,
|
|
||||||
} iscsi_event_e;
|
|
||||||
|
|
||||||
struct queue_task;
|
|
||||||
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/iscsid_req.c open-iscsi-2.0-872-rc1-bnx2i.work/usr/iscsid_req.c
|
|
||||||
--- open-iscsi-2.0-872-rc1-bnx2i/usr/iscsid_req.c 2010-05-18 17:58:00.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/iscsid_req.c 2010-05-18 21:16:21.000000000 -0500
|
|
||||||
@@ -217,6 +217,8 @@ int uip_broadcast(void *buf, size_t buf_
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ log_debug(3, "connected to uIP daemon");
|
|
||||||
+
|
|
||||||
/* Send the data to uIP */
|
|
||||||
if ((err = write(fd, buf, buf_len)) != buf_len) {
|
|
||||||
log_error("got write error (%d/%d), daemon died?",
|
|
||||||
@@ -225,6 +227,8 @@ int uip_broadcast(void *buf, size_t buf_
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ log_debug(3, "send iface config to uIP daemon");
|
|
||||||
+
|
|
||||||
/* Set the socket to a non-blocking read, this way if there are
|
|
||||||
* problems waiting for uIP, iscsid can bailout early */
|
|
||||||
flags = fcntl(fd, F_GETFL, 0);
|
|
||||||
@@ -243,8 +247,10 @@ int uip_broadcast(void *buf, size_t buf_
|
|
||||||
/* Wait for the response */
|
|
||||||
err = read(fd, &rsp, sizeof(rsp));
|
|
||||||
if (err == sizeof(rsp)) {
|
|
||||||
- log_debug(3, "Broadcasted to uIP with length: %ld\n",
|
|
||||||
- buf_len);
|
|
||||||
+ log_debug(3, "Broadcasted to uIP with length: %ld "
|
|
||||||
+ "cmd: 0x%x rsp: 0x%x\n", buf_len,
|
|
||||||
+ rsp.command, rsp.err);
|
|
||||||
+ err = 0;
|
|
||||||
break;
|
|
||||||
} else if((err == -1) && (errno == EAGAIN)) {
|
|
||||||
usleep(250000);
|
|
||||||
@@ -256,12 +262,17 @@ int uip_broadcast(void *buf, size_t buf_
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- if(count == MAX_UIP_BROADCAST_READ_TRIES)
|
|
||||||
- log_error("Could not broadcast to uIP");
|
|
||||||
+ if (count == MAX_UIP_BROADCAST_READ_TRIES) {
|
|
||||||
+ log_error("Could not broadcast to uIP after %d tries",
|
|
||||||
+ count);
|
|
||||||
+ err = -EAGAIN;
|
|
||||||
+ } else if (rsp.err != ISCISD_UIP_MGMT_IPC_DEVICE_UP) {
|
|
||||||
+ log_debug(3, "Device is not ready\n");
|
|
||||||
+ err = -EAGAIN;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
-
|
|
||||||
- return 0;
|
|
||||||
+ return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
void iscsid_handle_error(mgmt_ipc_err_e err)
|
|
||||||
Only in open-iscsi-2.0-872-rc1-bnx2i.work/usr/: iscsid_req.c.orig
|
|
||||||
diff -aurp open-iscsi-2.0-872-rc1-bnx2i/usr/uip_mgmt_ipc.h open-iscsi-2.0-872-rc1-bnx2i.work/usr/uip_mgmt_ipc.h
|
|
||||||
--- open-iscsi-2.0-872-rc1-bnx2i/usr/uip_mgmt_ipc.h 2010-05-18 17:58:00.000000000 -0500
|
|
||||||
+++ open-iscsi-2.0-872-rc1-bnx2i.work/usr/uip_mgmt_ipc.h 2010-05-18 18:13:12.000000000 -0500
|
|
||||||
@@ -55,6 +55,8 @@ typedef enum iscsid_uip_mgmt_ipc_err {
|
|
||||||
ISCISD_UIP_MGMT_IPC_ERR = 1,
|
|
||||||
ISCISD_UIP_MGMT_IPC_ERR_NOT_FOUND = 2,
|
|
||||||
ISCISD_UIP_MGMT_IPC_ERR_NOMEM = 3,
|
|
||||||
+ ISCISD_UIP_MGMT_IPC_DEVICE_UP = 4,
|
|
||||||
+ ISCISD_UIP_MGMT_IPC_DEVICE_INITIALIZING = 5,
|
|
||||||
} iscsid_uip_mgmt_ipc_err_e;
|
|
||||||
|
|
||||||
/* IPC Response */
|
|
@ -1,28 +0,0 @@
|
|||||||
From 4fa631cc1792680b0b7301b15d3bfde73dcb6e98 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benjamin Li <benli@broadcom.com>
|
|
||||||
Date: Mon, 2 Aug 2010 10:36:39 -0700
|
|
||||||
Subject: [PATCH 4/4] Bump uIP version for RHEL6.0
|
|
||||||
|
|
||||||
---
|
|
||||||
brcm_iscsi_uio/configure.ac | 4 ++--
|
|
||||||
1 files changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/brcm_iscsi_uio/configure.ac b/brcm_iscsi_uio/configure.ac
|
|
||||||
index 6cefcc5..7815240 100644
|
|
||||||
--- a/brcm_iscsi_uio/configure.ac
|
|
||||||
+++ b/brcm_iscsi_uio/configure.ac
|
|
||||||
@@ -10,9 +10,9 @@ dnl Written by: Benjamin Li (benli@broadcom.com)
|
|
||||||
dnl
|
|
||||||
|
|
||||||
PACKAGE=brcm_iscsiuio
|
|
||||||
-VERSION=0.5.15
|
|
||||||
+VERSION=0.5.15.rhel6.0.1
|
|
||||||
|
|
||||||
-AC_INIT(brcm_iscsi, 0.5.15, benli@broadcom.com)
|
|
||||||
+AC_INIT(brcm_iscsi, 0.5.15.rhel6.0.1, benli@broadcom.com)
|
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
|
|
||||||
AC_CONFIG_HEADER(config.h)
|
|
||||||
--
|
|
||||||
1.7.1
|
|
||||||
|
|
@ -1,569 +0,0 @@
|
|||||||
From ba0b093ec377b6dc861b5676b70e96505a678f39 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benajmin Li <benli@broadcom.com>
|
|
||||||
Date: Tue, 20 Jul 2010 22:26:25 -0700
|
|
||||||
Subject: [PATCH 1/4] Because in the current iface file doesn't allow one to specify a VLAN
|
|
||||||
tag, the VLAN tag will be taking from the path request given by the CNIC.
|
|
||||||
|
|
||||||
This will also allow uIP to close and reopen devices properly.
|
|
||||||
---
|
|
||||||
brcm_iscsi_uio/src/unix/iscsid_ipc.c | 40 +++++++++++++++++++-
|
|
||||||
brcm_iscsi_uio/src/unix/libs/bnx2.c | 14 -------
|
|
||||||
brcm_iscsi_uio/src/unix/libs/bnx2x.c | 14 -------
|
|
||||||
brcm_iscsi_uio/src/unix/nic.c | 66 ++++++++++++++++++++------------
|
|
||||||
brcm_iscsi_uio/src/unix/nic.h | 16 +++++++-
|
|
||||||
brcm_iscsi_uio/src/unix/nic_nl.c | 56 ++++++++++++++++++++++++---
|
|
||||||
brcm_iscsi_uio/src/unix/nic_utils.c | 70 ++++++++++++++++++++++++++++++++--
|
|
||||||
brcm_iscsi_uio/src/unix/nic_utils.h | 6 ++-
|
|
||||||
brcm_iscsi_uio/src/unix/uevent.c | 2 +-
|
|
||||||
9 files changed, 217 insertions(+), 67 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/iscsid_ipc.c b/brcm_iscsi_uio/src/unix/iscsid_ipc.c
|
|
||||||
index b06100e..4c00ef2 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/iscsid_ipc.c
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/iscsid_ipc.c
|
|
||||||
@@ -131,6 +131,42 @@ static int parse_iface(void * arg)
|
|
||||||
data->u.iface_rec.rec.netdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (nic->flags & NIC_GOING_DOWN) {
|
|
||||||
+ rc = -EIO;
|
|
||||||
+ goto done;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* If we retry too many times allow iscsid to to timeout */
|
|
||||||
+ if (nic->pending_count > 1000) {
|
|
||||||
+ LOG_WARN(PFX "%s: pending count excceded 1000",
|
|
||||||
+ nic->log_name);
|
|
||||||
+
|
|
||||||
+ pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
+ nic->pending_count = 0;
|
|
||||||
+ nic->flags &= ~NIC_ENABLED_PENDING;
|
|
||||||
+ pthread_mutex_unlock(&nic->nic_mutex);
|
|
||||||
+
|
|
||||||
+ rc = 0;
|
|
||||||
+ goto done;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (nic->flags & NIC_ENABLED_PENDING) {
|
|
||||||
+ struct timespec sleep_req, sleep_rem;
|
|
||||||
+
|
|
||||||
+ sleep_req.tv_sec = 0;
|
|
||||||
+ sleep_req.tv_nsec = 100000;
|
|
||||||
+ nanosleep(&sleep_req, &sleep_rem);
|
|
||||||
+
|
|
||||||
+ pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
+ nic->pending_count++;
|
|
||||||
+ pthread_mutex_unlock(&nic->nic_mutex);
|
|
||||||
+
|
|
||||||
+ LOG_INFO(PFX "%s: enabled pending",
|
|
||||||
+ nic->log_name);
|
|
||||||
+ rc = -EAGAIN;
|
|
||||||
+ goto done;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
prepare_nic(nic);
|
|
||||||
|
|
||||||
/* Sanity Check to ensure the transport names are the same */
|
|
||||||
@@ -210,7 +246,9 @@ static int parse_iface(void * arg)
|
|
||||||
goto enable_nic;
|
|
||||||
} else {
|
|
||||||
/* Disable the NIC */
|
|
||||||
- nic_disable(nic);
|
|
||||||
+ nic_disable(nic, 0);
|
|
||||||
+
|
|
||||||
+ persist_all_nic_iface(nic);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check to see if this is using DHCP or if this is
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/libs/bnx2.c b/brcm_iscsi_uio/src/unix/libs/bnx2.c
|
|
||||||
index 400fd43..2b103b1 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/libs/bnx2.c
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/libs/bnx2.c
|
|
||||||
@@ -788,20 +788,6 @@ static int bnx2_close(nic_t *nic, NIC_SHUTDOWN_T graceful)
|
|
||||||
|
|
||||||
bnx2_uio_close_resources(nic, graceful);
|
|
||||||
|
|
||||||
- /* Free any named strings we might be holding onto */
|
|
||||||
- if(nic->flags & NIC_CONFIG_NAME_MALLOC) {
|
|
||||||
- free(nic->config_device_name);
|
|
||||||
- nic->flags &= ~NIC_CONFIG_NAME_MALLOC;
|
|
||||||
- }
|
|
||||||
- nic->config_device_name = NULL;
|
|
||||||
-
|
|
||||||
- if(nic->flags & NIC_UIO_NAME_MALLOC) {
|
|
||||||
- free(nic->uio_device_name);
|
|
||||||
- nic->uio_device_name = NULL;
|
|
||||||
-
|
|
||||||
- nic->flags &= ~NIC_UIO_NAME_MALLOC;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/libs/bnx2x.c b/brcm_iscsi_uio/src/unix/libs/bnx2x.c
|
|
||||||
index a3f4fb2..ce71109 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/libs/bnx2x.c
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/libs/bnx2x.c
|
|
||||||
@@ -985,20 +985,6 @@ static int bnx2x_close(nic_t *nic, NIC_SHUTDOWN_T graceful)
|
|
||||||
|
|
||||||
bnx2x_uio_close_resources(nic, graceful);
|
|
||||||
|
|
||||||
- /* Free any named strings we might be holding onto */
|
|
||||||
- if(nic->flags & NIC_CONFIG_NAME_MALLOC) {
|
|
||||||
- free(nic->config_device_name);
|
|
||||||
- nic->flags &= ~NIC_CONFIG_NAME_MALLOC;
|
|
||||||
- }
|
|
||||||
- nic->config_device_name = NULL;
|
|
||||||
-
|
|
||||||
- if(nic->flags & NIC_UIO_NAME_MALLOC) {
|
|
||||||
- free(nic->uio_device_name);
|
|
||||||
- nic->uio_device_name = NULL;
|
|
||||||
-
|
|
||||||
- nic->flags &= ~NIC_UIO_NAME_MALLOC;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/nic.c b/brcm_iscsi_uio/src/unix/nic.c
|
|
||||||
index da83e2b..2b267f2 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/nic.c
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/nic.c
|
|
||||||
@@ -400,7 +400,7 @@ nic_t *nic_init()
|
|
||||||
return nic;
|
|
||||||
}
|
|
||||||
|
|
||||||
-int nic_remove(nic_t *nic, int locked)
|
|
||||||
+int nic_remove(nic_t *nic)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
nic_t *prev, *current;
|
|
||||||
@@ -422,9 +422,6 @@ int nic_remove(nic_t *nic, int locked)
|
|
||||||
|
|
||||||
nic->thread = INVALID_THREAD;
|
|
||||||
|
|
||||||
- if(!locked)
|
|
||||||
- pthread_mutex_lock(&nic_list_mutex);
|
|
||||||
-
|
|
||||||
current = prev = nic_list;
|
|
||||||
while(current != NULL) {
|
|
||||||
if(current == nic)
|
|
||||||
@@ -445,9 +442,6 @@ int nic_remove(nic_t *nic, int locked)
|
|
||||||
LOG_ERR(PFX "%s: Coudln't find nic", nic->log_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
- if(!locked)
|
|
||||||
- pthread_mutex_unlock(&nic_list_mutex);
|
|
||||||
-
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -459,16 +453,14 @@ int nic_remove(nic_t *nic, int locked)
|
|
||||||
* before proceeding to close()
|
|
||||||
* FORCE_SHUTDOWN will force the nic to close()
|
|
||||||
* reguardless of the state
|
|
||||||
+ * @param clean - this will free the proper strings assoicated
|
|
||||||
+ * with the NIC
|
|
||||||
*/
|
|
||||||
-void nic_close(nic_t *nic, NIC_SHUTDOWN_T graceful)
|
|
||||||
+void nic_close(nic_t *nic, NIC_SHUTDOWN_T graceful, int clean)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
nic_interface_t *nic_iface;
|
|
||||||
|
|
||||||
- if((nic->flags & NIC_DISABLED) &&
|
|
||||||
- (graceful == ALLOW_GRACEFUL_SHUTDOWN))
|
|
||||||
- return;
|
|
||||||
-
|
|
||||||
/* The NIC could be configured by the uIP config file
|
|
||||||
* but not assoicated with a hardware library just yet
|
|
||||||
* we will need to check for this */
|
|
||||||
@@ -491,10 +483,36 @@ void nic_close(nic_t *nic, NIC_SHUTDOWN_T graceful)
|
|
||||||
while(nic_iface != NULL)
|
|
||||||
{
|
|
||||||
nic_iface->state = NIC_IFACE_STOPPED;
|
|
||||||
- uip_reset(&nic_iface->ustack);
|
|
||||||
+ if (!((nic_iface->state & NIC_IFACE_PERSIST) ==
|
|
||||||
+ NIC_IFACE_PERSIST))
|
|
||||||
+ uip_reset(&nic_iface->ustack);
|
|
||||||
nic_iface = nic_iface->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* The NIC must be destroyed and init'ed once again,
|
|
||||||
+ * POSIX defines that the mutex will be undefined it
|
|
||||||
+ * init'ed twice without a destroy */
|
|
||||||
+ pthread_mutex_destroy(&nic->xmit_mutex);
|
|
||||||
+ pthread_mutex_init(&nic->xmit_mutex, NULL);
|
|
||||||
+
|
|
||||||
+ if (clean & FREE_CONFIG_NAME) {
|
|
||||||
+ /* Free any named strings we might be holding onto */
|
|
||||||
+ if(nic->flags & NIC_CONFIG_NAME_MALLOC) {
|
|
||||||
+ free(nic->config_device_name);
|
|
||||||
+ nic->flags &= ~NIC_CONFIG_NAME_MALLOC;
|
|
||||||
+ }
|
|
||||||
+ nic->config_device_name = NULL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (clean & FREE_UIO_NAME) {
|
|
||||||
+ if(nic->flags & NIC_UIO_NAME_MALLOC) {
|
|
||||||
+ free(nic->uio_device_name);
|
|
||||||
+ nic->uio_device_name = NULL;
|
|
||||||
+
|
|
||||||
+ nic->flags &= ~NIC_UIO_NAME_MALLOC;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ LOG_ERR(PFX "%s: nic closed", nic->log_name);
|
|
||||||
error:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@@ -1138,6 +1156,8 @@ void *nic_loop(void *arg)
|
|
||||||
pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
|
|
||||||
if (rc) {
|
|
||||||
+ LOG_ERR(PFX "%s: DHCP failed",
|
|
||||||
+ nic->log_name);
|
|
||||||
pthread_mutex_unlock(&nic->nic_mutex);
|
|
||||||
goto dev_close;
|
|
||||||
}
|
|
||||||
@@ -1164,6 +1184,9 @@ void *nic_loop(void *arg)
|
|
||||||
goto dev_close;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
+ unpersist_all_nic_iface(nic);
|
|
||||||
+
|
|
||||||
/* This is when we start the processing of packets */
|
|
||||||
nic->start_time = time(NULL);
|
|
||||||
nic->flags &= ~NIC_UNITIALIZED;
|
|
||||||
@@ -1171,8 +1194,9 @@ void *nic_loop(void *arg)
|
|
||||||
nic->state &= ~NIC_STOPPED;
|
|
||||||
nic->state |= NIC_RUNNING;
|
|
||||||
|
|
||||||
+ nic->flags &= ~NIC_ENABLED_PENDING;
|
|
||||||
+
|
|
||||||
/* Signal that the device enable is done */
|
|
||||||
- pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
pthread_cond_broadcast(&nic->enable_done_cond);
|
|
||||||
pthread_mutex_unlock(&nic->nic_mutex);
|
|
||||||
|
|
||||||
@@ -1197,17 +1221,11 @@ void *nic_loop(void *arg)
|
|
||||||
dev_close:
|
|
||||||
pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
|
|
||||||
- /* Ensure that the IP configuration is cleared */
|
|
||||||
- nic_iface = nic->nic_iface;
|
|
||||||
- while(nic_iface != NULL)
|
|
||||||
- {
|
|
||||||
- nic_iface->ustack.ip_config =
|
|
||||||
- (IPV4_CONFIG_OFF | IPV6_CONFIG_OFF);
|
|
||||||
- nic_iface = nic_iface->next;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
nic->state = NIC_STOPPED;
|
|
||||||
- nic_close(nic, 1);
|
|
||||||
+ nic_close(nic, 1, FREE_NO_STRINGS);
|
|
||||||
+
|
|
||||||
+ nic->flags |= NIC_UNITIALIZED;
|
|
||||||
+ nic->flags &= ~NIC_INITIALIZED;
|
|
||||||
|
|
||||||
/* Signal we are done closing CNIC/UIO device */
|
|
||||||
pthread_cond_broadcast(&nic->disable_wait_cond);
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/nic.h b/brcm_iscsi_uio/src/unix/nic.h
|
|
||||||
index 097230a..7636948 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/nic.h
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/nic.h
|
|
||||||
@@ -45,6 +45,11 @@ extern struct nic *nic_list;
|
|
||||||
#define MAX_PCI_DEVICE_ENTRIES 64 /* Maxium number of pci_device_id
|
|
||||||
entries a hw library may contain */
|
|
||||||
|
|
||||||
+#define FREE_CONFIG_NAME 0x0001
|
|
||||||
+#define FREE_UIO_NAME 0x0002
|
|
||||||
+#define FREE_ALL_STRINGS FREE_CONFIG_NAME | FREE_UIO_NAME
|
|
||||||
+#define FREE_NO_STRINGS 0x0000
|
|
||||||
+
|
|
||||||
/******************************************************************************
|
|
||||||
* Enumerations
|
|
||||||
******************************************************************************/
|
|
||||||
@@ -89,6 +94,7 @@ typedef struct nic_interface {
|
|
||||||
|
|
||||||
uint16_t protocol;
|
|
||||||
uint16_t flags;
|
|
||||||
+#define NIC_IFACE_PERSIST 0x0001
|
|
||||||
uint16_t state;
|
|
||||||
#define NIC_IFACE_STOPPED 0x0001
|
|
||||||
#define NIC_IFACE_RUNNING 0x0002
|
|
||||||
@@ -173,9 +179,12 @@ typedef struct nic {
|
|
||||||
#define NIC_VLAN_STRIP_ENABLED 0x0100
|
|
||||||
#define NIC_MSIX_ENABLED 0x0200
|
|
||||||
#define NIC_TX_HAS_SENT 0x0400
|
|
||||||
+#define NIC_ENABLED_PENDING 0x0800
|
|
||||||
|
|
||||||
#define NIC_UIO_NAME_MALLOC 0x1000
|
|
||||||
#define NIC_CONFIG_NAME_MALLOC 0x2000
|
|
||||||
+#define NIC_EXIT_MAIN_LOOP 0x4000
|
|
||||||
+#define NIC_GOING_DOWN 0x8000
|
|
||||||
|
|
||||||
uint16_t state;
|
|
||||||
#define NIC_STOPPED 0x0001
|
|
||||||
@@ -236,6 +245,9 @@ typedef struct nic {
|
|
||||||
time_t start_time;
|
|
||||||
struct nic_stats stats;
|
|
||||||
|
|
||||||
+ /* Number of retrys from iscsid*/
|
|
||||||
+ uint32_t pending_count;
|
|
||||||
+
|
|
||||||
#define DEFAULT_RX_POLL_USEC 100 /* usec */
|
|
||||||
/* options enabled by the user */
|
|
||||||
uint32_t rx_poll_usec;
|
|
||||||
@@ -271,7 +283,7 @@ typedef struct nic {
|
|
||||||
int load_all_nic_libraries();
|
|
||||||
|
|
||||||
nic_t *nic_init();
|
|
||||||
-int nic_remove(nic_t * nic, int locked);
|
|
||||||
+int nic_remove(nic_t * nic);
|
|
||||||
|
|
||||||
int nic_add_nic_iface(nic_t *nic,
|
|
||||||
nic_interface_t *nic_iface);
|
|
||||||
@@ -298,7 +310,7 @@ void put_packet_in_free_queue(struct packet *pkt,
|
|
||||||
nic_t *nic);
|
|
||||||
|
|
||||||
int unload_all_nic_libraries();
|
|
||||||
-void nic_close(nic_t *nic, NIC_SHUTDOWN_T graceful);
|
|
||||||
+void nic_close(nic_t *nic, NIC_SHUTDOWN_T graceful, int clean);
|
|
||||||
|
|
||||||
/* Use this function to fill in minor number and uio, and eth names */
|
|
||||||
int nic_fill_name(nic_t *nic);
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/nic_nl.c b/brcm_iscsi_uio/src/unix/nic_nl.c
|
|
||||||
index fa4033a..c624689 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/nic_nl.c
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/nic_nl.c
|
|
||||||
@@ -347,11 +347,51 @@ static int ctldev_handle()
|
|
||||||
nic_iface = nic_find_nic_iface_protocol(nic, path->vlan_id,
|
|
||||||
ip_type);
|
|
||||||
if (nic_iface == NULL) {
|
|
||||||
- LOG_WARN(PFX "%s: Couldn't find nic_iface "
|
|
||||||
- "vlan: %d ip_addr_len",
|
|
||||||
- nic->log_name,
|
|
||||||
- path->vlan_id, path->ip_addr_len);
|
|
||||||
- goto error;
|
|
||||||
+ nic_interface_t *default_iface;
|
|
||||||
+ default_iface = nic_find_nic_iface_protocol(nic,
|
|
||||||
+ 0,
|
|
||||||
+ ip_type);
|
|
||||||
+ if (default_iface == NULL)
|
|
||||||
+ {
|
|
||||||
+ LOG_ERR(PFX "%s: Couldn't find default iface "
|
|
||||||
+ "vlan: %d ip_type: %d "
|
|
||||||
+ "ip_addr_len: %d to clone",
|
|
||||||
+ nic->log_name, path->vlan_id, ip_type,
|
|
||||||
+ path->ip_addr_len);
|
|
||||||
+ goto error;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ nic_iface = nic_iface_init();
|
|
||||||
+ if (nic_iface == NULL)
|
|
||||||
+ {
|
|
||||||
+ LOG_ERR(PFX "%s: Couldn't allocate space for "
|
|
||||||
+ "vlan: %d ip_type: %d "
|
|
||||||
+ "ip_addr_len: %d",
|
|
||||||
+ nic->log_name, path->vlan_id, ip_type,
|
|
||||||
+ path->ip_addr_len);
|
|
||||||
+
|
|
||||||
+ goto error;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ nic_iface->protocol = ip_type;
|
|
||||||
+ nic_iface->vlan_id = path->vlan_id;
|
|
||||||
+ nic_add_nic_iface(nic, nic_iface);
|
|
||||||
+
|
|
||||||
+ /* TODO: When VLAN support is placed in the iface file
|
|
||||||
+ * revisit this code */
|
|
||||||
+ nic_iface->ustack.ip_config = default_iface->ustack.ip_config;
|
|
||||||
+ memcpy(&nic_iface->ustack.hostaddr,
|
|
||||||
+ &default_iface->ustack.hostaddr,
|
|
||||||
+ sizeof(nic_iface->ustack.hostaddr));
|
|
||||||
+ memcpy(&nic_iface->ustack.netmask,
|
|
||||||
+ &default_iface->ustack.netmask,
|
|
||||||
+ sizeof(nic_iface->ustack.netmask));
|
|
||||||
+ memcpy(&nic_iface->ustack.hostaddr6,
|
|
||||||
+ &default_iface->ustack.hostaddr6,
|
|
||||||
+ sizeof(nic_iface->ustack.hostaddr6));
|
|
||||||
+
|
|
||||||
+ nic_disable(nic, 0);
|
|
||||||
+ nic_enable(nic);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure that the NIC is RUNNING */
|
|
||||||
@@ -386,7 +426,11 @@ static int ctldev_handle()
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ISCSI_KEVENT_IF_DOWN:
|
|
||||||
- nic_remove(nic, 0);
|
|
||||||
+
|
|
||||||
+ pthread_mutex_lock(&nic_list_mutex);
|
|
||||||
+ nic_disable(nic, 1);
|
|
||||||
+ nic_remove(nic);
|
|
||||||
+ pthread_mutex_unlock(&nic_list_mutex);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/nic_utils.c b/brcm_iscsi_uio/src/unix/nic_utils.c
|
|
||||||
index 0e36a67..eabb474 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/nic_utils.c
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/nic_utils.c
|
|
||||||
@@ -787,6 +787,7 @@ int nic_enable(nic_t *nic)
|
|
||||||
|
|
||||||
nic->flags &= ~NIC_DISABLED;
|
|
||||||
nic->flags |= NIC_ENABLED;
|
|
||||||
+ nic->flags |= NIC_ENABLED_PENDING;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&nic->nic_mutex);
|
|
||||||
|
|
||||||
@@ -811,6 +812,8 @@ int nic_enable(nic_t *nic)
|
|
||||||
nic->log_name, strerror(rc));
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ nic->flags &= ~NIC_ENABLED_PENDING;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
@@ -826,11 +829,15 @@ int nic_enable(nic_t *nic)
|
|
||||||
* @param nic - NIC to disble
|
|
||||||
* @return 0 on success, <0 on failure
|
|
||||||
*/
|
|
||||||
-int nic_disable(nic_t *nic)
|
|
||||||
+int nic_disable(nic_t *nic, int going_down)
|
|
||||||
{
|
|
||||||
if( (nic->flags & NIC_ENABLED) &&
|
|
||||||
(nic->state & NIC_RUNNING))
|
|
||||||
{
|
|
||||||
+ struct timespec ts;
|
|
||||||
+ struct timeval tp;
|
|
||||||
+ int rc;
|
|
||||||
+
|
|
||||||
/* Wait for the device to be disabled */
|
|
||||||
pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
|
|
||||||
@@ -839,8 +846,23 @@ int nic_disable(nic_t *nic)
|
|
||||||
nic->state &= ~NIC_RUNNING;
|
|
||||||
nic->state |= NIC_STOPPED;
|
|
||||||
|
|
||||||
- pthread_cond_wait(&nic->disable_wait_cond,
|
|
||||||
- &nic->nic_mutex);
|
|
||||||
+ if (going_down) {
|
|
||||||
+ nic->flags |= NIC_GOING_DOWN;
|
|
||||||
+
|
|
||||||
+ if (nic->thread != INVALID_THREAD) {
|
|
||||||
+ pthread_cancel(nic->thread);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* Convert from timeval to timespec */
|
|
||||||
+ rc = gettimeofday(&tp, NULL);
|
|
||||||
+ ts.tv_sec = tp.tv_sec;
|
|
||||||
+ ts.tv_nsec = tp.tv_usec * 1000;
|
|
||||||
+ ts.tv_sec += 2; /* TODO: hardcoded wait for 2 seconds */
|
|
||||||
+
|
|
||||||
+ /* Wait for the device to be disabled */
|
|
||||||
+ rc = pthread_cond_timedwait(&nic->disable_wait_cond,
|
|
||||||
+ &nic->nic_mutex, &ts);
|
|
||||||
pthread_mutex_unlock(&nic->nic_mutex);
|
|
||||||
|
|
||||||
LOG_DEBUG(PFX "%s: device disabled", nic->log_name);
|
|
||||||
@@ -865,7 +887,7 @@ void nic_close_all()
|
|
||||||
nic = nic_list;
|
|
||||||
while (nic != NULL) {
|
|
||||||
pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
- nic_close(nic, 1);
|
|
||||||
+ nic_close(nic, 1, FREE_ALL_STRINGS);
|
|
||||||
pthread_mutex_unlock(&nic->nic_mutex);
|
|
||||||
|
|
||||||
nic = nic->next;
|
|
||||||
@@ -1224,6 +1246,46 @@ nic_interface_t * nic_find_nic_iface_protocol(nic_t *nic,
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * unpersist_all_nic_iface() - Mark all the NIC interfaces as non-persistant
|
|
||||||
+ * Note: nic->nic_mutex must be taken
|
|
||||||
+ * @param nic - NIC to mark as non-persistant
|
|
||||||
+ */
|
|
||||||
+void unpersist_all_nic_iface(nic_t *nic)
|
|
||||||
+{
|
|
||||||
+ nic_interface_t *current;
|
|
||||||
+
|
|
||||||
+ current = nic->nic_iface;
|
|
||||||
+ while (current != NULL)
|
|
||||||
+ {
|
|
||||||
+ current->flags &= ~NIC_IFACE_PERSIST;
|
|
||||||
+
|
|
||||||
+ current = current->next;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * persist_all_nic_iface() - Mark all the NIC interfaces as persistant
|
|
||||||
+ * Note: nic->nic_mutex must be taken
|
|
||||||
+ * @param nic - NIC to mark as persistant
|
|
||||||
+ */
|
|
||||||
+void persist_all_nic_iface(nic_t *nic)
|
|
||||||
+{
|
|
||||||
+ nic_interface_t *current;
|
|
||||||
+
|
|
||||||
+ pthread_mutex_lock(&nic->nic_mutex);
|
|
||||||
+
|
|
||||||
+ current = nic->nic_iface;
|
|
||||||
+ while (current != NULL)
|
|
||||||
+ {
|
|
||||||
+ current->flags |= NIC_IFACE_PERSIST;
|
|
||||||
+
|
|
||||||
+ current = current->next;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ pthread_mutex_unlock(&nic->nic_mutex);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/*******************************************************************************
|
|
||||||
* Packet management utility functions
|
|
||||||
******************************************************************************/
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/nic_utils.h b/brcm_iscsi_uio/src/unix/nic_utils.h
|
|
||||||
index 5034006..283e324 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/nic_utils.h
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/nic_utils.h
|
|
||||||
@@ -46,6 +46,10 @@ void nic_fill_ethernet_header(nic_interface_t *nic_iface,
|
|
||||||
|
|
||||||
nic_interface_t * nic_find_nic_iface(nic_t *nic,
|
|
||||||
uint16_t vlan_id);
|
|
||||||
+
|
|
||||||
+void unpersist_all_nic_iface(nic_t *nic);
|
|
||||||
+void persist_all_nic_iface(nic_t *nic);
|
|
||||||
+
|
|
||||||
int add_vlan_interfaces(nic_t *nic);
|
|
||||||
|
|
||||||
int nic_verify_uio_sysfs_name(nic_t *nic);
|
|
||||||
@@ -56,7 +60,7 @@ uint32_t calculate_default_netmask(uint32_t ip_addr);
|
|
||||||
void prepare_nic(nic_t *nic);
|
|
||||||
|
|
||||||
int nic_enable(nic_t *nic);
|
|
||||||
-int nic_disable(nic_t *nic);
|
|
||||||
+int nic_disable(nic_t *nic, int);
|
|
||||||
|
|
||||||
void dump_packet_to_log(struct nic_interface *iface,
|
|
||||||
uint8_t *buf, uint16_t buf_len);
|
|
||||||
diff --git a/brcm_iscsi_uio/src/unix/uevent.c b/brcm_iscsi_uio/src/unix/uevent.c
|
|
||||||
index 2019c64..4ff7e04 100644
|
|
||||||
--- a/brcm_iscsi_uio/src/unix/uevent.c
|
|
||||||
+++ b/brcm_iscsi_uio/src/unix/uevent.c
|
|
||||||
@@ -333,7 +333,7 @@ static int close_cnic_dev(struct parsed_uevent *event)
|
|
||||||
nic = nic_list;
|
|
||||||
while (nic != NULL) {
|
|
||||||
if (nic->uio_minor == minor) {
|
|
||||||
- nic_remove(nic, 1);
|
|
||||||
+ nic_remove(nic);
|
|
||||||
|
|
||||||
rc = 0;
|
|
||||||
break;
|
|
||||||
--
|
|
||||||
1.7.1
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
97
iscsi-initiator-utils-fixes.patch
Normal file
97
iscsi-initiator-utils-fixes.patch
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
diff -aurp open-iscsi-2.0-872-rc4-bnx2i/usr/io.c open-iscsi-2.0-872-rc4-bnx2i.fix/usr/io.c
|
||||||
|
--- open-iscsi-2.0-872-rc4-bnx2i/usr/io.c 2011-04-02 01:40:02.000000000 -0500
|
||||||
|
+++ open-iscsi-2.0-872-rc4-bnx2i.fix/usr/io.c 2011-04-02 05:23:15.000000000 -0500
|
||||||
|
@@ -296,6 +296,9 @@ static int bind_conn_to_iface(iscsi_conn
|
||||||
|
{
|
||||||
|
struct iscsi_session *session = conn->session;
|
||||||
|
|
||||||
|
+ if (strcmp(iface->transport_name, DEFAULT_TRANSPORT))
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
memset(session->netdev, 0, IFNAMSIZ);
|
||||||
|
if (iface_is_bound_by_hwaddr(iface) &&
|
||||||
|
net_get_netdev_from_hwaddress(iface->hwaddress, session->netdev)) {
|
||||||
|
@@ -467,7 +470,7 @@ iscsi_io_tcp_poll(iscsi_conn_t *conn, in
|
||||||
|
}
|
||||||
|
|
||||||
|
len = sizeof(ss);
|
||||||
|
- if (log_level > 0 || !conn->session->netdev)
|
||||||
|
+ if (log_level > 0 || !conn->session->netdev[0])
|
||||||
|
rc = getsockname(conn->socket_fd, (struct sockaddr *)&ss, &len);
|
||||||
|
if (log_level > 0 && rc >= 0) {
|
||||||
|
getnameinfo((struct sockaddr *) &conn->saddr,
|
||||||
|
diff -aurp open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_err.c open-iscsi-2.0-872-rc4-bnx2i.fix/usr/iscsi_err.c
|
||||||
|
--- open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_err.c 2011-04-02 01:40:02.000000000 -0500
|
||||||
|
+++ open-iscsi-2.0-872-rc4-bnx2i.fix/usr/iscsi_err.c 2011-04-02 05:22:51.000000000 -0500
|
||||||
|
@@ -44,7 +44,7 @@ static char *iscsi_err_msgs[] = {
|
||||||
|
/* 19 */ "encountered non-retryable iSCSI login failure",
|
||||||
|
/* 20 */ "could not connect to iscsid",
|
||||||
|
/* 21 */ "no objects found",
|
||||||
|
- /* 23 */ "sysfs lookup failure",
|
||||||
|
+ /* 22 */ "sysfs lookup failure",
|
||||||
|
/* 23 */ "host not found",
|
||||||
|
/* 24 */ "iSCSI login failed due to authorization failure",
|
||||||
|
/* 25 */ "iSNS query failed",
|
||||||
|
diff -aurp open-iscsi-2.0-872-rc4-bnx2i/usr/netlink.c open-iscsi-2.0-872-rc4-bnx2i.fix/usr/netlink.c
|
||||||
|
--- open-iscsi-2.0-872-rc4-bnx2i/usr/netlink.c 2011-04-02 01:40:02.000000000 -0500
|
||||||
|
+++ open-iscsi-2.0-872-rc4-bnx2i.fix/usr/netlink.c 2011-04-02 05:23:10.000000000 -0500
|
||||||
|
@@ -53,15 +53,15 @@ static struct iscsi_ipc_ev_clbk *ipc_ev_
|
||||||
|
|
||||||
|
static int ctldev_handle(void);
|
||||||
|
|
||||||
|
-#define NLM_BUF_DEFAULT_MAX \
|
||||||
|
- (NLMSG_SPACE(ISCSI_DEF_MAX_RECV_SEG_LEN + \
|
||||||
|
- sizeof(struct iscsi_hdr)))
|
||||||
|
+#define NLM_BUF_DEFAULT_MAX (NLMSG_SPACE(ISCSI_DEF_MAX_RECV_SEG_LEN + \
|
||||||
|
+ sizeof(struct iscsi_uevent) + \
|
||||||
|
+ sizeof(struct iscsi_hdr)))
|
||||||
|
+
|
||||||
|
+#define PDU_SENDBUF_DEFAULT_MAX (ISCSI_DEF_MAX_RECV_SEG_LEN + \
|
||||||
|
+ sizeof(struct iscsi_uevent) + \
|
||||||
|
+ sizeof(struct iscsi_hdr))
|
||||||
|
|
||||||
|
-#define PDU_SENDBUF_DEFAULT_MAX \
|
||||||
|
- (ISCSI_DEF_MAX_RECV_SEG_LEN + sizeof(struct iscsi_hdr))
|
||||||
|
-
|
||||||
|
-#define NLM_SETPARAM_DEFAULT_MAX \
|
||||||
|
- (NI_MAXHOST + 1 + sizeof(struct iscsi_uevent))
|
||||||
|
+#define NLM_SETPARAM_DEFAULT_MAX (NI_MAXHOST + 1 + sizeof(struct iscsi_uevent))
|
||||||
|
|
||||||
|
static int
|
||||||
|
kread(char *data, int count)
|
||||||
|
@@ -108,6 +108,12 @@ nlpayload_read(int ctrl_fd, char *data,
|
||||||
|
|
||||||
|
iov.iov_base = nlm_recvbuf;
|
||||||
|
iov.iov_len = NLMSG_SPACE(count);
|
||||||
|
+
|
||||||
|
+ if (iov.iov_len > NLM_BUF_DEFAULT_MAX) {
|
||||||
|
+ log_error("Cannot read %lu bytes. nlm_recvbuf too small.",
|
||||||
|
+ iov.iov_len);
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
memset(iov.iov_base, 0, iov.iov_len);
|
||||||
|
|
||||||
|
memset(&msg, 0, sizeof(msg));
|
||||||
|
@@ -517,6 +523,7 @@ ksend_pdu_begin(uint64_t transport_handl
|
||||||
|
int hdr_size, int data_size)
|
||||||
|
{
|
||||||
|
struct iscsi_uevent *ev;
|
||||||
|
+ int total_xmitlen = sizeof(*ev) + hdr_size + data_size;
|
||||||
|
|
||||||
|
log_debug(7, "in %s", __FUNCTION__);
|
||||||
|
|
||||||
|
@@ -525,8 +532,13 @@ ksend_pdu_begin(uint64_t transport_handl
|
||||||
|
exit(-EIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (total_xmitlen > PDU_SENDBUF_DEFAULT_MAX) {
|
||||||
|
+ log_error("BUG: Cannot send %d bytes.", total_xmitlen);
|
||||||
|
+ exit(-EINVAL);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
xmitbuf = pdu_sendbuf;
|
||||||
|
- memset(xmitbuf, 0, sizeof(*ev) + hdr_size + data_size);
|
||||||
|
+ memset(xmitbuf, 0, total_xmitlen);
|
||||||
|
xmitlen = sizeof(*ev);
|
||||||
|
ev = xmitbuf;
|
||||||
|
memset(ev, 0, sizeof(*ev));
|
@ -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_boot%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_boot"
|
|
||||||
+
|
|
||||||
+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
|
|
||||||
|
|
@ -1,23 +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, ...)
|
|
File diff suppressed because it is too large
Load Diff
@ -9,8 +9,8 @@ Source1: iscsid.init
|
|||||||
Source2: iscsidevs.init
|
Source2: iscsidevs.init
|
||||||
Source3: 04-iscsi
|
Source3: 04-iscsi
|
||||||
|
|
||||||
# sync brcm to 0.6.2.13
|
# sync brcm to 0.6.2.14
|
||||||
Patch0: iscsi-initiator-utils-sync-brcm-0.6.2.13.patch
|
Patch0: iscsi-initiator-utils-sync-brcm-0.6.2.14.patch
|
||||||
# sync iscsi tools to upstream commit 6a9fc9ff0f49eac37da86847268dda437609f1d4
|
# sync iscsi tools to upstream commit 6a9fc9ff0f49eac37da86847268dda437609f1d4
|
||||||
Patch1: iscsi-initiator-utils-sync-iscsi.patch
|
Patch1: iscsi-initiator-utils-sync-iscsi.patch
|
||||||
# Add Red Hat specific info to docs.
|
# Add Red Hat specific info to docs.
|
||||||
@ -39,6 +39,10 @@ Patch12: iscsi-initiator-utils-brcm-man.patch
|
|||||||
Patch13: iscsi-initiator-utils-dcb.patch
|
Patch13: iscsi-initiator-utils-dcb.patch
|
||||||
# libiscsi: nodes remember their interface
|
# libiscsi: nodes remember their interface
|
||||||
Patch14: iscsi-initiator-utils-libiscsi-nodes-remember-the-interface.patch
|
Patch14: iscsi-initiator-utils-libiscsi-nodes-remember-the-interface.patch
|
||||||
|
# Upstream commit from 9803f14e172c560b0120689cd91945f166c2f07e to
|
||||||
|
# fcd08dfbd02a279ffa69618a5216f6cf4f88e1da (will be rolled into rebase next
|
||||||
|
# release)
|
||||||
|
Patch15: iscsi-initiator-utils-fixes.patch
|
||||||
|
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
@ -66,7 +70,7 @@ developing applications that use %{name}.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n open-iscsi-2.0-872-rc4-bnx2i
|
%setup -q -n open-iscsi-2.0-872-rc4-bnx2i
|
||||||
%patch0 -p1 -b .sync-brcm-0.6.2.13
|
%patch0 -p1 -b .sync-brcm-0.6.2.14
|
||||||
%patch1 -p1 -b .sync-iscsi
|
%patch1 -p1 -b .sync-iscsi
|
||||||
%patch2 -p1 -b .update-initscripts-and-docs
|
%patch2 -p1 -b .update-initscripts-and-docs
|
||||||
%patch3 -p1 -b .use-var-for-config
|
%patch3 -p1 -b .use-var-for-config
|
||||||
@ -81,7 +85,7 @@ developing applications that use %{name}.
|
|||||||
%patch12 -p1 -b .brcm-man
|
%patch12 -p1 -b .brcm-man
|
||||||
%patch13 -p1 -b .dcb
|
%patch13 -p1 -b .dcb
|
||||||
%patch14 -p1 -b .libiscsi-remember-the-interface
|
%patch14 -p1 -b .libiscsi-remember-the-interface
|
||||||
|
%patch15 -p1 -b .fixes
|
||||||
|
|
||||||
%build
|
%build
|
||||||
cd utils/open-isns
|
cd utils/open-isns
|
||||||
@ -201,8 +205,11 @@ fi
|
|||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Thu Feb 24 2011 Mike Christie <mcrhsit@redhat.com> 6.2.0.872.18
|
* Thu Feb 24 2011 Mike Christie <mcrhsit@redhat.com> 6.2.0.872.18
|
||||||
- 677148 fix iscsiadm exit code when iscsid is not running and the
|
- fix iscsiadm exit code when iscsid is not running and the
|
||||||
discovery command is run.
|
discovery command is run.
|
||||||
|
- 689359 Fix uIP when using DCB for FCoE
|
||||||
|
- 691902 Fix iscsiadm SendTargets offload support when the PDU's data len
|
||||||
|
is 8K.
|
||||||
|
|
||||||
* Sat Feb 19 2011 Mike Christie <mcrhsit@redhat.com> 6.2.0.872.17
|
* Sat Feb 19 2011 Mike Christie <mcrhsit@redhat.com> 6.2.0.872.17
|
||||||
- 634021 Fix in .14 added regression during iscsi startup that prevented
|
- 634021 Fix in .14 added regression during iscsi startup that prevented
|
||||||
|
Loading…
Reference in New Issue
Block a user