From 4e685895ea1395c53c1ef68259760a1aaf2a7fc1 Mon Sep 17 00:00:00 2001 From: Sachin Prabhu Date: Sat, 16 Mar 2019 12:25:07 +0000 Subject: [PATCH] s4-torture: Add handlers to ignore incoming oplock/lease break requests For use in multichannel oplock break tests. These handers ignore incoming oplock and lease break requests so that we can test the oplock/lease break retries on the server. This is meant for use with samba servers which rely on receiving a reply from the client before timeout. Windows servers rely on underlying tcp commands to decide if the oplock break command was delivered successfully to the client and therefore cannot be tested with this method. Signed-off-by: Sachin Prabhu Reviewed-by: Guenther Deschner Reviewed-by: Jeremy Allison --- source4/torture/smb2/lease_break_handler.c | 12 ++++++++++++ source4/torture/smb2/lease_break_handler.h | 3 +++ source4/torture/smb2/oplock_break_handler.c | 10 ++++++++++ source4/torture/smb2/oplock_break_handler.h | 4 ++++ 4 files changed, 29 insertions(+) diff --git a/source4/torture/smb2/lease_break_handler.c b/source4/torture/smb2/lease_break_handler.c index 5f8e325d63f..8e576391eb1 100644 --- a/source4/torture/smb2/lease_break_handler.c +++ b/source4/torture/smb2/lease_break_handler.c @@ -72,6 +72,18 @@ bool torture_lease_handler(struct smb2_transport *transport, return true; } +/* + * A lease break handler which ignores incoming lease break requests + * To be used in cases where the client is expected to ignore incoming + * lease break requests + */ +bool torture_lease_ignore_handler(struct smb2_transport *transport, + const struct smb2_lease_break *lb, + void *private_data) +{ + return true; +} + /* Timer handler function notifies the registering function that time is up */ diff --git a/source4/torture/smb2/lease_break_handler.h b/source4/torture/smb2/lease_break_handler.h index 1e915e27951..90fde1a9217 100644 --- a/source4/torture/smb2/lease_break_handler.h +++ b/source4/torture/smb2/lease_break_handler.h @@ -121,6 +121,9 @@ extern struct lease_break_info lease_break_info; bool torture_lease_handler(struct smb2_transport *transport, const struct smb2_lease_break *lb, void *private_data); +bool torture_lease_ignore_handler(struct smb2_transport *transport, + const struct smb2_lease_break *lb, + void *private_data); void torture_wait_for_lease_break(struct torture_context *tctx); static inline void torture_reset_lease_break_info(struct torture_context *tctx, diff --git a/source4/torture/smb2/oplock_break_handler.c b/source4/torture/smb2/oplock_break_handler.c index 1b207810658..de46eb32f2a 100644 --- a/source4/torture/smb2/oplock_break_handler.c +++ b/source4/torture/smb2/oplock_break_handler.c @@ -91,6 +91,16 @@ bool torture_oplock_ack_handler(struct smb2_transport *transport, return true; } +/** + * A oplock break handler designed to ignore incoming break requests. + * This is used when incoming oplock break requests need to be ignored + */ +bool torture_oplock_ignore_handler(struct smb2_transport *transport, + const struct smb2_handle *handle, + uint8_t level, void *private_data) +{ + return true; +} /* * Timer handler function notifies the registering function that time is up diff --git a/source4/torture/smb2/oplock_break_handler.h b/source4/torture/smb2/oplock_break_handler.h index 6b1eeb14b63..3286ddbe443 100644 --- a/source4/torture/smb2/oplock_break_handler.h +++ b/source4/torture/smb2/oplock_break_handler.h @@ -40,6 +40,10 @@ bool torture_oplock_ack_handler(struct smb2_transport *transport, const struct smb2_handle *handle, uint8_t level, void *private_data); +bool torture_oplock_ignore_handler(struct smb2_transport *transport, + const struct smb2_handle *handle, + uint8_t level, + void *private_data); void torture_wait_for_oplock_break(struct torture_context *tctx); static inline void torture_reset_break_info(struct torture_context *tctx, -- 2.34.1