s4-torture: add iptables filtering for multichannel oplock break test.
authorGünther Deschner <gd@samba.org>
Thu, 21 Sep 2017 16:24:26 +0000 (18:24 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 25 Jun 2018 12:56:39 +0000 (14:56 +0200)
This test demonstrates that Windows (2012R2) will *NOT* retry oplock break
requests over other channels in one multichannel session.

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Pair-Programmed-With: Jose A. Rivera <jarrpa@samba.org>

source4/torture/smb2/multichannel.c

index a97cceff5551070c636495e05e1fc3013d68d43b..3d1d3413e2788b920fac502a6a28f612c7a92304 100644 (file)
@@ -38,6 +38,7 @@
 #include "oplock_break_handler.h"
 #include "system/network.h"
 #include "lib/util/util_net.h"
+#include "torture/smb2/block.h"
 
 #define BASEDIR "multichanneltestdir"
 
@@ -272,6 +273,9 @@ static bool test_multichannel_oplock_break(struct torture_context *tctx,
        bool share_is_so;
        uint32_t server_capabilities;
        struct fsctl_net_iface_info info;
+       uint16_t local_port = 0;
+       bool block_ok = false;
+       bool unblock_ok = false;
 
        if (smbXcli_conn_protocol(transport1->conn) < PROTOCOL_SMB3_00) {
                torture_skip(tctx, "SMB 3.X Dialect family required for "
@@ -570,6 +574,10 @@ static bool test_multichannel_oplock_break(struct torture_context *tctx,
 
        smb2_keepalive(transport2C);
 
+       local_port = torture_get_local_port_from_transport(transport2C);
+
+       torture_comment(tctx, "transport2C uses tcp port: %d\n", local_port);
+
        torture_comment(tctx, "client2 opens fname1 via session 2A\n");
 
        /* 2a opens file1 */
@@ -640,6 +648,10 @@ static bool test_multichannel_oplock_break(struct torture_context *tctx,
 
        torture_reset_break_info(tctx, &break_info);
 
+       /* block tcp connection of transport2C */
+       block_ok = torture_block_tcp_transport(tctx, transport2C);
+       torture_assert(tctx, block_ok, "we could not block tcp transport");
+
        /*
         * 1 opens file2
         * batchoplock break?
@@ -661,8 +673,14 @@ static bool test_multichannel_oplock_break(struct torture_context *tctx,
                CHECK_VAL(io2.out.timeout, 0);
        }
        CHECK_VAL(io2.out.durable_open, false);
-       CHECK_VAL(break_info.count, 2);
-       CHECK_PTR(break_info.received_transport, transport2C);
+
+       /*
+        * Important: when filtered, Windows will really let the open succeed
+        * and *NOT* send a new oplock break over the remaining channels, thus
+        * the break info count stays at one.
+        */
+
+       CHECK_VAL(break_info.count, 1);
 
        if (h != NULL) {
                smb2_util_close(tree1, *h);
@@ -670,6 +688,11 @@ static bool test_multichannel_oplock_break(struct torture_context *tctx,
        }
 
 done:
+       if (block_ok && !unblock_ok) {
+               /* unblock tcp connection of transport2C */
+               unblock_ok = torture_unblock_tcp_transport(tctx, transport2C);
+       }
+
        tree1->session = session1;
 
        smb2_util_close(tree1, h_client1_file1);