Add need_ack arguments to smbd_smb2_send_oplock/lease_break
authorSachin Prabhu <sprabhu@redhat.com>
Thu, 19 Sep 2019 14:45:17 +0000 (15:45 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 28 Jan 2020 12:26:51 +0000 (13:26 +0100)
This indicates if the server is expecting a response to the oplock/lease
break sent to the clients. The need_ack argument will be further used in
the upcoming patches.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
source3/smbd/globals.h
source3/smbd/oplock.c
source3/smbd/smb2_break.c
source3/smbd/smb2_server.c

index 32a403ff15e69f8ac3fe87cc78ac0f844a9b209b..bdea81868133ab17583159b256969db3f08ee9e7 100644 (file)
@@ -259,13 +259,12 @@ NTSTATUS smbd_smb2_send_oplock_break(struct smbXsrv_connection *xconn,
                                     struct smbXsrv_session *session,
                                     struct smbXsrv_tcon *tcon,
                                     struct smbXsrv_open *op,
                                     struct smbXsrv_session *session,
                                     struct smbXsrv_tcon *tcon,
                                     struct smbXsrv_open *op,
-                                    uint8_t oplock_level);
+                                    uint8_t oplock_level, bool need_ack);
 NTSTATUS smbd_smb2_send_lease_break(struct smbXsrv_connection *xconn,
                                    uint16_t new_epoch,
 NTSTATUS smbd_smb2_send_lease_break(struct smbXsrv_connection *xconn,
                                    uint16_t new_epoch,
-                                   uint32_t lease_flags,
                                    struct smb2_lease_key *lease_key,
                                    uint32_t current_lease_state,
                                    struct smb2_lease_key *lease_key,
                                    uint32_t current_lease_state,
-                                   uint32_t new_lease_state);
+                                   uint32_t new_lease_state, bool need_ack);
 
 NTSTATUS smbd_smb2_request_pending_queue(struct smbd_smb2_request *req,
                                         struct tevent_req *subreq,
 
 NTSTATUS smbd_smb2_request_pending_queue(struct smbd_smb2_request *req,
                                         struct tevent_req *subreq,
index 2c4449b10b268ddb9d5bdfd7b5c33ca940fc9f09..c772a5765d8f68c78a79a93dca70c83709f8fee3 100644 (file)
@@ -413,10 +413,10 @@ static void downgrade_lease_additional_trigger(struct tevent_context *ev,
 
        status = smbd_smb2_send_lease_break(xconn,
                                            state->new_epoch,
 
        status = smbd_smb2_send_lease_break(xconn,
                                            state->new_epoch,
-                                           state->break_flags,
                                            &state->lease_key,
                                            state->break_from,
                                            &state->lease_key,
                                            state->break_from,
-                                           state->break_to);
+                                           state->break_to,
+                                           (state->break_flags));
        TALLOC_FREE(state);
        if (!NT_STATUS_IS_OK(status)) {
                smbd_server_connection_terminate(xconn,
        TALLOC_FREE(state);
        if (!NT_STATUS_IS_OK(status)) {
                smbd_server_connection_terminate(xconn,
index b79c18313c08f90d4ba2e3b64683a13372ad0257..064698ac98c2c2ac5c77f2b04a5893d6376d0027 100644 (file)
@@ -510,12 +510,8 @@ void send_break_message_smb2(files_struct *fsp,
                (unsigned int)break_to ));
 
        if (fsp->oplock_type == LEASE_OPLOCK) {
                (unsigned int)break_to ));
 
        if (fsp->oplock_type == LEASE_OPLOCK) {
-               uint32_t break_flags = 0;
                uint16_t new_epoch;
                uint16_t new_epoch;
-
-               if (fsp->lease->lease.lease_state != SMB2_LEASE_NONE) {
-                       break_flags = SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED;
-               }
+               bool need_ack = (fsp->lease->lease.lease_state != SMB2_LEASE_NONE);
 
                if (fsp->lease->lease.lease_version > 1) {
                        new_epoch = fsp->lease->lease.lease_epoch;
 
                if (fsp->lease->lease.lease_version > 1) {
                        new_epoch = fsp->lease->lease.lease_epoch;
@@ -523,18 +519,23 @@ void send_break_message_smb2(files_struct *fsp,
                        new_epoch = 0;
                }
 
                        new_epoch = 0;
                }
 
-               status = smbd_smb2_send_lease_break(xconn, new_epoch, break_flags,
+               status = smbd_smb2_send_lease_break(xconn,
+                                                   new_epoch,
                                                    &fsp->lease->lease.lease_key,
                                                    &fsp->lease->lease.lease_key,
-                                                   break_from, break_to);
+                                                   break_from, break_to, need_ack);
        } else {
                uint8_t smb2_oplock_level;
        } else {
                uint8_t smb2_oplock_level;
+               bool need_ack = true;
+
+               if (break_from == SMB2_OPLOCK_LEVEL_II) {
+                       need_ack = false;
+               }
+
                smb2_oplock_level = (break_to & SMB2_LEASE_READ) ?
                        SMB2_OPLOCK_LEVEL_II : SMB2_OPLOCK_LEVEL_NONE;
                smb2_oplock_level = (break_to & SMB2_LEASE_READ) ?
                        SMB2_OPLOCK_LEVEL_II : SMB2_OPLOCK_LEVEL_NONE;
-               status = smbd_smb2_send_oplock_break(xconn,
-                                                    session,
-                                                    fsp->conn->tcon,
-                                                    fsp->op,
-                                                    smb2_oplock_level);
+               status = smbd_smb2_send_oplock_break(xconn, session,
+                                                    fsp->conn->tcon, fsp->op,
+                                                    smb2_oplock_level, need_ack);
        }
        if (!NT_STATUS_IS_OK(status)) {
                smbd_server_connection_terminate(xconn,
        }
        if (!NT_STATUS_IS_OK(status)) {
                smbd_server_connection_terminate(xconn,
index b2748400993f4a78e24d42dfacfd78487b84a7c8..2496bcf1775234976a189b1a84122e8f5ec19b69 100644 (file)
@@ -3789,7 +3789,8 @@ NTSTATUS smbd_smb2_send_oplock_break(struct smbXsrv_connection *xconn,
                                     struct smbXsrv_session *session,
                                     struct smbXsrv_tcon *tcon,
                                     struct smbXsrv_open *op,
                                     struct smbXsrv_session *session,
                                     struct smbXsrv_tcon *tcon,
                                     struct smbXsrv_open *op,
-                                    uint8_t oplock_level)
+                                    uint8_t oplock_level,
+                                    bool need_ack)
 {
        uint8_t body[0x18];
 
 {
        uint8_t body[0x18];
 
@@ -3802,17 +3803,22 @@ NTSTATUS smbd_smb2_send_oplock_break(struct smbXsrv_connection *xconn,
 
        return smbd_smb2_send_break(xconn, NULL, NULL, body, sizeof(body),
                                    false, /* Not lease */
 
        return smbd_smb2_send_break(xconn, NULL, NULL, body, sizeof(body),
                                    false, /* Not lease */
-                                   0);
+                                   need_ack);
 }
 
 NTSTATUS smbd_smb2_send_lease_break(struct smbXsrv_connection *xconn,
                                    uint16_t new_epoch,
 }
 
 NTSTATUS smbd_smb2_send_lease_break(struct smbXsrv_connection *xconn,
                                    uint16_t new_epoch,
-                                   uint32_t lease_flags,
                                    struct smb2_lease_key *lease_key,
                                    uint32_t current_lease_state,
                                    struct smb2_lease_key *lease_key,
                                    uint32_t current_lease_state,
-                                   uint32_t new_lease_state)
+                                   uint32_t new_lease_state,
+                                   bool need_ack)
 {
        uint8_t body[0x2c];
 {
        uint8_t body[0x2c];
+       uint32_t lease_flags = 0;
+
+       if (need_ack == true) {
+               lease_flags = SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED;
+       }
 
        SSVAL(body, 0x00, sizeof(body));
        SSVAL(body, 0x02, new_epoch);
 
        SSVAL(body, 0x00, sizeof(body));
        SSVAL(body, 0x02, new_epoch);
@@ -3827,7 +3833,7 @@ NTSTATUS smbd_smb2_send_lease_break(struct smbXsrv_connection *xconn,
 
        return smbd_smb2_send_break(xconn, NULL, NULL, body, sizeof(body),
                                    true, /* Is Lease */
 
        return smbd_smb2_send_break(xconn, NULL, NULL, body, sizeof(body),
                                    true, /* Is Lease */
-                                   0);
+                                   need_ack);
 }
 
 static bool is_smb2_recvfile_write(struct smbd_smb2_request_read_state *state)
 }
 
 static bool is_smb2_recvfile_write(struct smbd_smb2_request_read_state *state)