torture:smb2: for oplocks, durable reconnect works with different client-guid
authorMichael Adam <obnox@samba.org>
Tue, 15 Mar 2016 08:02:28 +0000 (09:02 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 21 Mar 2016 23:23:22 +0000 (00:23 +0100)
for durable-v2-open.reopen1a

Try both different and original client guid.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/torture/smb2/durable_v2_open.c

index 2528187f7a9920d8a02f21ddc069a12cdbe7c7e2..e48fb9b5f354b9d881a060eef7d6440ce30e8efb 100644 (file)
@@ -592,10 +592,13 @@ bool test_durable_v2_open_reopen1a(struct torture_context *tctx,
        struct GUID create_guid = GUID_random();
        bool ret = true;
        struct smb2_tree *tree2 = NULL;
+       struct smb2_tree *tree3 = NULL;
        uint64_t previous_session_id;
        struct smbcli_options options;
+       struct GUID orig_client_guid;
 
        options = tree->session->transport->options;
+       orig_client_guid = options.client_guid;
 
        /* Choose a random name in case the state is left a little funky. */
        snprintf(fname, 256, "durable_v2_open_reopen1a_%s.dat",
@@ -629,6 +632,9 @@ bool test_durable_v2_open_reopen1a(struct torture_context *tctx,
 
        previous_session_id = smb2cli_session_current_id(tree->session->smbXcli);
 
+       /* for oplocks, the client guid can be different: */
+       options.client_guid = GUID_random();
+
        ret = torture_smb2_connection_ext(tctx, previous_session_id,
                                          &options, &tree2);
        torture_assert_goto(tctx, ret, ret, done, "couldn't reconnect");
@@ -665,11 +671,59 @@ bool test_durable_v2_open_reopen1a(struct torture_context *tctx,
        _h = io.out.file.handle;
        h = &_h;
 
+       /*
+        * a session reconnect on a second tcp connection
+        */
+
+       previous_session_id = smb2cli_session_current_id(tree2->session->smbXcli);
+
+       /* it works the same with the original guid */
+       options.client_guid = orig_client_guid;
+
+       ret = torture_smb2_connection_ext(tctx, previous_session_id,
+                                         &options, &tree3);
+       torture_assert_goto(tctx, ret, ret, done, "couldn't reconnect");
+
+       /*
+        * check that this has deleted the old session
+        */
+
+       ZERO_STRUCT(io);
+       io.in.fname = "";
+       io.in.durable_handle_v2 = h;
+       io.in.create_guid = create_guid;
+       status = smb2_create(tree2, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED);
+       TALLOC_FREE(tree2);
+
+       /*
+        * but a durable reconnect on the new session succeeds:
+        */
+
+       ZERO_STRUCT(io);
+       io.in.fname = "";
+       io.in.durable_handle_v2 = h;
+       io.in.create_guid = create_guid;
+       status = smb2_create(tree3, mem_ctx, &io);
+       CHECK_STATUS(status, NT_STATUS_OK);
+       CHECK_CREATED(&io, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b"));
+       CHECK_VAL(io.out.durable_open, false);
+       CHECK_VAL(io.out.durable_open_v2, false); /* no dh2q response blob */
+       CHECK_VAL(io.out.persistent_open, false);
+       CHECK_VAL(io.out.timeout, io.in.timeout);
+       _h = io.out.file.handle;
+       h = &_h;
+
 done:
        if (tree == NULL) {
                tree = tree2;
        }
 
+       if (tree == NULL) {
+               tree = tree3;
+       }
+
        if (tree != NULL) {
                if (h != NULL) {
                        smb2_util_close(tree, *h);