[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Sat Mar 4 00:55:03 UTC 2017


The branch, master has been updated
       via  53e9c2b s4/torture: add a creditting test skipping a SMB2 MID
       via  cce2240 libcli/smb: add smb2cli_conn_get_mid and smb2cli_conn_set_mid
       via  b668c30 s4/torture: add some SMB2 crediting tests
       via  799b7e7 libcli/smb: add smb2cli_conn_get_cur_credits
       via  8cbdc6a libcli/smb: add max_credits arg to smbXcli_negprot_send()
       via  ac71bb3 lib: Make gencache hash size configurable, default to 10000
      from  1cb99fc idmap_hash: Add a deprecation message

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 53e9c2b65d56dbd365e945129148c4293da635bc
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Feb 27 12:55:04 2017 +0100

    s4/torture: add a creditting test skipping a SMB2 MID
    
    This tests that skipping a SMB2 MID the client's usable MID window is
    
    [unused mid, unused mid + 8192]
    
    The test currently fails against Samba as we only grant up to 512
    credits. It passes against Windows 2016 as that grants up to 8192
    credits by default.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Mar  4 01:54:07 CET 2017 on sn-devel-144

commit cce2240f0844ef650f21b64a56acc814a60e0447
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Feb 26 09:28:12 2017 +0100

    libcli/smb: add smb2cli_conn_get_mid and smb2cli_conn_set_mid
    
    This will be needed for a torture test in the next commit.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b668c300bf5c5ab1b0402e80f6f46d81daac2a34
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Feb 27 07:12:09 2017 +0100

    s4/torture: add some SMB2 crediting tests
    
    These tests verify that a server grants at least 8192 credits in a
    successfull session setup and in a single SMB2 request. Both tests pass
    against Windows 2016 Server but currently fail against Samba.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 799b7e75c3b4b38d58ef56918135176c708103ff
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Feb 27 12:29:25 2017 +0100

    libcli/smb: add smb2cli_conn_get_cur_credits
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8cbdc6a6dfe22a777e3420a6471726604fcafe60
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Feb 27 16:14:39 2017 +0100

    libcli/smb: add max_credits arg to smbXcli_negprot_send()
    
    This allows source4/torture code to set the option for tests by
    preparing a struct smbcli_options with max_credits set to some value and
    pass that to a torture_smb2_connection_ext().
    
    This will be used in subsequent smbtorture test for SMB2 creditting.
    
    Behaviour of existing upper layers is unchanged, they simply pass the
    wanted max credits value to smbXcli_negprot_send() instead of
    retrofitting it with a call to smb2cli_conn_set_max_credits().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ac71bb3eb45fc87365206a5f6f9083c42972b25a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Feb 6 17:10:40 2017 +0100

    lib: Make gencache hash size configurable, default to 10000
    
    For large deployments with many users, we put a lot of idmapping
    entries into gencache. Increase the hash size from our default 131.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 libcli/smb/smbXcli_base.c          |  35 +++--
 libcli/smb/smbXcli_base.h          |   6 +-
 selftest/knownfail                 |   3 +
 source3/lib/gencache.c             |  11 +-
 source3/libsmb/cliconnect.c        |   4 +-
 source3/torture/torture.c          |   2 +-
 source4/libcli/raw/libcliraw.h     |   1 +
 source4/libcli/raw/rawnegotiate.c  |   3 +-
 source4/libcli/smb2/connect.c      |   6 +-
 source4/param/loadparm.c           |   2 +
 source4/selftest/tests.py          |   2 +-
 source4/torture/smb2/credits.c     | 268 +++++++++++++++++++++++++++++++++++++
 source4/torture/smb2/smb2.c        |   1 +
 source4/torture/smb2/wscript_build |   1 +
 14 files changed, 320 insertions(+), 25 deletions(-)
 create mode 100644 source4/torture/smb2/credits.c


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index a7b24f0..9521fc6 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -2782,6 +2782,11 @@ void smb2cli_conn_set_max_credits(struct smbXcli_conn *conn,
 	conn->smb2.max_credits = max_credits;
 }
 
+uint16_t smb2cli_conn_get_cur_credits(struct smbXcli_conn *conn)
+{
+	return conn->smb2.cur_credits;
+}
+
 uint8_t smb2cli_conn_get_io_priority(struct smbXcli_conn *conn)
 {
 	if (conn->protocol < PROTOCOL_SMB3_11) {
@@ -4092,7 +4097,8 @@ struct tevent_req *smbXcli_negprot_send(TALLOC_CTX *mem_ctx,
 					struct smbXcli_conn *conn,
 					uint32_t timeout_msec,
 					enum protocol_types min_protocol,
-					enum protocol_types max_protocol)
+					enum protocol_types max_protocol,
+					uint16_t max_credits)
 {
 	struct tevent_req *req, *subreq;
 	struct smbXcli_negprot_state *state;
@@ -4125,6 +4131,10 @@ struct tevent_req *smbXcli_negprot_send(TALLOC_CTX *mem_ctx,
 	conn->max_protocol = max_protocol;
 	conn->protocol = PROTOCOL_NONE;
 
+	if (max_protocol >= PROTOCOL_SMB2_02) {
+		conn->smb2.max_credits = max_credits;
+	}
+
 	if ((min_protocol < PROTOCOL_SMB2_02) &&
 	    (max_protocol < PROTOCOL_SMB2_02)) {
 		/*
@@ -4147,16 +4157,6 @@ struct tevent_req *smbXcli_negprot_send(TALLOC_CTX *mem_ctx,
 		 */
 		conn->dispatch_incoming = smb2cli_conn_dispatch_incoming;
 
-		/*
-		 * As we're starting with an SMB2 negprot, emulate Windows
-		 * and ask for 31 credits in the initial SMB2 negprot.
-		 * If we don't and leave requested credits at
-		 * zero, MacOSX servers return zero credits on
-		 * the negprot reply and we fail to connect.
-		 */
-		smb2cli_conn_set_max_credits(conn,
-			WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK);
-
 		subreq = smbXcli_negprot_smb2_subreq(state);
 		if (tevent_req_nomem(subreq, req)) {
 			return tevent_req_post(req, ev);
@@ -5137,7 +5137,8 @@ NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
 		goto fail;
 	}
 	req = smbXcli_negprot_send(frame, ev, conn, timeout_msec,
-				   min_protocol, max_protocol);
+				   min_protocol, max_protocol,
+				   WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK);
 	if (req == NULL) {
 		goto fail;
 	}
@@ -6247,3 +6248,13 @@ bool smb2cli_tcon_is_encryption_on(struct smbXcli_tcon *tcon)
 {
 	return tcon->smb2.should_encrypt;
 }
+
+void smb2cli_conn_set_mid(struct smbXcli_conn *conn, uint64_t mid)
+{
+	conn->smb2.mid = mid;
+}
+
+uint64_t smb2cli_conn_get_mid(struct smbXcli_conn *conn)
+{
+	return conn->smb2.mid;
+}
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index 702eedf..84f4a6b 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -368,6 +368,7 @@ uint32_t smb2cli_conn_max_read_size(struct smbXcli_conn *conn);
 uint32_t smb2cli_conn_max_write_size(struct smbXcli_conn *conn);
 void smb2cli_conn_set_max_credits(struct smbXcli_conn *conn,
 				  uint16_t max_credits);
+uint16_t smb2cli_conn_get_cur_credits(struct smbXcli_conn *conn);
 uint8_t smb2cli_conn_get_io_priority(struct smbXcli_conn *conn);
 void smb2cli_conn_set_io_priority(struct smbXcli_conn *conn,
 				  uint8_t io_priority);
@@ -377,6 +378,8 @@ void smb2cli_conn_set_cc_chunk_len(struct smbXcli_conn *conn,
 uint32_t smb2cli_conn_cc_max_chunks(struct smbXcli_conn *conn);
 void smb2cli_conn_set_cc_max_chunks(struct smbXcli_conn *conn,
 				    uint32_t max_chunks);
+void smb2cli_conn_set_mid(struct smbXcli_conn *conn, uint64_t mid);
+uint64_t smb2cli_conn_get_mid(struct smbXcli_conn *conn);
 
 struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
 				      struct tevent_context *ev,
@@ -436,7 +439,8 @@ struct tevent_req *smbXcli_negprot_send(TALLOC_CTX *mem_ctx,
 					struct smbXcli_conn *conn,
 					uint32_t timeout_msec,
 					enum protocol_types min_protocol,
-					enum protocol_types max_protocol);
+					enum protocol_types max_protocol,
+					uint16_t max_credits);
 NTSTATUS smbXcli_negprot_recv(struct tevent_req *req);
 NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
 			 uint32_t timeout_msec,
diff --git a/selftest/knownfail b/selftest/knownfail
index d96e238..7c5417b 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -312,3 +312,6 @@
 ^samba.tests.dcerpc.dnsserver.samba.tests.dcerpc.dnsserver.DnsserverTests.test_add_duplicate_different_type.*
 ^samba.tests.dcerpc.dnsserver.samba.tests.dcerpc.dnsserver.DnsserverTests.test_rank_none.*
 ^samba.tests.dcerpc.dnsserver.samba.tests.dcerpc.dnsserver.DnsserverTests.test_security_descriptor.*
+^samba3.smb2.credits.session_setup_credits_granted.*
+^samba3.smb2.credits.single_req_credits_granted.*
+^samba3.smb2.credits.skipped_mid.*
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 2c1704e..1572825 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -55,12 +55,15 @@ static bool gencache_init(void)
 {
 	char* cache_fname = NULL;
 	int open_flags = O_RDWR|O_CREAT;
+	int hash_size;
 
 	/* skip file open if it's already opened */
 	if (cache) {
 		return true;
 	}
 
+	hash_size = lp_parm_int(-1, "gencache", "hash_size", 10000);
+
 	cache_fname = cache_path("gencache.tdb");
 	if (cache_fname == NULL) {
 		return false;
@@ -68,7 +71,7 @@ static bool gencache_init(void)
 
 	DEBUG(5, ("Opening cache file at %s\n", cache_fname));
 
-	cache = tdb_wrap_open(NULL, cache_fname, 0,
+	cache = tdb_wrap_open(NULL, cache_fname, hash_size,
 			      TDB_DEFAULT|TDB_INCOMPATIBLE_HASH,
 			      open_flags, 0644);
 	if (cache) {
@@ -87,7 +90,7 @@ static bool gencache_init(void)
 			 * CLEAR_IF_FIRST databases, so lets use it here to
 			 * clean up a broken database.
 			 */
-			cache = tdb_wrap_open(NULL, cache_fname, 0,
+			cache = tdb_wrap_open(NULL, cache_fname, hash_size,
 					      TDB_DEFAULT|
 					      TDB_INCOMPATIBLE_HASH|
 					      TDB_CLEAR_IF_FIRST,
@@ -97,7 +100,7 @@ static bool gencache_init(void)
 
 	if (!cache && (errno == EACCES)) {
 		open_flags = O_RDONLY;
-		cache = tdb_wrap_open(NULL, cache_fname, 0,
+		cache = tdb_wrap_open(NULL, cache_fname, hash_size,
 				      TDB_DEFAULT|TDB_INCOMPATIBLE_HASH,
 				      open_flags, 0644);
 		if (cache) {
@@ -119,7 +122,7 @@ static bool gencache_init(void)
 
 	DEBUG(5, ("Opening cache file at %s\n", cache_fname));
 
-	cache_notrans = tdb_wrap_open(NULL, cache_fname, 0,
+	cache_notrans = tdb_wrap_open(NULL, cache_fname, hash_size,
 				      TDB_CLEAR_IF_FIRST|
 				      TDB_INCOMPATIBLE_HASH|
 				      TDB_NOSYNC|
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index a9451fb..029c3d4 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -39,6 +39,7 @@
 #include "../libcli/smb/smbXcli_base.h"
 #include "../libcli/smb/smb_seal.h"
 #include "lib/param/param.h"
+#include "../libcli/smb/smb2_negotiate_context.h"
 
 #define STAR_SMBSERVER "*SMBSERVER"
 
@@ -2754,7 +2755,8 @@ static void cli_start_connection_connected(struct tevent_req *subreq)
 	subreq = smbXcli_negprot_send(state, state->ev, state->cli->conn,
 				      state->cli->timeout,
 				      state->min_protocol,
-				      state->max_protocol);
+				      state->max_protocol,
+				      WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK);
 	if (tevent_req_nomem(subreq, req)) {
 		return;
 	}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 2c10ae8..dbbd072 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -2990,7 +2990,7 @@ static bool run_negprot_nowait(int dummy)
 		struct tevent_req *req;
 
 		req = smbXcli_negprot_send(ev, ev, cli->conn, cli->timeout,
-					   PROTOCOL_CORE, PROTOCOL_NT1);
+					   PROTOCOL_CORE, PROTOCOL_NT1, 0);
 		if (req == NULL) {
 			TALLOC_FREE(ev);
 			return false;
diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h
index 8220cd7..96dfcd4 100644
--- a/source4/libcli/raw/libcliraw.h
+++ b/source4/libcli/raw/libcliraw.h
@@ -103,6 +103,7 @@ struct smbcli_options {
 	enum smb_signing_setting signing;
 	uint32_t smb2_capabilities;
 	struct GUID client_guid;
+	uint64_t max_credits;
 };
 
 /* this is the context for the client transport layer */
diff --git a/source4/libcli/raw/rawnegotiate.c b/source4/libcli/raw/rawnegotiate.c
index 4b42c26..f6a189f 100644
--- a/source4/libcli/raw/rawnegotiate.c
+++ b/source4/libcli/raw/rawnegotiate.c
@@ -60,7 +60,8 @@ struct tevent_req *smb_raw_negotiate_send(TALLOC_CTX *mem_ctx,
 				      transport->conn,
 				      timeout_msec,
 				      minprotocol,
-				      maxprotocol);
+				      maxprotocol,
+				      transport->options.max_credits);
 	if (tevent_req_nomem(subreq, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index 1a6ae34..8ff56c9 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -155,7 +155,8 @@ static void smb2_connect_socket_done(struct composite_context *creq)
 	subreq = smbXcli_negprot_send(state, state->ev,
 				      state->transport->conn, timeout_msec,
 				      min_protocol,
-				      state->transport->options.max_protocol);
+				      state->transport->options.max_protocol,
+				      state->transport->options.max_credits);
 	if (tevent_req_nomem(subreq, req)) {
 		return;
 	}
@@ -181,9 +182,6 @@ static void smb2_connect_negprot_done(struct tevent_req *subreq)
 		return;
 	}
 
-	/* This is a hack... */
-	smb2cli_conn_set_max_credits(transport->conn, 30);
-
 	state->session = smb2_session_init(transport, state->gensec_settings, state);
 	if (tevent_req_nomem(state->session, req)) {
 		return;
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index f53b2dd..1044a07 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -30,6 +30,7 @@
 #include "lib/param/param.h"
 #include "libcli/raw/libcliraw.h"
 #include "librpc/ndr/libndr.h"
+#include "libcli/smb/smb2_negotiate_context.h"
 
 void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
 			 struct smbcli_options *options)
@@ -47,6 +48,7 @@ void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
 	options->use_level2_oplocks = true;
 	options->smb2_capabilities = SMB2_CAP_ALL;
 	options->client_guid = GUID_random();
+	options->max_credits = WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK;
 }
 
 void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index 80bee03..ac601f5 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -303,7 +303,7 @@ for t in nbt_tests:
 ntvfsargs = ["--option=torture:sharedelay=100000", "--option=torture:oplocktimeout=3", "--option=torture:writetimeupdatedelay=500000"]
 
 # Filter smb2 tests that should not run against ad_dc_ntvfs
-smb2_s3only = ["smb2.change_notify_disabled", "smb2.dosmode"]
+smb2_s3only = ["smb2.change_notify_disabled", "smb2.dosmode", "smb2.credits"]
 smb2 = [x for x in smbtorture4_testsuites("smb2.") if x not in smb2_s3only]
 
 #The QFILEINFO-IPC test needs to be on ipc$
diff --git a/source4/torture/smb2/credits.c b/source4/torture/smb2/credits.c
new file mode 100644
index 0000000..43550c3
--- /dev/null
+++ b/source4/torture/smb2/credits.c
@@ -0,0 +1,268 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   test suite for SMB2 credits
+
+   Copyright (C) Ralph Boehme 2017
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "../libcli/smb/smbXcli_base.h"
+#include "lib/param/param.h"
+
+/**
+ * Request 64k credits in negprot/sessionsetup and require at least 8k
+ *
+ * This passes against Windows 2016
+ **/
+static bool test_session_setup_credits_granted(struct torture_context *tctx,
+					       struct smb2_tree *_tree)
+{
+	struct smbcli_options options;
+	struct smb2_transport *transport = NULL;
+	struct smb2_tree *tree = NULL;
+	uint16_t cur_credits;
+	NTSTATUS status;
+	bool ret = true;
+
+	transport = _tree->session->transport;
+	options = transport->options;
+
+	status = smb2_logoff(_tree->session);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_logoff failed\n");
+	TALLOC_FREE(_tree);
+
+	options.max_credits = 65535;
+
+	ret = torture_smb2_connection_ext(tctx, 0, &options, &tree);
+	torture_assert_goto(tctx, ret == true, ret, done,
+			    "torture_smb2_connection_ext failed\n");
+
+	transport = tree->session->transport;
+
+	cur_credits = smb2cli_conn_get_cur_credits(transport->conn);
+	if (cur_credits < 8192) {
+		torture_result(tctx, TORTURE_FAIL,
+			       "Server only granted %" PRIu16" credits\n",
+			       cur_credits);
+		ret = false;
+		goto done;
+	}
+
+done:
+	TALLOC_FREE(tree);
+	return ret;
+}
+
+/**
+ * Request 64K credits in a single SMB2 request and requite at least 8192
+ *
+ * This passes against Windows 2016
+ **/
+static bool test_single_req_credits_granted(struct torture_context *tctx,
+					    struct smb2_tree *_tree)
+{
+	struct smbcli_options options;
+	struct smb2_transport *transport = NULL;
+	struct smb2_tree *tree = NULL;
+	struct smb2_handle h = {{0}};
+	struct smb2_create create;
+	const char *fname = "single_req_credits_granted.dat";
+	uint16_t cur_credits;
+	NTSTATUS status;
+	bool ret = true;
+
+	smb2_util_unlink(_tree, fname);
+
+	transport = _tree->session->transport;
+	options = transport->options;
+
+	status = smb2_logoff(_tree->session);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_logoff failed\n");
+	TALLOC_FREE(_tree);
+
+	options.max_credits = 1;
+
+	ret = torture_smb2_connection_ext(tctx, 0, &options, &tree);
+	torture_assert_goto(tctx, ret == true, ret, done,
+			    "torture_smb2_connection_ext failed\n");
+
+	transport = tree->session->transport;
+
+	cur_credits = smb2cli_conn_get_cur_credits(transport->conn);
+	if (cur_credits != 1) {
+		torture_result(tctx, TORTURE_FAIL,
+			       "Only wanted 1 credit but server granted %" PRIu16"\n",
+			       cur_credits);
+		ret = false;
+		goto done;
+	}
+
+	smb2cli_conn_set_max_credits(transport->conn, 65535);
+
+	ZERO_STRUCT(create);
+	create.in.impersonation_level	= NTCREATEX_IMPERSONATION_IMPERSONATION;
+	create.in.desired_access	= SEC_RIGHTS_FILE_ALL;
+	create.in.file_attributes	= FILE_ATTRIBUTE_NORMAL;
+	create.in.create_disposition	= NTCREATEX_DISP_OPEN_IF;
+	create.in.fname			= fname;
+
+	status = smb2_create(tree, tctx, &create);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+					"smb2_create failed\n");
+	h = create.out.file.handle;
+
+	cur_credits = smb2cli_conn_get_cur_credits(transport->conn);
+	if (cur_credits < 8192) {
+		torture_result(tctx, TORTURE_FAIL,
+			       "Server only granted %" PRIu16" credits\n",
+			       cur_credits);
+		ret = false;
+		goto done;
+	}
+
+done:
+	if (!smb2_util_handle_empty(h)) {
+		smb2_util_close(tree, h);
+	}
+	smb2_util_unlink(tree, fname);
+	TALLOC_FREE(tree);
+	return ret;
+}
+
+static bool test_crediting_skipped_mid(struct torture_context *tctx,
+				       struct smb2_tree *_tree)
+{
+	struct smbcli_options options;
+	struct smb2_transport *transport = NULL;
+	struct smb2_tree *tree = NULL;
+	struct smb2_handle h = {{0}};
+	struct smb2_create create;
+	const char *fname = "skipped_mid.dat";
+	uint64_t mid;
+	uint16_t cur_credits;
+	NTSTATUS status;
+	bool ret = true;
+	int i;
+
+	smb2_util_unlink(_tree, fname);
+
+	transport = _tree->session->transport;
+	options = transport->options;
+
+	status = smb2_logoff(_tree->session);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_logoff failed\n");
+	TALLOC_FREE(_tree);
+
+	options.max_credits = 8192;
+
+	ret = torture_smb2_connection_ext(tctx, 0, &options, &tree);
+	torture_assert_goto(tctx, ret == true, ret, done, "torture_smb2_connection_ext failed\n");
+
+	transport = tree->session->transport;
+
+	cur_credits = smb2cli_conn_get_cur_credits(transport->conn);
+	if (cur_credits != 8192) {
+		torture_result(tctx, TORTURE_FAIL, "Server only granted %" PRIu16" credits\n", cur_credits);
+		ret = false;
+		goto done;
+	}
+
+	ZERO_STRUCT(create);
+	create.in.impersonation_level	= NTCREATEX_IMPERSONATION_IMPERSONATION;
+	create.in.desired_access	= SEC_RIGHTS_FILE_ALL;
+	create.in.file_attributes	= FILE_ATTRIBUTE_NORMAL;
+	create.in.create_disposition	= NTCREATEX_DISP_OPEN_IF;
+	create.in.fname			= fname;
+
+	status = smb2_create(tree, tctx, &create);
+	torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create failed\n");
+	h = create.out.file.handle;
+


-- 
Samba Shared Repository



More information about the samba-cvs mailing list