Start to plumb smb2 into the oplock system. Calls dummy functions for now.
authorJeremy Allison <jra@samba.org>
Thu, 8 Apr 2010 02:00:44 +0000 (19:00 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 8 Apr 2010 02:00:44 +0000 (19:00 -0700)
Jeremy.

source3/smbd/globals.h
source3/smbd/oplock.c
source3/smbd/process.c
source3/smbd/smb2_break.c

index 3b58cb4ef3a9211d424fa554172215c355ab3865..f9fd71ed751afd58696b4802471b4d24fe46671e 100644 (file)
@@ -320,6 +320,9 @@ NTSTATUS smbd_smb2_request_process_getinfo(struct smbd_smb2_request *req);
 NTSTATUS smbd_smb2_request_process_setinfo(struct smbd_smb2_request *req);
 NTSTATUS smbd_smb2_request_process_break(struct smbd_smb2_request *req);
 
+void send_smb2_break_message(files_struct *fsp, uint8_t level);
+void schedule_deferred_open_smb2_message(uint16 mid);
+
 struct smbd_smb2_request {
        struct smbd_smb2_request *prev, *next;
 
index f3034bd739687254b1f8a88fe5fd914038278579..e876e8c2868d2ea3d5d8ef1efbb01b866db05019 100644 (file)
@@ -214,7 +214,7 @@ bool should_notify_deferred_opens()
  Set up an oplock break message.
 ****************************************************************************/
 
-static char *new_break_smb_message(TALLOC_CTX *mem_ctx,
+static char *new_break_smb1_message(TALLOC_CTX *mem_ctx,
                                   files_struct *fsp, uint8 cmd)
 {
        char *result = TALLOC_ARRAY(mem_ctx, char, smb_size + 8*2 + 0);
@@ -354,9 +354,30 @@ static void add_oplock_timeout_handler(files_struct *fsp)
        }
 }
 
+static void send_smb1_break_message(files_struct *fsp, uint8_t level)
+{
+       char *break_msg = new_break_smb1_message(talloc_tos(),
+                                       fsp,
+                                       level);
+       if (break_msg == NULL) {
+               exit_server("Could not talloc break_msg\n");
+       }
+
+       show_msg(break_msg);
+       if (!srv_send_smb(smbd_server_fd(),
+                       break_msg, false, 0,
+                       IS_CONN_ENCRYPTED(fsp->conn),
+                       NULL)) {
+               exit_server_cleanly("send_smb1_break_message: "
+                       "srv_send_smb failed.");
+       }
+
+       TALLOC_FREE(break_msg);
+}
+
 void break_level2_to_none_async(files_struct *fsp)
 {
-       char *break_msg;
+       struct smbd_server_connection *sconn = smbd_server_conn;
 
        if (fsp->oplock_type == NO_OPLOCK) {
                /* We already got a "break to none" message and we've handled
@@ -382,24 +403,14 @@ void break_level2_to_none_async(files_struct *fsp)
                  fsp_str_dbg(fsp)));
 
        /* Now send a break to none message to our client. */
-       break_msg = new_break_smb_message(NULL, fsp, OPLOCKLEVEL_NONE);
-       if (break_msg == NULL) {
-               exit_server("Could not talloc break_msg\n");
-       }
-
-       show_msg(break_msg);
-       if (!srv_send_smb(smbd_server_fd(),
-                       break_msg, false, 0,
-                       IS_CONN_ENCRYPTED(fsp->conn),
-                       NULL)) {
-               exit_server_cleanly("oplock_break: srv_send_smb failed.");
+       if (sconn->allow_smb2) {
+               send_smb2_break_message(fsp, OPLOCKLEVEL_NONE);
+       } else {
+               send_smb1_break_message(fsp, OPLOCKLEVEL_NONE);
        }
 
-       TALLOC_FREE(break_msg);
-
        /* Async level2 request, don't send a reply, just remove the oplock. */
        remove_oplock(fsp);
-
 }
 
 /*******************************************************************
@@ -459,9 +470,9 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
                                         struct server_id src,
                                         DATA_BLOB *data)
 {
+       struct smbd_server_connection *sconn = smbd_server_conn;
        struct share_mode_entry msg;
        files_struct *fsp;
-       char *break_msg;
        bool break_to_level2 = False;
 
        if (data->data == NULL) {
@@ -525,27 +536,20 @@ static void process_oplock_break_message(struct messaging_context *msg_ctx,
                break_to_level2 = True;
        }
 
-       break_msg = new_break_smb_message(NULL, fsp, break_to_level2 ?
-                                         OPLOCKLEVEL_II : OPLOCKLEVEL_NONE);
-       if (break_msg == NULL) {
-               exit_server("Could not talloc break_msg\n");
-       }
-
-       /* Need to wait before sending a break message if we sent ourselves this message. */
+       /* Need to wait before sending a break
+          message if we sent ourselves this message. */
        if (procid_is_me(&src)) {
                wait_before_sending_break();
        }
 
-       show_msg(break_msg);
-       if (!srv_send_smb(smbd_server_fd(),
-                       break_msg, false, 0,
-                       IS_CONN_ENCRYPTED(fsp->conn),
-                       NULL)) {
-               exit_server_cleanly("oplock_break: srv_send_smb failed.");
+       if (sconn->allow_smb2) {
+               send_smb2_break_message(fsp, break_to_level2 ?
+                       OPLOCKLEVEL_II : OPLOCKLEVEL_NONE);
+       } else {
+               send_smb1_break_message(fsp, break_to_level2 ?
+                       OPLOCKLEVEL_II : OPLOCKLEVEL_NONE);
        }
 
-       TALLOC_FREE(break_msg);
-
        fsp->sent_oplock_break = break_to_level2 ? LEVEL_II_BREAK_SENT:BREAK_TO_NONE_SENT;
 
        msg.pid = src;
@@ -566,10 +570,10 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
                                        struct server_id src,
                                        DATA_BLOB *data)
 {
+       struct smbd_server_connection *sconn = smbd_server_conn;
        struct file_id id;
        unsigned long file_id;
        files_struct *fsp;
-       char *break_msg;
 
        if (data->data == NULL) {
                DEBUG(0, ("Got NULL buffer\n"));
@@ -604,21 +608,12 @@ static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
                return;
        }
 
-       break_msg = new_break_smb_message(NULL, fsp, OPLOCKLEVEL_NONE);
-       if (break_msg == NULL) {
-               exit_server("Could not talloc break_msg\n");
-       }
-
-       show_msg(break_msg);
-       if (!srv_send_smb(smbd_server_fd(),
-                       break_msg, false, 0,
-                       IS_CONN_ENCRYPTED(fsp->conn),
-                       NULL)) {
-               exit_server_cleanly("oplock_break: srv_send_smb failed.");
+       if (sconn->allow_smb2) {
+               send_smb2_break_message(fsp, OPLOCKLEVEL_NONE);
+       } else {
+               send_smb1_break_message(fsp, OPLOCKLEVEL_NONE);
        }
 
-       TALLOC_FREE(break_msg);
-
        fsp->sent_oplock_break = BREAK_TO_NONE_SENT;
 
        add_oplock_timeout_handler(fsp);
index 485439a089648f76bccda6b43d3a0dcb439b6176..3e5cee83c59d81b0a35ca06df7a7bf00b8fd0660 100644 (file)
@@ -623,9 +623,15 @@ void remove_deferred_open_smb_message(uint16 mid)
 
 void schedule_deferred_open_smb_message(uint16 mid)
 {
+       struct smbd_server_connection *sconn = smbd_server_conn;
        struct pending_message_list *pml;
        int i = 0;
 
+       if (sconn->allow_smb2) {
+               schedule_deferred_open_smb2_message(mid);
+               return;
+       }
+
        for (pml = deferred_open_queue; pml; pml = pml->next) {
                uint16 msg_mid = SVAL(pml->buf.data,smb_mid);
 
index 879d59f89e7eb4928ecf57f4bd7759310209077a..5057fc1fc1310478d7ae0e3c0ee6b6a282bfbc8b 100644 (file)
@@ -208,3 +208,12 @@ static NTSTATUS smbd_smb2_oplock_break_recv(struct tevent_req *req,
        tevent_req_received(req);
        return NT_STATUS_OK;
 }
+
+void send_smb2_break_message(files_struct *fsp, uint8_t level)
+{
+}
+
+void schedule_deferred_open_smb2_message(uint16 mid)
+{
+       /* FIXME - mid needs to be uint64_t. */
+}