From 8cbdc6a6dfe22a777e3420a6471726604fcafe60 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 27 Feb 2017 16:14:39 +0100 Subject: 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 Reviewed-by: Jeremy Allison --- source4/libcli/raw/libcliraw.h | 1 + source4/libcli/raw/rawnegotiate.c | 3 ++- source4/libcli/smb2/connect.c | 6 ++---- source4/param/loadparm.c | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'source4') diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h index 8220cd7c563..96dfcd4c765 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 4b42c2662a0..f6a189ff8d7 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 1a6ae34d2cd..8ff56c9ca8f 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 f53b2dd1807..1044a07ee30 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, -- cgit v1.2.1