Sync with the latest IET (r207-211):
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 26 Mar 2009 18:38:05 +0000 (18:38 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 26 Mar 2009 18:38:05 +0000 (18:38 +0000)
 - Fix CHAP account handling bugs
 - Fix bugs in multi PDU handling code

git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@722 d57e44dd-8a1f-0410-8b47-8ef2f437770f

iscsi-scst/include/iscsi_scst_ver.h
iscsi-scst/usr/config.c
iscsi-scst/usr/iscsid.c
iscsi-scst/usr/misc.h

index 30f0b68..b4c7be7 100644 (file)
@@ -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"
index 813881f..c8bdc54 100644 (file)
@@ -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);
index 08f423b..167e3b8 100644 (file)
@@ -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) {
index 5061f1c..16b2ced 100644 (file)
@@ -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)