Ejemplo n.º 1
0
        /// <summary>
        /// Send sqos request and receive sqos response
        /// </summary>
        /// <param name="request">The sqos request packet</param>
        /// <param name="response">The sqos response packet</param>
        /// <returns>Status of the sqos response</returns>
        public uint SendAndReceiveSqosPacket(SqosRequestPacket request, out SqosResponsePacket response)
        {
            transport.SendIoctlPayload(CtlCode_Values.FSCTL_STORAGE_QOS_CONTROL, request.ToBytes());
            uint smb2Status;

            byte[] payload;
            transport.ExpectIoctlPayload(out smb2Status, out payload);
            if (smb2Status != Smb2Status.STATUS_SUCCESS || payload == null)
            {
                response = null;
                return(smb2Status);
            }

            response = new SqosResponsePacket();
            STORAGE_QOS_CONTROL_Header responseHeader = TypeMarshal.ToStruct <STORAGE_QOS_CONTROL_Header>(payload);

            // Parse the header first to decode the ProtocolVersion field.
            if (responseHeader.ProtocolVersion == (ushort)SQOS_PROTOCOL_VERSION.Sqos10)
            {
                response.FromBytes(SqosResponseType.V10, payload);
            }
            else if (responseHeader.ProtocolVersion == (ushort)SQOS_PROTOCOL_VERSION.Sqos11)
            {
                response.FromBytes(SqosResponseType.V11, payload);
            }

            return(smb2Status);
        }
        private bool TestSqosVersion(string share, SQOS_PROTOCOL_VERSION version)
        {
            using (SqosClient client = new SqosClient(new TimeSpan(0, 0, defaultTimeoutInSeconds)))
            {
                client.ConnectToVHD(
                    SUTName, SUTIpAddress, Credential.DomainName, Credential.AccountName, Credential.Password, SecurityPackageType,
                    true, share, vhdName);
                SqosRequestPacket sqosRequest = new SqosRequestPacket(version == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                    (ushort)version,
                    SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_SET_LOGICAL_FLOW_ID | SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_GET_STATUS,
                    Guid.NewGuid(),
                    Guid.Empty,
                    Guid.Empty,
                    string.Empty,
                    string.Empty
                    );
                SqosResponsePacket sqosResponse;
                uint status = client.SendAndReceiveSqosPacket(
                    sqosRequest,
                    out sqosResponse);

                if (status != Smb2Status.STATUS_SUCCESS)
                    return false;

                return (ushort)version == sqosResponse.Header.ProtocolVersion;
            }
        }
        public void Sqos_InvalidOption()
        {
            ConnectToVHD();
            BaseTestSite.Log.Add(
                LogEntryKind.TestStep,
                "Client sends an SQOS request with an invalid option (0) and expects STATUS_INVALID_PARAMETER");
            SqosResponsePacket sqosResponse;
            SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                (ushort)TestConfig.SqosClientDialect,
                SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_NONE, // Invalid Option
                Guid.NewGuid(),
                TestConfig.SqosPolicyId,
                Guid.NewGuid(),
                TestConfig.SqosInitiatorName,
                TestConfig.SqosInitiatorNodeName);

            uint status = client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);

            if (TestConfig.Platform == Platform.WindowsServer2016 && status != Smb2Status.STATUS_INVALID_PARAMETER)
            {

            }
            else
            {
                BaseTestSite.Assert.AreEqual(
                    (uint)Smb2Status.STATUS_INVALID_PARAMETER,
                    status,
                    "3.2.5.1: If Request.Options does not include at least one of the flags defined in section 2.2.2.2, " +
                    "the server MUST fail the request with error STATUS_INVALID_PARAMETER.");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Send sqos request and receive sqos response
        /// </summary>
        /// <param name="request">The sqos request packet</param>
        /// <param name="response">The sqos response packet</param>
        /// <returns>Status of the sqos response</returns>
        public uint SendAndReceiveSqosPacket(SqosRequestPacket request, out SqosResponsePacket response)
        {
            transport.SendIoctlPayload(CtlCode_Values.FSCTL_STORAGE_QOS_CONTROL, request.ToBytes());
            uint smb2Status;
            byte[] payload;
            transport.ExpectIoctlPayload(out smb2Status, out payload);
            if (smb2Status != Smb2Status.STATUS_SUCCESS || payload == null)
            {
                response = null;
                return smb2Status;
            }

            response = new SqosResponsePacket();
            STORAGE_QOS_CONTROL_Header responseHeader = TypeMarshal.ToStruct<STORAGE_QOS_CONTROL_Header>(payload);

            // Parse the header first to decode the ProtocolVersion field.
            if (responseHeader.ProtocolVersion == (ushort)SQOS_PROTOCOL_VERSION.Sqos10)
            {
                response.FromBytes(SqosResponseType.V10, payload);
            }
            else if (responseHeader.ProtocolVersion == (ushort)SQOS_PROTOCOL_VERSION.Sqos11)
            {
                response.FromBytes(SqosResponseType.V11, payload);
            }

            return smb2Status;
        }
        public void Sqos_SetPolicyToNonAssociatedLogicalFlow()
        {
            ConnectToVHD();
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends an SQOS request to set policy, but the open is not associated to a logical flow");
            SqosResponsePacket sqosResponse;
            SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                (ushort)TestConfig.SqosClientDialect,
                SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_SET_POLICY,
                Guid.NewGuid(),
                TestConfig.SqosPolicyId,
                Guid.NewGuid(),
                TestConfig.SqosInitiatorName,
                TestConfig.SqosInitiatorNodeName);

            uint status = client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);
            BaseTestSite.Assert.AreEqual(
                Smb2Status.STATUS_NOT_FOUND,
                status,
                "3.2.5.1.2: If Request.Options includes the STORAGE_QOS_CONTROL_FLAG_SET_POLICY and the Open is not associated to a logical flow, " +
                "the server MUST fail the request with error STATUS_NOT_FOUND");
        }
        private void InvalidOffset(VariableType variableType, InvalidOffsetType offsetType)
        {
            ConnectToVHD();
            SqosResponsePacket sqosResponse;
            SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                (ushort)TestConfig.SqosClientDialect,
                SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_PROBE_POLICY,
                Guid.NewGuid(),
                TestConfig.SqosPolicyId,
                Guid.NewGuid(),
                TestConfig.SqosInitiatorName,
                TestConfig.SqosInitiatorNodeName);
            ushort invalidOffset = 0;
            int nameLength = variableType == VariableType.InitiatorName ? TestConfig.SqosInitiatorName.Length : TestConfig.SqosInitiatorNodeName.Length;
            int requestSize = sqosRequest.ToBytes().Length;
            if (offsetType == InvalidOffsetType.Large)
            {
                // Set the offset to make the sum of Length and offset be greater than RequestSize.
                invalidOffset = (ushort)(requestSize - nameLength + 1);
            }

            if (variableType == VariableType.InitiatorName)
            {
                sqosRequest.InitiatorNameOffset = invalidOffset;
            }
            else
            {
                sqosRequest.InitiatorNodeNameOffset = invalidOffset;
            }

            BaseTestSite.Log.Add(
                LogEntryKind.TestStep,
                "Client sends an SQOS request with {0}Offset set to {1} and expects STATUS_INVALID_PARAMETER",
                variableType,
                invalidOffset);
            uint status = client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);
            string failReason = offsetType == InvalidOffsetType.Small ?
                String.Format(
                    "if Request.{0}Length:{1} is greater than 0 and Request.{0}Offset:{2} is less than 104.", variableType, nameLength, invalidOffset) :
                String.Format(
                    "if (Request.{0}Length:{1} + Request.{0}Offset:{2}) is greater than RequestSize:{3}.", variableType, nameLength, invalidOffset, requestSize);

            BaseTestSite.Assert.AreEqual(
                (uint)Smb2Status.STATUS_INVALID_PARAMETER,
                status,
                "3.2.5.1.2: The server MUST fail the request with error STATUS_INVALID_PARAMETER " +
                failReason);
        }
        public void Sqos_InvalidRequestType()
        {
            ConnectToVHD();
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends an SQOS request to set policy, uses a version 1.0 request structure, but sets ProtocolVersion field to 1.1");
            SqosResponsePacket sqosResponse;
            SqosRequestPacket sqosRequest = new SqosRequestPacket(SqosRequestType.V10,
                (ushort)SQOS_PROTOCOL_VERSION.Sqos11,
                SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_SET_POLICY,
                Guid.NewGuid(),
                TestConfig.SqosPolicyId,
                Guid.NewGuid(),
                TestConfig.SqosInitiatorName,
                TestConfig.SqosInitiatorNodeName);

            uint status = client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);
            BaseTestSite.Assert.AreEqual(
                Smb2Status.STATUS_INVALID_PARAMETER,
                status,
                "The server should return STATUS_INVALID_PARAMETER");
        }
        public void Sqos_ReservationGreaterThanLimit()
        {
            ConnectToVHD();
            BaseTestSite.Log.Add(
                LogEntryKind.TestStep,
                "Client sends an SQOS request when Request.Reservation is greater than Request.Limit and expects STATUS_INVALID_PARAMETER");
            SqosResponsePacket sqosResponse;
            // Section 3.2.5.1.2
            // The server MUST fail the request with error STATUS_INVALID_PARAMETER if it determines that any of the following fields has an invalid value<4>:
            //	Request.Limit
            //	Request.Reservation

            SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                (ushort)TestConfig.SqosClientDialect,
                SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_PROBE_POLICY,
                Guid.NewGuid(),
                TestConfig.SqosPolicyId,
                Guid.NewGuid(),
                TestConfig.SqosInitiatorName,
                TestConfig.SqosInitiatorNodeName,
                // According to the footnote<4>, Windows Server vNext fails the request with STATUS_INVALID_PARAMETER
                // if Request.Limit is greater than 0 and Request.Reservation is greater than Request.Limit
                1,  // Set Request.Limit to be greater than 0
                2); // Set Request.Reservation is greater than Request.Limit

            uint status = client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);
            BaseTestSite.Assert.AreEqual(
                Smb2Status.STATUS_INVALID_PARAMETER,
                status,
                "Server should return STATUS_INVALID_PARAMETER when Request.Limit is greater than 0 and Request.Reservation is greater than Request.Limit");
        }
        public void Sqos_InvalidProtocolVersion()
        {
            ConnectToVHD();
            SqosResponsePacket sqosResponse;
            ushort invalidProtocolVersion = 0xFFFF;
            SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                invalidProtocolVersion,
                SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_SET_LOGICAL_FLOW_ID,
                Guid.NewGuid(),
                TestConfig.SqosPolicyId,
                Guid.NewGuid(),
                TestConfig.SqosInitiatorName,
                TestConfig.SqosInitiatorNodeName);

            BaseTestSite.Log.Add(
                LogEntryKind.TestStep,
                "Client sends an SQOS request with an invalid protocol version ({0}) and expects STATUS_REVISION_MISMATCH",
                invalidProtocolVersion);
            uint status = client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);
            BaseTestSite.Assert.AreEqual(
                (uint)NtStatus.STATUS_REVISION_MISMATCH,
                status,
                "3.2.5.1: If Request.ProtocolVersion does not equal 0x0100, the server MUST fail the request with error STATUS_REVISION_MISMATCH.");
        }
