From 4c8237b73ba4f8b0bef7da477d711391cd59267f Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 26 Mar 2009 18:38:05 +0000 Subject: [PATCH] Sync with the latest IET (r207-211): - Fix CHAP account handling bugs - Fix bugs in multi PDU handling code git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@722 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/include/iscsi_scst_ver.h | 2 +- iscsi-scst/usr/config.c | 21 ++++++++++++--------- iscsi-scst/usr/iscsid.c | 8 +++++--- iscsi-scst/usr/misc.h | 5 +++++ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/iscsi-scst/include/iscsi_scst_ver.h b/iscsi-scst/include/iscsi_scst_ver.h index 30f0b68b2..b4c7be71e 100644 --- a/iscsi-scst/include/iscsi_scst_ver.h +++ b/iscsi-scst/include/iscsi_scst_ver.h @@ -13,4 +13,4 @@ * GNU General Public License for more details. */ -#define ISCSI_VERSION_STRING "1.0.1/0.4.17r206" +#define ISCSI_VERSION_STRING "1.0.1/0.4.17r211" diff --git a/iscsi-scst/usr/config.c b/iscsi-scst/usr/config.c index 813881f64..c8bdc547a 100644 --- a/iscsi-scst/usr/config.c +++ b/iscsi-scst/usr/config.c @@ -179,6 +179,8 @@ int config_account_list(u32 tid, int dir, u32 *cnt, u32 *overflow, return -ENOENT; list_for_each_entry(user, list, ulist) { + if (user->tid != tid) + continue; if (buf_sz >= ISCSI_NAME_LEN) { strncpy(buf, user->name, ISCSI_NAME_LEN); buf_sz -= ISCSI_NAME_LEN; @@ -255,15 +257,16 @@ int config_account_add(u32 tid, int dir, char *name, char *pass) user->tid = tid; list = account_list_get(tid, dir); - - if (dir == AUTH_DIR_OUTGOING && !list_empty(list)) { - struct user *old; - log_warning("Only one outgoing %s account is supported." - " Replacing the old one.\n", - tid ? "target" : "discovery"); - - old = list_entry(list->q_forw, struct user, ulist); - account_destroy(old); + if (dir == AUTH_DIR_OUTGOING) { + struct user *old, *tmp; + list_for_each_entry_safe(old, tmp, list, ulist) { + if (tid != old->tid) + continue; + log_warning("Only one outgoing %s account is supported." + " Replacing the old one.\n", + tid ? "target" : "discovery"); + account_destroy(old); + } } insque(user, list); diff --git a/iscsi-scst/usr/iscsid.c b/iscsi-scst/usr/iscsid.c index 08f423b61..167e3b880 100644 --- a/iscsi-scst/usr/iscsid.c +++ b/iscsi-scst/usr/iscsid.c @@ -569,9 +569,10 @@ static void cmnd_reject(struct connection *conn, u8 reason) struct iscsi_reject_hdr *rej = (struct iscsi_reject_hdr *)&conn->rsp.bhs; size_t data_sz = sizeof(struct iscsi_hdr); - struct buf_segment *seg = conn_alloc_buf_segment(conn, data_sz); + struct buf_segment *seg; conn_free_rsp_buf_list(conn); + seg = conn_alloc_buf_segment(conn, data_sz); memset(rej, 0x0, sizeof *rej); rej->opcode = ISCSI_OP_REJECT_MSG; @@ -590,7 +591,6 @@ static void cmnd_reject(struct connection *conn, u8 reason) memcpy(seg->data, &conn->req.bhs, data_sz); seg->len = data_sz; - list_add_tail(&seg->entry, &conn->rsp_buf_list); } static int cmnd_exec_auth(struct connection *conn) @@ -969,7 +969,7 @@ int cmnd_execute(struct connection *conn) if (!list_empty(&conn->rsp_buf_list)) { seg = list_entry(conn->rsp_buf_list.q_forw, struct buf_segment, entry); - list_del(&seg->entry); + list_del_init(&seg->entry); conn->rsp.datasize = seg->len; conn->rsp.data = seg->data; } else { @@ -993,7 +993,9 @@ void cmnd_finish(struct connection *conn) if (conn->rsp.data) { seg = container_of(conn->rsp.data, struct buf_segment, data); + list_del(&seg->entry); free(seg); + conn->rsp.data = NULL; } switch (conn->state) { diff --git a/iscsi-scst/usr/misc.h b/iscsi-scst/usr/misc.h index 5061f1cb2..16b2ced8b 100644 --- a/iscsi-scst/usr/misc.h +++ b/iscsi-scst/usr/misc.h @@ -68,6 +68,11 @@ static inline int list_length_is_one(const struct __qelem *head) #define list_del(elem) remque(elem) +#define list_del_init(elem) do { \ + remque(elem); \ + INIT_LIST_HEAD(elem); \ + } while (0) + #define list_add(new, head) insque (new, head) #define list_add_tail(new, head) insque(new, (head)->q_back)