]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:torture: Add notify test with multichannel for 'smb2 max async credits'
authorAndreas Schneider <asn@samba.org>
Fri, 9 Aug 2024 07:12:04 +0000 (09:12 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 29 Jan 2025 11:20:33 +0000 (11:20 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14430

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/knownfail.d/smb2_credits
source4/torture/smb2/credits.c

index 2a5d259a3d074aeaa9e6cac76932696ff61efcad..6ed5119c3e5cc8837ea4e335e2a54c3f828037ad 100644 (file)
@@ -3,3 +3,4 @@ samba3.smb2.credits.*2conn_ipc_max_async_credits
 samba3.smb2.credits.*multichannel_ipc_max_async_credits
 samba3.smb2.credits.*1conn_notify_max_async_credits
 samba3.smb2.credits.*2conn_notify_max_async_credits
+samba3.smb2.credits.*multichannel_max_async_credits
index d16213866ae1f423831007955922df78db515b85..7593404696a5c1177cd4dacbcf2ce170718a70c2 100644 (file)
@@ -1379,6 +1379,94 @@ out:
        return ok;
 }
 
+static bool test_multichannel_notify_max_async_credits(
+       struct torture_context *tctx,
+       struct smb2_tree *tree1a)
+{
+       uint16_t max_async_credits = torture_setting_int(
+               tctx,
+               "maxasynccredits",
+               512 /* lpcfg_smb2_max_async_credits(tctx->lp_ctx) */);
+       const char *host = torture_setting_string(tctx, "host", NULL);
+       const char *share = torture_setting_string(tctx, "share", NULL);
+       struct smb2_transport *transport1a = tree1a->session->transport;
+       struct smbcli_options options = transport1a->options;
+       struct smb2_session *session1a = tree1a->session;
+       struct smb2_session *session1b = NULL;
+       struct smb2_tree *tree1b_base = NULL;
+       struct smb2_transport *transport1b = NULL;
+       struct smb2_tree *tree1b = NULL;
+       struct smb2_tree *trees[2] = {};
+       struct smb2_handle dh = {{}};
+       bool ok = false;
+       NTSTATUS status;
+       uint16_t max_credits = max_async_credits + 2;
+
+       smb2_transport_credits_ask_num(transport1a, max_credits);
+
+       /* Cleanup TESTDIR */
+       smb2_deltree(tree1a, TESTDIR);
+
+       /* Create TESTDIR */
+       status = torture_smb2_testdir(tree1a, TESTDIR, &dh);
+       torture_assert_ntstatus_ok_goto(
+               tctx, status, ok, out, "smb2_create failed");
+       status = smb2_util_close(tree1a, dh);
+       torture_assert_ntstatus_ok_goto(
+               tctx, status, ok, out, "smb2_util_close failed");
+
+       /* Create a new connection with bigger max_credits value */
+       options.max_credits = max_credits;
+       /* Connect multichannel */
+       options.only_negprot = true;
+
+       status = smb2_connect(tree1a,
+                             host,
+                             lpcfg_smb_ports(tctx->lp_ctx),
+                             share,
+                             lpcfg_resolve_context(tctx->lp_ctx),
+                             samba_cmdline_get_creds(),
+                             &tree1b_base,
+                             tctx->ev,
+                             &options,
+                             lpcfg_socket_options(tctx->lp_ctx),
+                             lpcfg_gensec_settings(tctx, tctx->lp_ctx));
+       torture_assert_ntstatus_ok_goto(
+               tctx, status, ok, out, "smb2_connect failed");
+       transport1b = tree1b_base->session->transport;
+
+       session1b = smb2_session_channel(transport1b,
+                                        lpcfg_gensec_settings(tctx,
+                                                              tctx->lp_ctx),
+                                        tree1b_base,
+                                        session1a);
+       torture_assert_not_null_goto(
+               tctx, session1b, ok, out, "smb2_session_channel failed");
+
+       status = smb2_session_setup_spnego(session1b,
+                                          samba_cmdline_get_creds(),
+                                          0);
+       torture_assert_ntstatus_ok_goto(
+               tctx, status, ok, out, "smb2_session_setup_spnego failed");
+
+       tree1b = smb2_tree_channel(tree1a, tree1b_base, false, session1b);
+       torture_assert_not_null_goto(
+               tctx, tree1b, ok, out, "smb2_tree_channel failed");
+
+       trees[0] = tree1a;
+       trees[1] = tree1b;
+
+       ok = test_notify_max_async_credits(tctx,
+                                          trees,
+                                          ARRAY_SIZE(trees),
+                                          max_credits);
+out:
+       /* Cleanup TESTDIR */
+       smb2_deltree(tree1a, TESTDIR);
+
+       return ok;
+}
+
 struct torture_suite *torture_smb2_crediting_init(TALLOC_CTX *ctx)
 {
        struct torture_suite *suite = torture_suite_create(ctx, "credits");
@@ -1403,6 +1491,9 @@ struct torture_suite *torture_smb2_crediting_init(TALLOC_CTX *ctx)
        torture_suite_add_2smb2_test(suite,
                                     "2conn_notify_max_async_credits",
                                     test_2conn_notify_max_async_credits);
+       torture_suite_add_1smb2_test(suite,
+                                    "multichannel_max_async_credits",
+                                    test_multichannel_notify_max_async_credits);
 
        suite->description = talloc_strdup(suite, "SMB2-CREDITS tests");