Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/iscsi/dist/src/lib Skip target if TargetName is...



details:   https://anonhg.NetBSD.org/src/rev/46fcf237c06e
branches:  trunk
changeset: 762520:46fcf237c06e
user:      sborrill <sborrill%NetBSD.org@localhost>
date:      Tue Feb 22 13:10:55 2011 +0000

description:
Skip target if TargetName is empty.
Use relevant TargetAddress, not just first one we happen to find.

Following improvement based on feedback from Daisuke Aoyama (author of istgt):
Handle NOP-OUT CmdSN and immediate bit.
Handle NOP-IN TransferTag=0xffffffff.
Interim solution for dealing with Underflow bit in iSCSI response.

iscsi-initiator now talks to istgt and other targets.

Remaining issues:
CHAP support will not work with most targets (maximum 16 octet challenge is
used, but other initiators use up to 1024). However, CHAP can now be
bypassed by not specifying a username.

diffstat:

 external/bsd/iscsi/dist/src/lib/initiator.c |  38 +++++++++++++++++++++++-----
 external/bsd/iscsi/dist/src/lib/protocol.c  |   2 +-
 2 files changed, 32 insertions(+), 8 deletions(-)

diffs (95 lines):

diff -r f83182c246e5 -r 46fcf237c06e external/bsd/iscsi/dist/src/lib/initiator.c
--- a/external/bsd/iscsi/dist/src/lib/initiator.c       Tue Feb 22 13:05:07 2011 +0000
+++ b/external/bsd/iscsi/dist/src/lib/initiator.c       Tue Feb 22 13:10:55 2011 +0000
@@ -630,6 +630,7 @@
         iscsi_parameter_t      *ip;
         char                   *text = NULL;
         int                     text_len = 0;
+        int                     pos = 0;
 
         if ((text = iscsi_malloc_atomic(DISCOVERY_PHASE_TEXT_LEN)) == NULL) {
                 iscsi_err(__FILE__, __LINE__, "iscsi_malloc_atomic() failed\n");
@@ -651,13 +652,23 @@
         }       
         for (ip = sess->params ; ip ; ip = ip->next) {
                 if (strcmp(ip->key, "TargetName") == 0) {
-                        for (vp = ip->value_l ; vp ; vp = vp->next) {
+                       pos = 0;
+                        for (vp = ip->value_l ; vp ; vp = vp->next, pos++) {
+                               /*
+                                * Skip items which have no name,
+                                * these have been blocked by the target
+                                */
+                               if (!strlen(vp->value))
+                                       continue;
+                               
                                 ALLOC(char *, svp->v, svp->size, svp->c, 10,
                                                10, "igt", return -1);
                                 svp->v[svp->c++] = strdup(vp->value);
                                 ALLOC(char *, svp->v, svp->size, svp->c, 10,
                                                10, "igt2", return -1);
-                                svp->v[svp->c++] = strdup(param_val(sess->params, "TargetAddress"));
+                                svp->v[svp->c++] =
+                                     strdup(param_val_which(sess->params,
+                                     "TargetAddress", pos));
                         }
                 }
         }
@@ -2466,7 +2477,8 @@
        /* Encapsulate and send NOP */
 
        nop_out->ExpStatSN = sess->ExpStatSN;
-       /* nop_out->CmdSN = sess->CmdSN++; */
+       nop_out->immediate = 1;
+       nop_out->CmdSN = sess->CmdSN;
        nop_out->transfer_tag = 0xffffffff;
        if (iscsi_nop_out_encap(header, nop_out) != 0) {
                iscsi_err(__FILE__, __LINE__, "iscsi_nop_out_encap() failed\n");
@@ -2901,6 +2913,16 @@
                iscsi_err(__FILE__, __LINE__, "iscsi_nop_in() failed\n");
                return -1;
        }
+       if (nop_in.transfer_tag == 0xffffffff) {
+               if (nop_in.length != 0) {
+                       iscsi_err(__FILE__, __LINE__,
+                               "nop_in.length %u not 0\n",
+                               nop_in.length);
+                       NO_CLEANUP;
+                       return -1;
+               }
+               return 0;
+       }
        if (cmd) {
 #if 0
                RETURN_NOT_EQUAL("nop_in.length", nop_in.length, nop_out->length, NO_CLEANUP, -1);
@@ -3400,12 +3422,14 @@
        errmsg = NULL;
        if (data.overflow != 0) {
                errmsg = "Overflow bit";
-       } else if (data.underflow != 0) {
-               errmsg = "Underflow bit";
        } else if (data.task_tag != scsi_cmd->tag) {
                errmsg = "Tag";
-       } else if (data.task_tag != scsi_cmd->tag) {
-               errmsg = "Residual Count";
+       } else if (!data.underflow) {
+               if (data.res_count != 0) {
+                       errmsg = "Residual Count";
+               }
+       } else {
+               iscsi_warn(__FILE__, __LINE__, "Underflow %s\n", data.res_count);
        }
        if (errmsg) {
                iscsi_err(__FILE__, __LINE__, errmsg);
diff -r f83182c246e5 -r 46fcf237c06e external/bsd/iscsi/dist/src/lib/protocol.c
--- a/external/bsd/iscsi/dist/src/lib/protocol.c        Tue Feb 22 13:05:07 2011 +0000
+++ b/external/bsd/iscsi/dist/src/lib/protocol.c        Tue Feb 22 13:10:55 2011 +0000
@@ -1457,7 +1457,7 @@
                errmsg = "Byte 4";
        } else if (memcmp(header + 8, zeros, 8) != 0) {
                errmsg = "Bytes 8-15";
-       } else if (memcmp(header + 44, zeros, 4) != 0) {
+       } else if (!cmd->underflow && memcmp(header + 44, zeros, 4) != 0) {
                errmsg = "Bytes 44-47";
        }
        if (errmsg) {



Home | Main Index | Thread Index | Old Index