]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:torture/smb2: let bench.c tests use the initial connection of just once is needed
authorStefan Metzmacher <metze@samba.org>
Mon, 15 Dec 2025 13:42:10 +0000 (14:42 +0100)
committerVolker Lendecke <vl@samba.org>
Fri, 16 Jan 2026 15:47:31 +0000 (15:47 +0000)
This makes it easier to analyze wireshark traces,
it will be important for smbdirect over roce, as
wireshark has some problems there.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source4/torture/smb2/bench.c

index 08b9ab513ac5019f3b733f5374c9b4af49284a63..ccf519ca83d60943747ccda4fc1666d0184cc51b 100644 (file)
@@ -403,11 +403,20 @@ static bool test_smb2_bench_echo(struct torture_context *tctx,
                state->conns[i].state = state;
                state->conns[i].idx = i;
 
-               if (!torture_smb2_connection(tctx, &ct)) {
-                       torture_comment(tctx, "Failed opening %zu/%zu connections\n", i, state->num_conns);
-                       return false;
+               if (state->num_conns == 1) {
+                       /*
+                        * Use the existing connection
+                        */
+                       state->conns[i].tree = ct = tree;
+               } else {
+                       if (!torture_smb2_connection(tctx, &ct)) {
+                               torture_comment(tctx,
+                                       "Failed opening %zu/%zu connections\n",
+                                       i, state->num_conns);
+                               return false;
+                       }
+                       state->conns[i].tree = talloc_steal(state->conns, ct);
                }
-               state->conns[i].tree = talloc_steal(state->conns, ct);
 
                smb2cli_conn_set_max_credits(ct->session->transport->conn, 8192);
                smb2cli_ioctl(ct->session->transport->conn,
@@ -885,11 +894,20 @@ bool test_smb2_bench_path_contention_shared(struct torture_context *tctx,
                state->conns[i].state = state;
                state->conns[i].idx = i;
 
-               if (!torture_smb2_connection(tctx, &ct)) {
-                       torture_comment(tctx, "Failed opening %zd/%zd connections\n", i, state->num_conns);
-                       return false;
+               if (state->num_conns == 1) {
+                       /*
+                        * Use the existing connection
+                        */
+                       state->conns[i].tree = ct = tree;
+               } else {
+                       if (!torture_smb2_connection(tctx, &ct)) {
+                               torture_comment(tctx,
+                                       "Failed opening %zu/%zu connections\n",
+                                       i, state->num_conns);
+                               return false;
+                       }
+                       state->conns[i].tree = talloc_steal(state->conns, ct);
                }
-               state->conns[i].tree = talloc_steal(state->conns, ct);
 
                smb2cli_conn_set_max_credits(ct->session->transport->conn, 8192);
                smb2cli_ioctl(ct->session->transport->conn,
@@ -1265,11 +1283,20 @@ static bool test_smb2_bench_read(struct torture_context *tctx,
                state->conns[i].state = state;
                state->conns[i].idx = i;
 
-               if (!torture_smb2_connection(tctx, &ct)) {
-                       torture_comment(tctx, "Failed opening %zu/%zu connections\n", i, state->num_conns);
-                       return false;
+               if (state->num_conns == 1) {
+                       /*
+                        * Use the existing connection
+                        */
+                       state->conns[i].tree = ct = tree;
+               } else {
+                       if (!torture_smb2_connection(tctx, &ct)) {
+                               torture_comment(tctx,
+                                       "Failed opening %zu/%zu connections\n",
+                                       i, state->num_conns);
+                               return false;
+                       }
+                       state->conns[i].tree = talloc_steal(state->conns, ct);
                }
-               state->conns[i].tree = talloc_steal(state->conns, ct);
 
                smb2cli_conn_set_max_credits(ct->session->transport->conn, 8192);
                smb2cli_ioctl(ct->session->transport->conn,
@@ -1784,11 +1811,20 @@ static bool test_smb2_bench_session_setup(struct torture_context *tctx,
                state->conns[i].state = state;
                state->conns[i].idx = i;
 
-               if (!torture_smb2_connection(tctx, &ct)) {
-                       torture_comment(tctx, "Failed opening %zd/%zd connections\n", i, state->num_conns);
-                       return false;
+               if (state->num_conns == 1) {
+                       /*
+                        * Use the existing connection
+                        */
+                       ct = tree;
+               } else {
+                       if (!torture_smb2_connection(tctx, &ct)) {
+                               torture_comment(tctx,
+                                       "Failed opening %zu/%zu connections\n",
+                                       i, state->num_conns);
+                               return false;
+                       }
+                       talloc_steal(state->conns, ct);
                }
-               talloc_steal(state->conns, ct);
                state->conns[i].transport = ct->session->transport;
 
                smb2cli_conn_set_max_credits(ct->session->transport->conn, 8192);