Jelajahi Sumber

iSCSI Console v1.2.9

Tal Aloni 8 tahun lalu
induk
melakukan
9d6327a09d

+ 2 - 2
ISCSI/Properties/AssemblyInfo.cs

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
 //
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
-[assembly: AssemblyVersion("1.2.8.0")]
-[assembly: AssemblyFileVersion("1.2.8.0")]
+[assembly: AssemblyVersion("1.2.9.0")]
+[assembly: AssemblyFileVersion("1.2.9.0")]

+ 2 - 0
ISCSI/RevisionHistory.txt

@@ -60,3 +60,5 @@ Revision History:
 1.2.7 - The iSCSI Client did not report the correct disk capacity.
 
 1.2.8 - Reject improper commands during the login phase.
+
+1.2.9 - Reject improper commands before login is complete.

+ 18 - 10
ISCSI/Server/ISCSIServer.cs

@@ -177,9 +177,12 @@ namespace ISCSI.Server
                     int connectionIndex = GetStateObjectIndex(m_activeConnections, state.SessionParameters.ISID, state.SessionParameters.TSIH, state.ConnectionParameters.CID);
                     if (connectionIndex >= 0)
                     {
-                        lock (m_activeConnections[connectionIndex].Target.IOLock)
+                        if (m_activeConnections[connectionIndex].Target != null)
                         {
-                            // Wait for pending I/O to complete.
+                            lock (m_activeConnections[connectionIndex].Target.IOLock)
+                            {
+                                // Wait for pending I/O to complete.
+                            }
                         }
                         m_activeConnections.RemoveAt(connectionIndex);
                     }
@@ -341,9 +344,12 @@ namespace ISCSI.Server
                             // Perform implicit logout
                             Log("[{0}][ProcessPDU] Initiating implicit logout", state.ConnectionIdentifier);
                             SocketUtils.ReleaseSocket(m_activeConnections[existingConnectionIndex].ClientSocket);
-                            lock (m_activeConnections[existingConnectionIndex].Target.IOLock)
+                            if (m_activeConnections[existingConnectionIndex].Target != null)
                             {
-                                // Wait for pending I/O to complete.
+                                lock (m_activeConnections[existingConnectionIndex].Target.IOLock)
+                                {
+                                    // Wait for pending I/O to complete.
+                                }
                             }
                             m_activeConnections.RemoveAt(existingConnectionIndex);
                             Log("[{0}][ProcessPDU] Implicit logout completed", state.ConnectionIdentifier);
@@ -351,12 +357,11 @@ namespace ISCSI.Server
                     }
                 }
                 LoginResponsePDU response = ServerResponseHelper.GetLoginResponsePDU(request, m_targets, state.SessionParameters, state.ConnectionParameters, ref state.Target, GetNextTSIH);
-                if (state.Target != null)
+                if (state.SessionParameters.IsFullFeaturePhase)
                 {
                     state.SessionParameters.ISID = request.ISID;
                     state.ConnectionParameters.CID = request.CID;
-
-                    if (response.NextStage == 3)
+                    lock (m_activeConnectionsLock)
                     {
                         m_activeConnections.Add(state);
                     }
@@ -364,7 +369,7 @@ namespace ISCSI.Server
                 Log("[{0}][ReceiveCallback] Login Response parameters: {1}", state.ConnectionIdentifier, KeyValuePairUtils.ToString(response.LoginParameters));
                 TrySendPDU(state, response);
             }
-            else if (!state.SessionParameters.IsDiscovery && state.Target == null)
+            else if (!state.SessionParameters.IsFullFeaturePhase)
             {
                 // Before the Full Feature Phase is established, only Login Request and Login Response PDUs are allowed.
                 Log("[{0}][ProcessPDU] Improper command during login phase, OpCode: 0x{1}", state.ConnectionIdentifier, pdu.OpCode.ToString("x"));
@@ -389,9 +394,12 @@ namespace ISCSI.Server
                         int connectionIndex = GetStateObjectIndex(m_activeConnections, state.SessionParameters.ISID, state.SessionParameters.TSIH, state.ConnectionParameters.CID);
                         if (connectionIndex >= 0)
                         {
-                            lock (m_activeConnections[connectionIndex].Target.IOLock)
+                            if (m_activeConnections[connectionIndex].Target != null)
                             {
-                                // Wait for pending I/O to complete.
+                                lock (m_activeConnections[connectionIndex].Target.IOLock)
+                                {
+                                    // Wait for pending I/O to complete.
+                                }
                             }
                             m_activeConnections.RemoveAt(connectionIndex);
                         }

+ 19 - 5
ISCSI/Server/ServerResponseHelper.cs

@@ -113,10 +113,17 @@ namespace ISCSI.Server
             if (request.CurrentStage == 0)
             {
                 response.LoginParameters.Add("AuthMethod", "None");
-                
-                if (request.Transit && request.NextStage != 1 && request.NextStage != 3)
+
+                if (request.Transit)
                 {
-                    response.Status = LoginResponseStatusName.InitiatorError;
+                    if (request.NextStage == 3)
+                    {
+                        session.IsFullFeaturePhase = true;
+                    }
+                    else if (request.NextStage != 1)
+                    {
+                        response.Status = LoginResponseStatusName.InitiatorError;
+                    }
                 }
             }
             else if (request.CurrentStage == 1)
@@ -124,9 +131,16 @@ namespace ISCSI.Server
                 UpdateOperationalParameters(request.LoginParameters, session, connection);
                 response.LoginParameters = GetLoginOperationalParameters(session, connection);
 
-                if (request.Transit && request.NextStage != 3)
+                if (request.Transit)
                 {
-                    response.Status = LoginResponseStatusName.InitiatorError;
+                    if (request.NextStage == 3)
+                    {
+                        session.IsFullFeaturePhase = true;
+                    }
+                    else
+                    {
+                        response.Status = LoginResponseStatusName.InitiatorError;
+                    }
                 }
             }
             else

+ 1 - 0
ISCSI/Server/SessionParameters.cs

@@ -79,6 +79,7 @@ namespace ISCSI.Server
         public ulong ISID; // Initiator Session ID
         public ushort TSIH; // Target Session Identifying Handle
         public bool IsDiscovery; // Indicate whether this is a discovery session
+        public bool IsFullFeaturePhase; // Indicate whether login has been completed
         public bool CommandNumberingStarted;
         public uint ExpCmdSN;
 

+ 2 - 2
ISCSIConsole/Properties/AssemblyInfo.cs

@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
 //      Build Number
 //      Revision
 //
-[assembly: AssemblyVersion("1.2.8.0")]
-[assembly: AssemblyFileVersion("1.2.8.0")]
+[assembly: AssemblyVersion("1.2.9.0")]
+[assembly: AssemblyFileVersion("1.2.9.0")]

+ 2 - 0
ISCSIConsole/RevisionHistory.txt

@@ -59,3 +59,5 @@ Revision History:
 1.2.7 - Updates to the ISCSI library.
 
 1.2.8 - Updates to the ISCSI library.
+
+1.2.9 - Updates to the ISCSI library.