return ret;
}
-static bool test_multichannel_lease_break_test5(struct torture_context *tctx,
- struct smb2_tree *tree1)
-{
- const char *host = torture_setting_string(tctx, "host", NULL);
- const char *share = torture_setting_string(tctx, "share", NULL);
- struct cli_credentials *credentials = popt_get_cmdline_credentials();
- NTSTATUS status;
- TALLOC_CTX *mem_ctx = talloc_new(tctx);
- struct test_multichannel_lease_break_state state = {
- .tctx = tctx,
- };
- struct test_multichannel_lease_break_channel *open2_channel = NULL;
- struct smb2_handle _h;
- struct smb2_handle *h = NULL;
- struct smb2_handle h_client1_file1 = {{0}};
- struct smb2_handle h_client2_file1 = {{0}};
- struct smb2_create io1;
- struct smb2_request *req = NULL;
- struct smb2_create io2;
- bool ret = true;
- const char *fname1 = BASEDIR "\\lease_break_test5.dat";
- struct smb2_tree *trees2[32] = { NULL, };
- size_t i;
- struct smb2_transport *transport1 = tree1->session->transport;
- struct smbcli_options transport2_options;
- struct smb2_session *session1 = tree1->session;
- uint16_t local_port = 0;
- struct smb2_lease ls1;
- struct smb2_lease ls2;
- bool block_setup = false;
- bool block_ok = false;
- DATA_BLOB blob;
-
- if (!test_multichannel_initial_checks(tctx, tree1)) {
- return true;
- }
-
- torture_comment(tctx, "Lease break retry: Test5\n");
-
- torture_reset_lease_break_info(tctx, &lease_break_info);
- lease_break_info.lease_skip_ack = true;
-
- transport1->lease.handler = torture_lease_handler;
- transport1->lease.private_data = tree1;
- torture_comment(tctx, "transport1 [%p]\n", transport1);
- local_port = torture_get_local_port_from_transport(transport1);
- torture_comment(tctx, "transport1 uses tcp port: %d\n", local_port);
-
- status = torture_smb2_testdir(tree1, BASEDIR, &_h);
- CHECK_STATUS(status, NT_STATUS_OK);
- smb2_util_close(tree1, _h);
- smb2_util_unlink(tree1, fname1);
- CHECK_VAL(lease_break_info.count, 0);
-
- smb2_lease_v2_create(&io2, &ls2, false, fname1,
- LEASE2F1, NULL,
- smb2_util_lease_state("RHW"),
- 0x20);
- test_multichannel_init_smb_create(&io1);
-
- transport2_options = transport1->options;
-
- ret = test_multichannel_create_channel_array(tctx, host, share, credentials,
- &transport2_options,
- ARRAY_SIZE(trees2), trees2);
- torture_assert(tctx, ret, "Could not create channels.\n");
-
- for (i = 0; i < ARRAY_SIZE(trees2); i++) {
- struct test_multichannel_lease_break_channel *c = &state.channels[i];
- struct smb2_transport *t = trees2[i]->session->transport;
-
- c->state = &state;
- c->idx = i+1;
- c->tree = trees2[i];
- snprintf(c->name, sizeof(c->name), "trees2_%zu", c->idx);
-
- t->lease.handler = test_multichannel_lease_break_handler;
- t->lease.private_data = c;
- }
-
- open2_channel = &state.channels[0];
-
- /* 2a opens file1 */
- torture_comment(tctx, "client2 opens fname1 via %s\n",
- open2_channel->name);
- status = smb2_create(open2_channel->tree, mem_ctx, &io2);
- CHECK_STATUS(status, NT_STATUS_OK);
- h_client2_file1 = io2.out.file.handle;
- CHECK_CREATED(&io2, CREATED, FILE_ATTRIBUTE_ARCHIVE);
- CHECK_LEASE_V2(&io2, "RHW", true, LEASE2F1, 0, 0, 0x21);
- CHECK_VAL(io2.out.durable_open_v2, false);
- CHECK_VAL(io2.out.timeout, io2.in.timeout);
- CHECK_VAL(io2.out.durable_open, false);
- CHECK_VAL(lease_break_info.count, 0);
-
- block_setup = test_setup_blocked_transports(tctx);
- torture_assert(tctx, block_setup, "test_setup_blocked_transports");
-
- for (i = 0; i < ARRAY_SIZE(state.channels); i++) {
- struct test_multichannel_lease_break_channel *c = &state.channels[i];
- struct smb2_transport *t = c->tree->session->transport;
-
- torture_comment(tctx, "Blocking %s\n", c->name);
- block_ok = _test_block_smb2_transport(tctx, t, c->name);
- torture_assert_goto(tctx, block_ok, ret, done, "we could not block tcp transport");
- c->blocked = true;
- }
-
- /* 1 opens file2 */
- torture_comment(tctx,
- "Client opens fname1 with session 1 with all %zu blocked\n",
- ARRAY_SIZE(trees2));
- smb2_lease_v2_create(&io1, &ls1, false, fname1,
- LEASE1F1, NULL,
- smb2_util_lease_state("RHW"),
- 0x10);
- test_multichannel_init_smb_create(&io1);
- CHECK_VAL(lease_break_info.count, 0);
-// io1.in.desired_access = SEC_FILE_READ_DATA;
- req = smb2_create_send(tree1, &io1);
-// while (lease_break_info.count < ARRAY_SIZE(trees2)) {
-// torture_comment(tctx, "Received %d lease break(s) wait for more!!\n",
-// lease_break_info.count);
-// torture_wait_for_lease_break(tctx);
-// }
- status = smb2_create_recv(req, mem_ctx, &io1);
- CHECK_STATUS(status, NT_STATUS_OK);
- h_client1_file1 = io1.out.file.handle;
- CHECK_LEASE_V2(&io1, "RH", true, LEASE1F1, 0, 0, 0x11);
-
- while (lease_break_info.count < ARRAY_SIZE(trees2)) {
- torture_comment(tctx, "Received %d lease break(s) wait for more!!\n",
- lease_break_info.count);
- torture_wait_for_lease_break(tctx);
- }
-// for (i = 0; i < num_trees; i++) {
-//
-// struct smb2_tree *tree, *parent_tree = NULL;
-// struct smb2_transport *transport;
-// uint16_t local_port = 0;
-//
-// if (i > 1) {
-// parent_tree = trees[0];
-// }
-//
-// torture_comment(tctx, "Setting up connection %d\n", i);
-// tree = test_multichannel_create_channel(tctx, host, share,
-// credentials, &transport_options,
-// parent_tree);
-// torture_assert(tctx, tree, "failed to created new channel");
-//
-// trees[i] = tree;
-// transport = tree->session->transport;
-// local_port = torture_get_local_port_from_transport(transport);
-// torture_comment(tctx, "transport[%d] uses tcp port: %d\n",
-// i, local_port);
-// }
- blob = data_blob_string_const("Here I am");
- status = smb2_util_write(tree1,
- h_client1_file1,
- blob.data,
- 0,
- blob.length);
- torture_assert_ntstatus_ok(tctx, status,
- "failed to write...");
-
- while (lease_break_info.count < ARRAY_SIZE(trees2)*2) {
- torture_comment(tctx, "Received %d lease break(s) wait for more!!\n",
- lease_break_info.count);
- torture_wait_for_lease_break(tctx);
- }
-
- if (lease_break_info.count == 0) {
- torture_comment(tctx,
- "Did not receive expected lease break!!\n");
- } else {
- torture_comment(tctx, "Received %d lease break(s)!!\n",
- lease_break_info.count);
- }
-
-done:
- for (i = 0; i < ARRAY_SIZE(state.channels); i++) {
- struct test_multichannel_lease_break_channel *c = &state.channels[i];
- struct smb2_transport *t = NULL;
-
- if (!c->blocked) {
- continue;
- }
-
- t = c->tree->session->transport;
-
- torture_comment(tctx, "Unblocking %s\n", c->name);
- _test_unblock_smb2_transport(tctx, t, c->name);
- }
- if (block_setup) {
- test_cleanup_blocked_transports(tctx);
- }
-
- tree1->session = session1;
-
- smb2_util_close(tree1, h_client1_file1);
- if (trees2[0] != NULL) {
- smb2_util_close(trees2[0], h_client2_file1);
- }
-
- if (h != NULL) {
- smb2_util_close(tree1, *h);
- }
-
- smb2_util_unlink(tree1, fname1);
- smb2_deltree(tree1, BASEDIR);
-
- for (i = 0; i < ARRAY_SIZE(trees2); i++) {
- if (trees2 == NULL || trees2[i] == NULL) {
- continue;
- }
- TALLOC_FREE(trees2[i]);
- }
- talloc_free(tree1);
- talloc_free(mem_ctx);
-
- return ret;
-}
-
struct torture_suite *torture_smb2_multichannel_init(TALLOC_CTX *ctx)
{
struct torture_suite *suite = torture_suite_create(ctx, "multichannel");
test_multichannel_lease_break_test3);
torture_suite_add_1smb2_test(suite_leases, "test4",
test_multichannel_lease_break_test4);
- torture_suite_add_1smb2_test(suite_leases, "test5",
- test_multichannel_lease_break_test5);
suite->description = talloc_strdup(suite, "SMB2 Multichannel tests");