Ejemplo n.º 10
0
        private void UpdateCounters(
            Guid logicalFlowId,
            Guid initiatorId,
            ulong ioCountIncrement,
            ulong normalizedIoCountIncrement,
            ulong latencyIncrement,
            ulong lowerLatencyIncrement,
            ulong bandwidthLimit,
            ulong kilobyteCountIncrement)
        {
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends an SQOS request to update counters to a logical flow and expects success");
            SqosResponsePacket sqosResponse;

            SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                (ushort)TestConfig.SqosClientDialect,
                SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_UPDATE_COUNTERS,
                logicalFlowId,
                TestConfig.SqosPolicyId,
                initiatorId,
                TestConfig.SqosInitiatorName,
                TestConfig.SqosInitiatorNodeName,
                0,
                0,
                ioCountIncrement,
                normalizedIoCountIncrement,
                latencyIncrement,
                lowerLatencyIncrement,
                bandwidthLimit,
                kilobyteCountIncrement
                );
            uint status = client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);

            BaseTestSite.Assert.AreEqual(
                (uint)Smb2Status.STATUS_SUCCESS,
                status,
                "Update counters should succeed, actual status: {0}",
                Smb2Status.GetStatusCode(status));
        }
Ejemplo n.º 11
0
        private void SetOrProbePolicy(Guid logicalFlowId, Guid initiatorId, bool setPolicy)
        {
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends an SQOS request to {0} policy to a logical flow and expects success", setPolicy ? "set" : "probe");
            SqosResponsePacket sqosResponse;
            SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                (ushort)TestConfig.SqosClientDialect,
                setPolicy ? SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_SET_POLICY : SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_PROBE_POLICY,
                logicalFlowId,
                TestConfig.SqosPolicyId,
                initiatorId,
                TestConfig.SqosInitiatorName,
                TestConfig.SqosInitiatorNodeName);

            uint status = client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);
            BaseTestSite.Assert.AreEqual(
                (uint)Smb2Status.STATUS_SUCCESS,
                status,
                "{0} policy should succeed, actual status: {1}",
                setPolicy ? "SetPolicy": "ProbePolicy",
                Smb2Status.GetStatusCode(status));
        }
Ejemplo n.º 12
0
        private void GetStatus(Guid initiatorId, Guid logicalFlowId)
        {
            SqosResponsePacket sqosResponse = null;

            SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                (ushort)TestConfig.SqosClientDialect,
                SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_GET_STATUS,
                logicalFlowId,
                TestConfig.SqosPolicyId,
                initiatorId,
                TestConfig.SqosInitiatorName,
                TestConfig.SqosInitiatorNodeName);

            client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);

            BaseTestSite.Assert.IsNotNull(sqosResponse,
                "Server should return STORAGE_QOS_CONTROL_RESPONSE when Request.Options includes the STORAGE_QOS_CONTROL_GET_STATUS flag");

            if (sqosResponse.MaximumIoRate != TestConfig.SqosMaximumIoRate)
            {
                throw new Exception(String.Format("MaximumRate should be {0}, not {1}, retry querying logical flow status in case the server is not ready.",
                    TestConfig.SqosMaximumIoRate, sqosResponse.MaximumIoRate));
            }

            BaseTestSite.Log.Add(LogEntryKind.Debug, "ProtocolVersion in response is {0}", sqosResponse.Header.ProtocolVersion);
            BaseTestSite.Assert.AreEqual(SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_NONE, sqosResponse.Header.Options, "Options must be set to 0");
            BaseTestSite.Assert.AreEqual(logicalFlowId, sqosResponse.Header.LogicalFlowID, "LogicalFlowID MUST be set to {0}", logicalFlowId);
            BaseTestSite.Assert.AreEqual(TestConfig.SqosPolicyId, sqosResponse.Header.PolicyID, "PolicyID MUST be set to {0}", TestConfig.SqosPolicyId);
            BaseTestSite.Assert.AreEqual(initiatorId, sqosResponse.Header.InitiatorID, "InitiatorID MUST be set to {0}", initiatorId);
            BaseTestSite.Assert.AreNotEqual((uint)0, sqosResponse.TimeToLive, "TimeToLive MUST be set to a positive value");
            BaseTestSite.Assert.AreEqual(LogicalFlowStatus.StorageQoSStatusOk, sqosResponse.Status, "Status MUST be StorageQoSStatusOk");
            BaseTestSite.Assert.AreEqual(TestConfig.SqosMaximumIoRate, sqosResponse.MaximumIoRate, "MaximumRate MUST be {0}", TestConfig.SqosMaximumIoRate);
            BaseTestSite.Assert.AreEqual(TestConfig.SqosMinimumIoRate, sqosResponse.MinimumIoRate, "MinimumIoRate MUST be {0}", TestConfig.SqosMinimumIoRate);
            BaseTestSite.Assert.AreEqual(TestConfig.SqosBaseIoSize, sqosResponse.BaseIoSize, "BaseIoSize MUST be {0}", TestConfig.SqosBaseIoSize);

            if (sqosResponse.Header.ProtocolVersion == (ushort)SQOS_PROTOCOL_VERSION.Sqos11)
            {
                BaseTestSite.Assert.AreEqual(TestConfig.SqosMaximumBandwidth, sqosResponse.MaximumBandwidth, "MaximumBandwidth MUST be {0}", TestConfig.SqosMaximumBandwidth);
            }
        }
Ejemplo n.º 13
0
        private void AssociateOpenToLogicalFlow(Guid logicalFlowId)
        {
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends an SQOS request to associate the Open to a logical flow and expects success");
            SqosResponsePacket sqosResponse;

            SqosRequestPacket sqosRequest = new SqosRequestPacket(TestConfig.SqosClientDialect == SQOS_PROTOCOL_VERSION.Sqos10 ? SqosRequestType.V10 : SqosRequestType.V11,
                (ushort)TestConfig.SqosClientDialect,
                SqosOptions_Values.STORAGE_QOS_CONTROL_FLAG_SET_LOGICAL_FLOW_ID,
                logicalFlowId,
                Guid.Empty,
                Guid.Empty,
                string.Empty,
                string.Empty
                );
            client.SendAndReceiveSqosPacket(
                sqosRequest,
                out sqosResponse);
        }