summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2016-09-28 21:23:20 +0200
committerJeremy Allison <jra@samba.org>2019-04-19 17:27:12 +0000
commit7a73c56907f5f56d989a37703865c15422cce233 (patch)
tree9d40922fca052f024070cf7a3251f012f3b9fc4d /source4
parent8274303f3023af1f80e353af552646b2158c4df9 (diff)
downloadsamba-7a73c56907f5f56d989a37703865c15422cce233.tar.gz
s4-torture: move oplock break handler out of the replay testsuite.
Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/smb2/oplock_break_handler.c91
-rw-r--r--source4/torture/smb2/oplock_break_handler.h51
-rw-r--r--source4/torture/smb2/replay.c78
-rw-r--r--source4/torture/smb2/wscript_build1
4 files changed, 144 insertions, 77 deletions
diff --git a/source4/torture/smb2/oplock_break_handler.c b/source4/torture/smb2/oplock_break_handler.c
new file mode 100644
index 00000000000..30863a9167e
--- /dev/null
+++ b/source4/torture/smb2/oplock_break_handler.c
@@ -0,0 +1,91 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * test suite for SMB2 replay
+ *
+ * Copyright (C) Anubhav Rakshit 2014
+ * Copyright (C) Stefan Metzmacher 2014
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "../libcli/smb/smbXcli_base.h"
+#include "oplock_break_handler.h"
+
+struct break_info break_info;
+
+static void torture_oplock_ack_callback(struct smb2_request *req)
+{
+ NTSTATUS status;
+
+ status = smb2_break_recv(req, &break_info.br);
+ if (!NT_STATUS_IS_OK(status)) {
+ break_info.failures++;
+ break_info.failure_status = status;
+ }
+}
+
+/**
+ * A general oplock break notification handler. This should be used when a
+ * test expects to break from batch or exclusive to a lower level.
+ */
+
+bool torture_oplock_ack_handler(struct smb2_transport *transport,
+ const struct smb2_handle *handle,
+ uint8_t level,
+ void *private_data)
+{
+ struct smb2_tree *tree = private_data;
+ const char *name;
+ struct smb2_request *req;
+
+ ZERO_STRUCT(break_info.br);
+
+ break_info.handle = *handle;
+ break_info.level = level;
+ break_info.count++;
+
+ switch (level) {
+ case SMB2_OPLOCK_LEVEL_II:
+ name = "level II";
+ break;
+ case SMB2_OPLOCK_LEVEL_NONE:
+ name = "none";
+ break;
+ default:
+ name = "unknown";
+ break_info.failures++;
+ }
+ torture_comment(break_info.tctx,
+ "transport[%p] Acking to %s [0x%02X] in oplock handler\n",
+ transport, name, level);
+
+ break_info.br.in.file.handle = *handle;
+ break_info.br.in.oplock_level = level;
+ break_info.br.in.reserved = 0;
+ break_info.br.in.reserved2 = 0;
+ break_info.received_transport = tree->session->transport;
+ SMB_ASSERT(tree->session->transport == transport);
+
+ req = smb2_break_send(tree, &break_info.br);
+ req->async.fn = torture_oplock_ack_callback;
+ req->async.private_data = NULL;
+
+ return true;
+}
diff --git a/source4/torture/smb2/oplock_break_handler.h b/source4/torture/smb2/oplock_break_handler.h
new file mode 100644
index 00000000000..78bba103fb2
--- /dev/null
+++ b/source4/torture/smb2/oplock_break_handler.h
@@ -0,0 +1,51 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * test suite for SMB2 replay
+ *
+ * Copyright (C) Anubhav Rakshit 2014
+ * Copyright (C) Stefan Metzmacher 2014
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __OPLOCK_BREAK_HANDLER_H__
+#define __OPLOCK_BREAK_HANDLER_H__
+
+struct break_info {
+ struct torture_context *tctx;
+ struct smb2_handle handle;
+ uint8_t level;
+ struct smb2_break br;
+ int count;
+ int failures;
+ NTSTATUS failure_status;
+ struct smb2_transport *received_transport;
+};
+
+extern struct break_info break_info;
+
+bool torture_oplock_ack_handler(struct smb2_transport *transport,
+ const struct smb2_handle *handle,
+ uint8_t level,
+ void *private_data);
+
+static inline void torture_reset_break_info(struct torture_context *tctx,
+ struct break_info *r)
+{
+ ZERO_STRUCTP(r);
+ r->tctx = tctx;
+}
+
+#endif /* __OPLOCK_BREAK_HANDLER_H__ */
diff --git a/source4/torture/smb2/replay.c b/source4/torture/smb2/replay.c
index 57c7bef2d66..903adc6798f 100644
--- a/source4/torture/smb2/replay.c
+++ b/source4/torture/smb2/replay.c
@@ -32,6 +32,7 @@
#include "libcli/resolve/resolve.h"
#include "lib/param/param.h"
#include "lib/events/events.h"
+#include "oplock_break_handler.h"
#define CHECK_VAL(v, correct) do { \
if ((v) != (correct)) { \
@@ -93,83 +94,6 @@
#define BASEDIR "replaytestdir"
-struct break_info {
- struct torture_context *tctx;
- struct smb2_handle handle;
- uint8_t level;
- struct smb2_break br;
- int count;
- int failures;
- NTSTATUS failure_status;
-};
-
-static struct break_info break_info;
-
-static void torture_reset_break_info(struct torture_context *tctx,
- struct break_info *r)
-{
- ZERO_STRUCTP(r);
- r->tctx = tctx;
-}
-
-static void torture_oplock_ack_callback(struct smb2_request *req)
-{
- NTSTATUS status;
-
- status = smb2_break_recv(req, &break_info.br);
- if (!NT_STATUS_IS_OK(status)) {
- break_info.failures++;
- break_info.failure_status = status;
- }
-
- return;
-}
-
-/**
- * A general oplock break notification handler. This should be used when a
- * test expects to break from batch or exclusive to a lower level.
- */
-static bool torture_oplock_ack_handler(struct smb2_transport *transport,
- const struct smb2_handle *handle,
- uint8_t level,
- void *private_data)
-{
- struct smb2_tree *tree = private_data;
- const char *name;
- struct smb2_request *req;
-
- ZERO_STRUCT(break_info.br);
-
- break_info.handle = *handle;
- break_info.level = level;
- break_info.count++;
-
- switch (level) {
- case SMB2_OPLOCK_LEVEL_II:
- name = "level II";
- break;
- case SMB2_OPLOCK_LEVEL_NONE:
- name = "none";
- break;
- default:
- name = "unknown";
- break_info.failures++;
- }
- torture_comment(break_info.tctx,
- "Acking to %s [0x%02X] in oplock handler\n",
- name, level);
-
- break_info.br.in.file.handle = *handle;
- break_info.br.in.oplock_level = level;
- break_info.br.in.reserved = 0;
- break_info.br.in.reserved2 = 0;
-
- req = smb2_break_send(tree, &break_info.br);
- req->async.fn = torture_oplock_ack_callback;
- req->async.private_data = NULL;
- return true;
-}
-
/**
* Timer handler function notifies the registering function that time is up
*/
diff --git a/source4/torture/smb2/wscript_build b/source4/torture/smb2/wscript_build
index e10d3d90ba5..1183cb93772 100644
--- a/source4/torture/smb2/wscript_build
+++ b/source4/torture/smb2/wscript_build
@@ -20,6 +20,7 @@ bld.SAMBA_MODULE('TORTURE_SMB2',
maxfid.c
maxwrite.c
multichannel.c
+ oplock_break_handler.c
notify.c
notify_disabled.c
oplock.c