public void SmbdCreditMgmt_NegativeParameter_CreditRequested() { // define data for test case const ushort RECEIVE_CREDIT_MAX = 10; const ushort SEND_CREDIT_TARGET = 10; BaseTestSite.Log.Add(LogEntryKind.TestStep, "Connect to server over RDMA"); NtStatus status = smbdAdapter.ConnectToServerOverRDMA(); BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status); BaseTestSite.Log.Add(LogEntryKind.TestStep, "SMBD Negotiate"); SmbdNegotiateResponse response; status = smbdAdapter.SmbdNegotiate( SEND_CREDIT_TARGET, RECEIVE_CREDIT_MAX, out response); BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD negotiate is {0}", status); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Send SMBD Data Transfer Message request with 0 credit."); status = smbdAdapter.SmbdSendDataTransferMessage( 0, 0, SmbdDataTransfer_Flags.NONE, 0, 0, 0, new byte[0]); BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of send SMBD Data Transfer message is {0}", status); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Verify server connection will be terminated."); smbdAdapter.WaitRdmaDisconnect(); BaseTestSite.Assert.IsFalse(smbdAdapter.ClientConnection.Endpoint.IsConnected, "Connection should be terminated"); }
public void Smb2OverRdmaChannel_InvalidBufferDescriptor_Offset() { InitSmbdConnectionForTestCases(smbdAdapter.TestConfig.TestFileName_LargeFile); // SMB2 Read file BaseTestSite.Log.Add(LogEntryKind.TestStep, "Register memory and get buffer descriptor for SMB2 READ."); SmbdBufferDescriptorV1 descp; uint bufferSize = smbdAdapter.Smb2MaxReadSize; smbdAdapter.SmbdRegisterBuffer( bufferSize, SmbdBufferReadWrite.RDMA_WRITE_PERMISSION_FOR_READ_FILE, out descp); // modify offset to overrun buffer size which is invalid descp.Offset = bufferSize + 1; byte[] channelInfo = TypeMarshal.ToBytes <SmbdBufferDescriptorV1>(descp); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Read content from file over RDMA."); READ_Response readResponse; byte[] readData; try { NtStatus status = (NtStatus)smbdAdapter.Smb2ReadOverRdmaChannel( 0, smbdAdapter.Smb2MaxReadSize, channelInfo, out readResponse, out readData ); BaseTestSite.Assert.AreNotEqual <NtStatus>( NtStatus.STATUS_SUCCESS, status, "Status of SMB2 Read File is {0}", status); } catch (TimeoutException) { BaseTestSite.Assert.Pass("No SMB2 READ response received"); } BaseTestSite.Log.Add(LogEntryKind.TestStep, "Disconnect and reconnect to verify server is available."); smbdAdapter.DisconnectRdma(); smbdAdapter.ConnectToServerOverRDMA(); }
public void SmbdNegotiate_Redundancy() { const ushort CREDIT_REQUESTED = 10; const uint MAX_SEND_SIZE = 1024; const uint MAX_RECEIVE_SIZE = 1024; const uint MAX_FRAGMENT_SIZE = 131072; const int NEGOTIATE_SIZE = 512; // it is the size of receive size after server accept the connection BaseTestSite.Log.Add(LogEntryKind.TestStep, "Connect to server over RDMA."); NtStatus status = smbdAdapter.ConnectToServerOverRDMA(); BaseTestSite.Assert.AreEqual <NtStatus>(status, NtStatus.STATUS_SUCCESS, "Status of SMBD connection is {0}.", status); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Create SMBD Negotiate request."); SmbdNegotiateRequest request = new SmbdNegotiateRequest(); request.MinVersion = SmbdVersion.V1; request.MaxVersion = SmbdVersion.V1; request.Reserved = 0; request.CreditsRequested = CREDIT_REQUESTED; request.PreferredSendSize = MAX_SEND_SIZE; request.MaxReceiveSize = MAX_RECEIVE_SIZE; request.MaxFragmentedSize = MAX_FRAGMENT_SIZE; BaseTestSite.Log.Add(LogEntryKind.TestStep, "Add 492 redundancy bytes."); byte[] requestBytes = TypeMarshal.ToBytes <SmbdNegotiateRequest>(request); byte[] allbytes = new byte[NEGOTIATE_SIZE]; Array.Copy(requestBytes, allbytes, requestBytes.Length); // post receive status = smbdAdapter.ClientConnection.Endpoint.PostReceive(NEGOTIATE_SIZE); BaseTestSite.Assert.AreEqual <NtStatus>(status, NtStatus.STATUS_SUCCESS, "Status of Post Receive is {0}.", status); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Send SMBD negotiate request."); status = smbdAdapter.SendDataOverRdma(allbytes); BaseTestSite.Assert.AreEqual <NtStatus>(status, NtStatus.STATUS_SUCCESS, "Status of Send SMBD negotiate is {0}.", status); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Receive and verify NEGOTIATE response."); byte[] responseData; smbdAdapter.ReceiveDataOverRdma( TimeSpan.FromSeconds(SmbdConnection.ACTIVE_NEGOTIATION_TIMEOUT), out responseData); SmbdNegotiateResponse response = TypeMarshal.ToStruct <SmbdNegotiateResponse>(responseData); smbdAdapter.DisconnectRdma(); NegotiateBasicChecker( response, CREDIT_REQUESTED, MAX_RECEIVE_SIZE, MAX_SEND_SIZE, MAX_FRAGMENT_SIZE); }
/// <summary> /// Establish SMB2 connection over RDMA and open file /// 1. Connect to server over RDMA /// 2. SMBD Negotiation over RDMA /// 3. Establish SMB2 session and open file with specific dialect /// </summary> /// <param name="fileName">File name to open</param> /// <param name="negotiatedDialect">Optional to set the SMB2 dialect used for SMB2 connection</param> protected virtual void EstablishConnectionAndOpenFile(string fileName, DialectRevision negotiatedDialect = DialectRevision.Smb30) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection over RDMA and open file " + fileName); // Connect to server over RDMA NtStatus status = smbdAdapter.ConnectToServerOverRDMA(); BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status); // SMBD Negotiate status = smbdAdapter.SmbdNegotiate(); BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD negotiate is {0}", status); status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName, negotiatedDialect); BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMB2 establish session and open file is {0}", status); }
/// <summary> /// Establish SMB2 connection over RDMA and open file /// 1. Connect to server over RDMA /// 2. SMBD Negotiation over RDMA /// 3. Establish SMB2 session and open file with specific dialect /// </summary> /// <param name="fileName">File name to open</param> /// <param name="negotiatedDialects">Optional to set the SMB2 dialects used for SMB2 connection</param> protected virtual void EstablishConnectionAndOpenFile(string fileName, DialectRevision[] negotiatedDialects = null) { BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection over RDMA and open file " + fileName); // Connect to server over RDMA NtStatus status = smbdAdapter.ConnectToServerOverRDMA(); BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status); // SMBD Negotiate status = smbdAdapter.SmbdNegotiate(); if (status == NtStatus.STATUS_NOT_SUPPORTED) { BaseTestSite.Assert.Inconclusive("Requested SMB dialects are not supported."); } BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD negotiate is {0}", status); status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName, negotiatedDialects); BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMB2 establish session and open file is {0}", status); }