Re: Protocol Errors for PDUs with CmdSN outside the range for Non Immediate commands

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

 



On Tuesday 19 November 2013 12:24 AM, Nicholas A. Bellinger wrote:
Hi Santosh,

On Fri, 2013-11-15 at 17:05 +0530, santosh kulkarni wrote:
Hi,

Is the following an expected behavior for LIO.

For iSCSI PDUs with CmdSN say greater(outside the range basically from
ExpCmdSN to MaxCmdSN) than MaxCmdsn,LIO is straight away rejecting it as
protocol error and not accepting further write commands.

~# dmesg
[1393323.895597] Received CmdSN: 0x00000155 is greater than MaxCmdSN:
0x00000092, protocol error.
[1393783.532961] Received CmdSN: 0x00000155 is greater than MaxCmdSN:
0x00000092, protocol error.

But as per RFC the expected behavior is to silently ignore.

Stating clause 3.2.2.1

3.2.2.1.  Command Numbering and Acknowledging


"For non-immediate commands, the CmdSN field can take any
     value from ExpCmdSN to MaxCmdSN inclusive.  The target MUST silently
     ignore any non-immediate command outside of this range or non-
     immediate duplicates within the range"


LIO must ignore such PDUs and handle subsequent PDUs.

I could have sworn that non-immediate CmdSNs that exceeded MaxCmdSN
should be considered a protocol error,
yes,makes sense to reject such PDUs.
but the wording in 3.2.2.1
clearly states they must be silently ignored..

To that effect, here is the patch that I'm applying for v3.13 code.

Thanks!

--nab

diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h
index f2094d2..8dcb3c1 100644
--- a/drivers/target/iscsi/iscsi_target_core.h
+++ b/drivers/target/iscsi/iscsi_target_core.h
@@ -193,6 +193,7 @@ enum recover_cmdsn_ret_table {
         CMDSN_NORMAL_OPERATION          = 0,
         CMDSN_LOWER_THAN_EXP            = 1,
         CMDSN_HIGHER_THAN_EXP           = 2,
+       CMDSN_MAXCMDSN_OVERRUN          = 3,
  };
/* Used for iscsi_handle_immediate_data() return values */
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index 45b8fd1..9064926 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -242,9 +242,9 @@ static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cm
          */
         if (iscsi_sna_gt(cmdsn, sess->max_cmd_sn)) {
                 pr_err("Received CmdSN: 0x%08x is greater than"
-                      " MaxCmdSN: 0x%08x, protocol error.\n", cmdsn,
+                      " MaxCmdSN: 0x%08x, ignoring.\n", cmdsn,
                        sess->max_cmd_sn);
-               ret = CMDSN_ERROR_CANNOT_RECOVER;
+               ret = CMDSN_MAXCMDSN_OVERRUN;
} else if (cmdsn == sess->exp_cmd_sn) {
                 sess->exp_cmd_sn++;
@@ -303,14 +303,16 @@ int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
                 ret = CMDSN_HIGHER_THAN_EXP;
                 break;
         case CMDSN_LOWER_THAN_EXP:
+       case CMDSN_MAXCMDSN_OVERRUN:
+       default:
                 cmd->i_state = ISTATE_REMOVE;
                 iscsit_add_cmd_to_immediate_queue(cmd, conn, cmd->i_state);
-               ret = cmdsn_ret;
-               break;
-       default:
-               reason = ISCSI_REASON_PROTOCOL_ERROR;
-               reject = true;
-               ret = cmdsn_ret;
+               /*
+                * Existing callers for iscsit_sequence_cmd() will silently
+                * ignore commands with CMDSN_LOWER_THAN_EXP, so force this
+                * return for CMDSN_MAXCMDSN_OVERRUN as well..
+                */
+               ret = CMDSN_LOWER_THAN_EXP;
                 break;
         }
         mutex_unlock(&conn->sess->cmdsn_mutex);




Regards
Santosh
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux