s3:smbd: pass smbXsrv_client to downgrade_lease()
authorStefan Metzmacher <metze@samba.org>
Tue, 2 Jun 2020 14:33:23 +0000 (16:33 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 8 Jul 2020 15:54:40 +0000 (15:54 +0000)
This prepares for multichannel support, where breaks are not bound
to a single connection.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11897

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
source3/smbd/oplock.c
source3/smbd/proto.h
source3/smbd/smb2_break.c

index 1c1510f3aabccc95dc11b4e03a13f8ae151a59e6..fce604ded0674f64bb0911b4df7f8b65b94a51d3 100644 (file)
@@ -335,7 +335,7 @@ static void lease_timeout_handler(struct tevent_context *ctx,
 
        DEBUG(1, ("lease break timed out for file %s -- replying anyway\n",
                  fsp_str_dbg(fsp)));
-       (void)downgrade_lease(lease->sconn->client->connections,
+       (void)downgrade_lease(lease->sconn->client,
                        1,
                        &fsp->file_id,
                        &lease->lease.lease_key,
@@ -409,7 +409,7 @@ bool fsp_lease_update(struct files_struct *fsp)
 
 struct downgrade_lease_additional_state {
        struct tevent_immediate *im;
-       struct smbXsrv_connection *xconn;
+       struct smbXsrv_client *client;
        uint32_t break_flags;
        struct smb2_lease_key lease_key;
        uint32_t break_from;
@@ -424,7 +424,7 @@ static void downgrade_lease_additional_trigger(struct tevent_context *ev,
        struct downgrade_lease_additional_state *state =
                talloc_get_type_abort(private_data,
                struct downgrade_lease_additional_state);
-       struct smbXsrv_connection *xconn = state->xconn;
+       struct smbXsrv_connection *xconn = state->client->connections;
        NTSTATUS status;
 
        status = smbd_smb2_send_lease_break(xconn,
@@ -435,8 +435,8 @@ static void downgrade_lease_additional_trigger(struct tevent_context *ev,
                                            state->break_to);
        TALLOC_FREE(state);
        if (!NT_STATUS_IS_OK(status)) {
-               smbd_server_connection_terminate(xconn,
-                                                nt_errstr(status));
+               smbd_server_disconnect_client(state->client,
+                                             nt_errstr(status));
                return;
        }
 }
@@ -475,12 +475,13 @@ static void fsps_lease_update(struct smbd_server_connection *sconn,
        files_forall(sconn, fsps_lease_update_fn, &state);
 }
 
-NTSTATUS downgrade_lease(struct smbXsrv_connection *xconn,
+NTSTATUS downgrade_lease(struct smbXsrv_client *client,
                         uint32_t num_file_ids,
                         const struct file_id *ids,
                         const struct smb2_lease_key *key,
                         uint32_t lease_state)
 {
+       struct smbXsrv_connection *xconn = client->connections;
        struct smbd_server_connection *sconn = xconn->client->sconn;
        const struct GUID *client_guid = NULL;
        struct share_mode_lock *lck;
@@ -565,7 +566,7 @@ NTSTATUS downgrade_lease(struct smbXsrv_connection *xconn,
                        breaking_to_requested |= SMB2_LEASE_READ;
                }
 
-               state = talloc_zero(xconn,
+               state = talloc_zero(client,
                                    struct downgrade_lease_additional_state);
                if (state == NULL) {
                        TALLOC_FREE(lck);
@@ -579,7 +580,7 @@ NTSTATUS downgrade_lease(struct smbXsrv_connection *xconn,
                        return NT_STATUS_NO_MEMORY;
                }
 
-               state->xconn = xconn;
+               state->client = client;
                state->lease_key = *key;
                state->break_from = current_state;
                state->break_to = breaking_to_requested;
index 118e926b55f8bf929e5f361f725d08fc2bd53c12..7d59ca5242f7269652340431d6ce658d52c4d363 100644 (file)
@@ -48,6 +48,7 @@
 
 /* The following definitions come from smbd/signing.c  */
 
+struct smbXsrv_client;
 struct smbXsrv_connection;
 struct dcesrv_context;
 
@@ -781,7 +782,7 @@ NTSTATUS set_file_oplock(files_struct *fsp);
 bool remove_oplock(files_struct *fsp);
 bool downgrade_oplock(files_struct *fsp);
 bool fsp_lease_update(struct files_struct *fsp);
-NTSTATUS downgrade_lease(struct smbXsrv_connection *xconn,
+NTSTATUS downgrade_lease(struct smbXsrv_client *client,
                        uint32_t num_file_ids,
                        const struct file_id *ids,
                        const struct smb2_lease_key *key,
index 2ab55aa872042810eb275aa927e50384c6686520..02ccac972e2763202054f2b7db49c92f306caa5e 100644 (file)
@@ -399,7 +399,7 @@ static struct tevent_req *smbd_smb2_lease_break_send(
                return tevent_req_post(req, ev);
        }
 
-       status = downgrade_lease(smb2_req->xconn,
+       status = downgrade_lease(smb2_req->xconn->client,
                                lls.num_file_ids,
                                lls.ids,
                                &in_lease_key,