summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-04-12 21:40:28 -0700
committerJeremy Allison <jra@samba.org>2010-04-12 21:40:28 -0700
commit79842437684be380407661fc27e64f223a326b18 (patch)
tree867b994fdc97991637d5b33fa57ba77b214c9cca /source3
parent8a2169d6749498c7929e7533f6b3c9d965b0aa3b (diff)
downloadsamba-79842437684be380407661fc27e64f223a326b18.tar.gz
samba-79842437684be380407661fc27e64f223a326b18.tar.bz2
samba-79842437684be380407661fc27e64f223a326b18.zip
Move to using 64-bit mid values in our internal open file database.
This will allow us to share logic much easier between SMB1 and SMB2 servers. Jeremy
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h24
-rw-r--r--source3/include/smb.h55
-rw-r--r--source3/locking/locking.c15
-rw-r--r--source3/modules/onefs_open.c7
-rw-r--r--source3/modules/vfs_aio_fork.c5
-rw-r--r--source3/smbd/aio.c38
-rw-r--r--source3/smbd/blocking.c4
-rw-r--r--source3/smbd/globals.h14
-rw-r--r--source3/smbd/notify.c4
-rw-r--r--source3/smbd/nttrans.c3
-rw-r--r--source3/smbd/open.c14
-rw-r--r--source3/smbd/oplock.c60
-rw-r--r--source3/smbd/oplock_onefs.c16
-rw-r--r--source3/smbd/process.c73
-rw-r--r--source3/smbd/smb2_glue.c22
15 files changed, 188 insertions, 166 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index bd81690702..f1cba8ffa2 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3510,12 +3510,12 @@ bool is_valid_share_mode_entry(const struct share_mode_entry *e);
bool is_deferred_open_entry(const struct share_mode_entry *e);
bool is_unused_share_mode_entry(const struct share_mode_entry *e);
void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
- uid_t uid, uint16 mid, uint16 op_type);
-void add_deferred_open(struct share_mode_lock *lck, uint16 mid,
+ uid_t uid, uint64_t mid, uint16 op_type);
+void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
struct timeval request_time,
struct file_id id);
bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
-void del_deferred_open_entry(struct share_mode_lock *lck, uint16 mid);
+void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid);
bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode);
@@ -6090,7 +6090,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
size_t numtowrite);
int wait_for_aio_completion(files_struct *fsp);
void cancel_aio_by_fsp(files_struct *fsp);
-void smbd_aio_complete_mid(unsigned int mid);
+void smbd_aio_complete_mid(uint64_t mid);
/* The following definitions come from smbd/blocking.c */
@@ -6107,8 +6107,8 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
uint64_t count,
uint32 blocking_pid);
void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lock *br_lck);
-void remove_pending_lock_requests_by_mid(int mid);
-bool blocking_lock_was_deferred(int mid);
+void remove_pending_lock_requests_by_mid(uint64_t mid);
+bool blocking_lock_was_deferred(uint64_t mid);
struct blocking_lock_record *blocking_lock_cancel(files_struct *fsp,
uint32 lock_pid,
uint64_t offset,
@@ -6547,7 +6547,7 @@ NTSTATUS change_notify_add_request(struct smb_request *req,
void (*reply_fn)(struct smb_request *req,
NTSTATUS error_code,
uint8_t *buf, size_t len));
-void remove_pending_change_notify_requests_by_mid(uint16 mid);
+void remove_pending_change_notify_requests_by_mid(uint64_t mid);
void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
NTSTATUS status);
void notify_fname(connection_struct *conn, uint32 action, uint32 filter,
@@ -6808,10 +6808,10 @@ int srv_set_message(char *buf,
int num_words,
int num_bytes,
bool zero);
-void remove_deferred_open_message_smb(uint16_t mid);
-void schedule_deferred_open_message_smb(uint16_t mid);
-bool open_was_deferred(uint16_t mid);
-bool get_deferred_open_message_state(uint16_t mid,
+void remove_deferred_open_message_smb(uint64_t mid);
+void schedule_deferred_open_message_smb(uint64_t mid);
+bool open_was_deferred(uint64_t mid);
+bool get_deferred_open_message_state(uint64_t mid,
struct timeval *p_request_time,
void **pp_state);
bool push_deferred_open_message_smb(struct smb_request *req,
@@ -6825,7 +6825,7 @@ struct idle_event *event_add_idle(struct event_context *event_ctx,
bool (*handler)(const struct timeval *now,
void *private_data),
void *private_data);
-NTSTATUS allow_new_trans(struct trans_state *list, int mid);
+NTSTATUS allow_new_trans(struct trans_state *list, uint64_t mid);
void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes);
const char *smb_fn_name(int type);
void add_to_common_flags2(uint32 v);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 853ced0aa6..19e45edf70 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -496,7 +496,7 @@ typedef struct {
struct trans_state {
struct trans_state *next, *prev;
uint16 vuid;
- uint16 mid;
+ uint64_t mid;
uint32 max_param_return;
uint32 max_data_return;
@@ -629,7 +629,7 @@ struct smb_request {
uint8_t cmd;
uint16 flags2;
uint16 smbpid;
- uint16 mid;
+ uint64_t mid; /* For compatibility with SMB2. */
uint32_t seqnum;
uint16 vuid;
uint16 tid;
@@ -751,7 +751,7 @@ struct pending_message_list {
/* struct returned by get_share_modes */
struct share_mode_entry {
struct server_id pid;
- uint16 op_mid;
+ uint64_t op_mid; /* For compatibility with SMB2 opens. */
uint16 op_type;
uint32 access_mask; /* NTCreateX access bits (FILE_READ_DATA etc.) */
uint32 share_access; /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */
@@ -770,26 +770,43 @@ struct share_mode_entry {
Offset Data length.
0 struct server_id pid 4
-4 uint16 op_mid 2
-6 uint16 op_type 2
-8 uint32 access_mask 4
-12 uint32 share_access 4
-16 uint32 private_options 4
-20 uint32 time sec 4
-24 uint32 time usec 4
-28 uint64 dev 8 bytes
-36 uint64 inode 8 bytes
-44 uint64 extid 8 bytes
-52 unsigned long file_id 4 bytes
-56 uint32 uid 4 bytes
-60 uint16 flags 2 bytes
-62
+4 uint16 op_mid 8
+12 uint16 op_type 2
+14 uint32 access_mask 4
+18 uint32 share_access 4
+22 uint32 private_options 4
+26 uint32 time sec 4
+30 uint32 time usec 4
+34 uint64 dev 8 bytes
+42 uint64 inode 8 bytes
+50 uint64 extid 8 bytes
+58 unsigned long file_id 4 bytes
+62 uint32 uid 4 bytes
+66 uint16 flags 2 bytes
+68
*/
+
+#define OP_BREAK_MSG_PID_OFFSET 0
+#define OP_BREAK_MSG_MID_OFFSET 4
+#define OP_BREAK_MSG_OP_TYPE_OFFSET 12
+#define OP_BREAK_MSG_ACCESS_MASK_OFFSET 14
+#define OP_BREAK_MSG_SHARE_ACCESS_OFFSET 18
+#define OP_BREAK_MSG_PRIV_OFFSET 22
+#define OP_BREAK_MSG_TIME_SEC_OFFSET 26
+#define OP_BREAK_MSG_TIME_USEC_OFFSET 30
+#define OP_BREAK_MSG_DEV_OFFSET 34
+#define OP_BREAK_MSG_INO_OFFSET 42
+#define OP_BREAK_MSG_EXTID_OFFSET 50
+#define OP_BREAK_MSG_FILE_ID_OFFSET 58
+#define OP_BREAK_MSG_UID_OFFSET 62
+#define OP_BREAK_MSG_FLAGS_OFFSET 66
+
#ifdef CLUSTER_SUPPORT
-#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 66
+#define OP_BREAK_MSG_VNN_OFFSET 68
+#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 72
#else
-#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 62
+#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 68
#endif
struct share_mode_lock {
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 1ada13ecad..a2581b1b96 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -480,13 +480,14 @@ char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e)
{
return talloc_asprintf(ctx, "share_mode_entry[%d]: %s "
"pid = %s, share_access = 0x%x, private_options = 0x%x, "
- "access_mask = 0x%x, mid = 0x%x, type= 0x%x, gen_id = %lu, "
+ "access_mask = 0x%x, mid = 0x%llx, type= 0x%x, gen_id = %lu, "
"uid = %u, flags = %u, file_id %s",
num,
e->op_type == UNUSED_SHARE_MODE_ENTRY ? "UNUSED" : "",
procid_str_static(&e->pid),
e->share_access, e->private_options,
- e->access_mask, e->op_mid, e->op_type, e->share_file_id,
+ e->access_mask, (unsigned long long)e->op_mid,
+ e->op_type, e->share_file_id,
(unsigned int)e->uid, (unsigned int)e->flags,
file_id_string_tos(&e->id));
}
@@ -1098,7 +1099,7 @@ bool is_unused_share_mode_entry(const struct share_mode_entry *e)
static void fill_share_mode_entry(struct share_mode_entry *e,
files_struct *fsp,
- uid_t uid, uint16 mid, uint16 op_type)
+ uid_t uid, uint64_t mid, uint16 op_type)
{
ZERO_STRUCTP(e);
e->pid = procid_self();
@@ -1117,7 +1118,7 @@ static void fill_share_mode_entry(struct share_mode_entry *e,
static void fill_deferred_open_entry(struct share_mode_entry *e,
const struct timeval request_time,
- struct file_id id, uint16 mid)
+ struct file_id id, uint64_t mid)
{
ZERO_STRUCTP(e);
e->pid = procid_self();
@@ -1152,14 +1153,14 @@ static void add_share_mode_entry(struct share_mode_lock *lck,
}
void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
- uid_t uid, uint16 mid, uint16 op_type)
+ uid_t uid, uint64_t mid, uint16 op_type)
{
struct share_mode_entry entry;
fill_share_mode_entry(&entry, fsp, uid, mid, op_type);
add_share_mode_entry(lck, &entry);
}
-void add_deferred_open(struct share_mode_lock *lck, uint16 mid,
+void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
struct timeval request_time,
struct file_id id)
{
@@ -1238,7 +1239,7 @@ bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp)
return True;
}
-void del_deferred_open_entry(struct share_mode_lock *lck, uint16 mid)
+void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid)
{
struct share_mode_entry entry, *e;
diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c
index eb22584772..b0c88c71bf 100644
--- a/source3/modules/onefs_open.c
+++ b/source3/modules/onefs_open.c
@@ -358,7 +358,8 @@ static void defer_open(struct share_mode_lock *lck,
if (procid_is_me(&e->pid) && (e->op_mid == req->mid)) {
DEBUG(0, ("Trying to defer an already deferred "
- "request: mid=%d, exiting\n", req->mid));
+ "request: mid=%llu, exiting\n",
+ (unsigned long long)req->mid));
exit_server("attempt to defer a deferred request");
}
}
@@ -366,10 +367,10 @@ static void defer_open(struct share_mode_lock *lck,
/* End paranoia check */
DEBUG(10,("defer_open_sharing_error: time [%u.%06u] adding deferred "
- "open entry for mid %u\n",
+ "open entry for mid %llu\n",
(unsigned int)request_time.tv_sec,
(unsigned int)request_time.tv_usec,
- (unsigned int)req->mid));
+ (unsigned long long)req->mid));
if (!push_deferred_open_message_smb(req, request_time, timeout,
(char *)state, sizeof(*state))) {
diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c
index ebad4b4c43..8fd89362bc 100644
--- a/source3/modules/vfs_aio_fork.c
+++ b/source3/modules/vfs_aio_fork.c
@@ -383,7 +383,7 @@ static void handle_aio_completion(struct event_context *event_ctx,
void *p)
{
struct aio_child *child = (struct aio_child *)p;
- uint16 mid;
+ uint64_t mid;
DEBUG(10, ("handle_aio_completion called with flags=%d\n", flags));
@@ -411,7 +411,8 @@ static void handle_aio_completion(struct event_context *event_ctx,
child->retval.size);
}
- mid = child->aiocb->aio_sigevent.sigev_value.sival_int;
+ /* FIXME - this won't work for SMB2. */
+ mid = (uint64_t)child->aiocb->aio_sigevent.sigev_value.sival_int;
DEBUG(10, ("mid %d finished\n", (int)mid));
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index e172b27d5a..b775977a72 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -45,7 +45,9 @@ static void smbd_aio_signal_handler(struct tevent_context *ev_ctx,
void *_info, void *private_data)
{
siginfo_t *info = (siginfo_t *)_info;
- unsigned int mid = (unsigned int)info->si_value.sival_int;
+ /* This won't work for SMB2.
+ * We need a mapping table from sival_int -> uint64_t mid. */
+ uint64_t mid = (uint64_t)info->si_value.sival_int;
smbd_aio_complete_mid(mid);
}
@@ -126,7 +128,7 @@ static struct aio_extra *create_aio_extra(files_struct *fsp, size_t buflen)
Given the mid find the extended aio struct containing it.
*****************************************************************************/
-static struct aio_extra *find_aio_ex(uint16 mid)
+static struct aio_extra *find_aio_ex(uint64_t mid)
{
struct aio_extra *p;
@@ -546,9 +548,10 @@ static bool handle_aio_completed(struct aio_extra *aio_ex, int *perr)
/* Ensure the operation has really completed. */
err = SMB_VFS_AIO_ERROR(fsp, &aio_ex->acb);
if (err == EINPROGRESS) {
- DEBUG(10,( "handle_aio_completed: operation mid %u still in "
- "process for file %s\n",
- aio_ex->req->mid, fsp_str_dbg(aio_ex->fsp)));
+ DEBUG(10,( "handle_aio_completed: operation mid %llu still in "
+ "process for file %s\n",
+ (unsigned long long)aio_ex->req->mid,
+ fsp_str_dbg(aio_ex->fsp)));
return False;
}
@@ -558,8 +561,9 @@ static bool handle_aio_completed(struct aio_extra *aio_ex, int *perr)
if (err == ECANCELED) {
/* If error is ECANCELED then don't return anything to the
* client. */
- DEBUG(10,( "handle_aio_completed: operation mid %u"
- " canceled\n", aio_ex->req->mid));
+ DEBUG(10,( "handle_aio_completed: operation mid %llu"
+ " canceled\n",
+ (unsigned long long)aio_ex->req->mid));
return True;
}
@@ -575,7 +579,7 @@ static bool handle_aio_completed(struct aio_extra *aio_ex, int *perr)
Handle any aio completion inline.
*****************************************************************************/
-void smbd_aio_complete_mid(unsigned int mid)
+void smbd_aio_complete_mid(uint64_t mid)
{
files_struct *fsp = NULL;
struct aio_extra *aio_ex = find_aio_ex(mid);
@@ -583,11 +587,13 @@ void smbd_aio_complete_mid(unsigned int mid)
outstanding_aio_calls--;
- DEBUG(10,("smbd_aio_complete_mid: mid[%u]\n", mid));
+ DEBUG(10,("smbd_aio_complete_mid: mid[%llu]\n",
+ (unsigned long long)mid));
if (!aio_ex) {
DEBUG(3,("smbd_aio_complete_mid: Can't find record to "
- "match mid %u.\n", mid));
+ "match mid %llu.\n",
+ (unsigned long long)mid));
return;
}
@@ -596,7 +602,8 @@ void smbd_aio_complete_mid(unsigned int mid)
/* file was closed whilst I/O was outstanding. Just
* ignore. */
DEBUG( 3,( "smbd_aio_complete_mid: file closed whilst "
- "aio outstanding (mid[%u]).\n", mid));
+ "aio outstanding (mid[%llu]).\n",
+ (unsigned long long)mid));
return;
}
@@ -685,14 +692,15 @@ int wait_for_aio_completion(files_struct *fsp)
/* One or more events might have completed - process them if
* so. */
for( i = 0; i < aio_completion_count; i++) {
- uint16 mid = aiocb_list[i]->aio_sigevent.sigev_value.sival_int;
+ /* FIXME. Won't work for SMB2. */
+ uint64_t mid = (uint64_t)aiocb_list[i]->aio_sigevent.sigev_value.sival_int;
aio_ex = find_aio_ex(mid);
if (!aio_ex) {
- DEBUG(0, ("wait_for_aio_completion: mid %u "
+ DEBUG(0, ("wait_for_aio_completion: mid %llu "
"doesn't match an aio record\n",
- (unsigned int)mid ));
+ (unsigned long long)mid ));
continue;
}
@@ -766,6 +774,6 @@ int wait_for_aio_completion(files_struct *fsp)
return ENOSYS;
}
-void smbd_aio_complete_mid(unsigned int mid);
+void smbd_aio_complete_mid(uint64_t mid);
#endif
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 90d2f31345..d876c8b438 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -608,7 +608,7 @@ void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lo
Delete entries by mid from the blocking lock pending queue. Always send reply.
*****************************************************************************/
-void remove_pending_lock_requests_by_mid(int mid)
+void remove_pending_lock_requests_by_mid(uint64_t mid)
{
struct blocking_lock_record *blr, *next = NULL;
@@ -651,7 +651,7 @@ void remove_pending_lock_requests_by_mid(int mid)
Is this mid a blocking lock request on the queue ?
*****************************************************************************/
-bool blocking_lock_was_deferred(int mid)
+bool blocking_lock_was_deferred(uint64_t mid)
{
struct blocking_lock_record *blr, *next = NULL;
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index f08da7b9a3..864143d83a 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -332,10 +332,10 @@ bool push_blocking_lock_request_smb2( struct byte_range_lock *br_lck,
uint64_t offset,
uint64_t count,
uint32_t blocking_pid);
-void remove_deferred_open_message_smb2(uint16_t mid);
-void schedule_deferred_open_message_smb2(uint16_t mid);
-bool open_was_deferred_smb2(uint16_t mid);
-bool get_deferred_open_message_state_smb2(uint16_t mid,
+void remove_deferred_open_message_smb2(uint64_t mid);
+void schedule_deferred_open_message_smb2(uint64_t mid);
+bool open_was_deferred_smb2(uint64_t mid);
+bool get_deferred_open_message_state_smb2(uint64_t mid,
struct timeval *p_request_time,
void **pp_state);
bool push_deferred_open_message_smb2(struct smb_request *req,
@@ -360,11 +360,6 @@ struct smbd_smb2_request {
int current_idx;
bool do_signing;
- /*
- * mid used for compatibility with SMB1 code.
- * Server allocated, never seen by client.
- */
- uint16_t compat_mid;
struct files_struct *compat_chain_fsp;
@@ -562,7 +557,6 @@ struct smbd_server_connection {
struct smbd_smb2_session *list;
} sessions;
struct smbd_smb2_request *requests;
- uint16_t next_compat_mid;
} smb2;
};
diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c
index 0c75769594..554591fc98 100644
--- a/source3/smbd/notify.c
+++ b/source3/smbd/notify.c
@@ -45,7 +45,7 @@ static void notify_fsp(files_struct *fsp, uint32 action, const char *name);
struct notify_mid_map {
struct notify_mid_map *prev, *next;
struct notify_change_request *req;
- uint16 mid;
+ uint64_t mid;
};
static bool notify_change_record_identical(struct notify_change *c1,
@@ -297,7 +297,7 @@ static void change_notify_remove_request(struct notify_change_request *remove_re
Delete entries by mid from the change notify pending queue. Always send reply.
*****************************************************************************/
-void remove_pending_change_notify_requests_by_mid(uint16 mid)
+void remove_pending_change_notify_requests_by_mid(uint64_t mid)
{
struct notify_mid_map *map;
struct smbd_server_connection *sconn = smbd_server_conn;
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index a03a0b1a55..2783545540 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -1280,7 +1280,8 @@ void reply_ntcancel(struct smb_request *req)
remove_pending_change_notify_requests_by_mid(req->mid);
remove_pending_lock_requests_by_mid(req->mid);
- DEBUG(3,("reply_ntcancel: cancel called on mid = %d.\n", req->mid));
+ DEBUG(3,("reply_ntcancel: cancel called on mid = %llu.\n",
+ (unsigned long long)req->mid));
END_PROFILE(SMBntcancel);
return;
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 1e98e88388..0e45c1d4b8 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -890,7 +890,7 @@ static bool is_delete_request(files_struct *fsp) {
static NTSTATUS send_break_message(files_struct *fsp,
struct share_mode_entry *exclusive,
- uint16 mid,
+ uint64_t mid,
int oplock_request)
{
NTSTATUS status;
@@ -907,7 +907,8 @@ static NTSTATUS send_break_message(files_struct *fsp,
don't want this set in the share mode struct pointed to by lck. */
if (oplock_request & FORCE_OPLOCK_BREAK_TO_NONE) {
- SSVAL(msg,6,exclusive->op_type | FORCE_OPLOCK_BREAK_TO_NONE);
+ SSVAL(msg,OP_BREAK_MSG_OP_TYPE_OFFSET,
+ exclusive->op_type | FORCE_OPLOCK_BREAK_TO_NONE);
}
status = messaging_send_buf(smbd_messaging_context(), exclusive->pid,
@@ -934,7 +935,7 @@ static NTSTATUS send_break_message(files_struct *fsp,
static bool delay_for_oplocks(struct share_mode_lock *lck,
files_struct *fsp,
- uint16 mid,
+ uint64_t mid,
int pass_number,
int oplock_request)
{
@@ -1069,7 +1070,8 @@ static void defer_open(struct share_mode_lock *lck,
if (procid_is_me(&e->pid) && (e->op_mid == req->mid)) {
DEBUG(0, ("Trying to defer an already deferred "
- "request: mid=%d, exiting\n", req->mid));
+ "request: mid=%llu, exiting\n",
+ (unsigned long long)req->mid));
exit_server("attempt to defer a deferred request");
}
}
@@ -1077,10 +1079,10 @@ static void defer_open(struct share_mode_lock *lck,
/* End paranoia check */
DEBUG(10,("defer_open_sharing_error: time [%u.%06u] adding deferred "
- "open entry for mid %u\n",
+ "open entry for mid %llu\n",
(unsigned int)request_time.tv_sec,
(unsigned int)request_time.tv_usec,
- (unsigned int)req->mid));
+ (unsigned long long)req->mid));
if (!push_deferred_open_message_smb(req, request_time, timeout,
(char *)state, sizeof(*state))) {
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index c7cce4afad..2289787ddd 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -676,9 +676,9 @@ static void process_oplock_break_response(struct messaging_context *msg_ctx,
/* De-linearize incoming message. */
message_to_share_mode_entry(&msg, (char *)data->data);
- DEBUG(10, ("Got oplock break response from pid %s: %s/%lu mid %u\n",
+ DEBUG(10, ("Got oplock break response from pid %s: %s/%lu mid %llu\n",
procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
- msg.share_file_id, (unsigned int)msg.op_mid));
+ msg.share_file_id, (unsigned long long)msg.op_mid));
schedule_deferred_open_message_smb(msg.op_mid);
}
@@ -704,9 +704,9 @@ static void process_open_retry_message(struct messaging_context *msg_ctx,
/* De-linearize incoming message. */
message_to_share_mode_entry(&msg, (char *)data->data);
- DEBUG(10, ("Got open retry msg from pid %s: %s mid %u\n",
+ DEBUG(10, ("Got open retry msg from pid %s: %s mid %llu\n",
procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
- (unsigned int)msg.op_mid));
+ (unsigned long long)msg.op_mid));
schedule_deferred_open_message_smb(msg.op_mid);
}
@@ -839,20 +839,20 @@ void contend_level2_oplocks_end(files_struct *fsp,
void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e)
{
- SIVAL(msg,0,(uint32)e->pid.pid);
- SSVAL(msg,4,e->op_mid);
- SSVAL(msg,6,e->op_type);
- SIVAL(msg,8,e->access_mask);
- SIVAL(msg,12,e->share_access);
- SIVAL(msg,16,e->private_options);
- SIVAL(msg,20,(uint32)e->time.tv_sec);
- SIVAL(msg,24,(uint32)e->time.tv_usec);
- push_file_id_24(msg+28, &e->id);
- SIVAL(msg,52,e->share_file_id);
- SIVAL(msg,56,e->uid);
- SSVAL(msg,60,e->flags);
+ SIVAL(msg,OP_BREAK_MSG_PID_OFFSET,(uint32)e->pid.pid);
+ SBVAL(msg,OP_BREAK_MSG_MID_OFFSET,e->op_mid);
+ SSVAL(msg,OP_BREAK_MSG_OP_TYPE_OFFSET,e->op_type);
+ SIVAL(msg,OP_BREAK_MSG_ACCESS_MASK_OFFSET,e->access_mask);
+ SIVAL(msg,OP_BREAK_MSG_SHARE_ACCESS_OFFSET,e->share_access);
+ SIVAL(msg,OP_BREAK_MSG_PRIV_OFFSET,e->private_options);
+ SIVAL(msg,OP_BREAK_MSG_TIME_SEC_OFFSET,(uint32_t)e->time.tv_sec);
+ SIVAL(msg,OP_BREAK_MSG_TIME_USEC_OFFSET,(uint32_t)e->time.tv_usec);
+ push_file_id_24(msg+OP_BREAK_MSG_DEV_OFFSET, &e->id);
+ SIVAL(msg,OP_BREAK_MSG_FILE_ID_OFFSET,e->share_file_id);
+ SIVAL(msg,OP_BREAK_MSG_UID_OFFSET,e->uid);
+ SSVAL(msg,OP_BREAK_MSG_FLAGS_OFFSET,e->flags);
#ifdef CLUSTER_SUPPORT
- SIVAL(msg,62,e->pid.vnn);
+ SIVAL(msg,OP_BREAK_MSG_VNN_OFFSET,e->pid.vnn);
#endif
}
@@ -862,20 +862,20 @@ void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e)
void message_to_share_mode_entry(struct share_mode_entry *e, char *msg)
{
- e->pid.pid = (pid_t)IVAL(msg,0);
- e->op_mid = SVAL(msg,4);
- e->op_type = SVAL(msg,6);
- e->access_mask = IVAL(msg,8);
- e->share_access = IVAL(msg,12);
- e->private_options = IVAL(msg,16);
- e->time.tv_sec = (time_t)IVAL(msg,20);
- e->time.tv_usec = (int)IVAL(msg,24);
- pull_file_id_24(msg+28, &e->id);
- e->share_file_id = (unsigned long)IVAL(msg,52);
- e->uid = (uint32)IVAL(msg,56);
- e->flags = (uint16)SVAL(msg,60);
+ e->pid.pid = (pid_t)IVAL(msg,OP_BREAK_MSG_PID_OFFSET);
+ e->op_mid = BVAL(msg,OP_BREAK_MSG_MID_OFFSET);
+ e->op_type = SVAL(msg,OP_BREAK_MSG_OP_TYPE_OFFSET);
+ e->access_mask = IVAL(msg,OP_BREAK_MSG_ACCESS_MASK_OFFSET);
+ e->share_access = IVAL(msg,OP_BREAK_MSG_SHARE_ACCESS_OFFSET);
+ e->private_options = IVAL(msg,OP_BREAK_MSG_PRIV_OFFSET);
+ e->time.tv_sec = (time_t)IVAL(msg,OP_BREAK_MSG_TIME_SEC_OFFSET);
+ e->time.tv_usec = (int)IVAL(msg,OP_BREAK_MSG_TIME_USEC_OFFSET);
+ pull_file_id_24(msg+OP_BREAK_MSG_DEV_OFFSET, &e->id);
+ e->share_file_id = (unsigned long)IVAL(msg,OP_BREAK_MSG_FILE_ID_OFFSET);
+ e->uid = (uint32)IVAL(msg,OP_BREAK_MSG_UID_OFFSET);
+ e->flags = (uint16)SVAL(msg,OP_BREAK_MSG_FLAGS_OFFSET);
#ifdef CLUSTER_SUPPORT
- e->pid.vnn = IVAL(msg,62);
+ e->pid.vnn = IVAL(msg,OP_BREAK_MSG_VNN_OFFSET);
#endif
}
diff --git a/source3/smbd/oplock_onefs.c b/source3/smbd/oplock_onefs.c
index 754ba73bfd..3811211088 100644
--- a/source3/smbd/oplock_onefs.c
+++ b/source3/smbd/oplock_onefs.c
@@ -49,7 +49,7 @@ struct onefs_callback_record {
enum onefs_callback_state state;
union {
files_struct *fsp; /* ONEFS_OPEN_FILE */
- uint16_t mid; /* ONEFS_WAITING_FOR_OPLOCK */
+ uint64_t mid; /* ONEFS_WAITING_FOR_OPLOCK */
} data;
};
@@ -78,8 +78,8 @@ const char *onefs_cb_record_str_dbg(const struct onefs_callback_record *r)
fsp_str_dbg(r->data.fsp));
case ONEFS_WAITING_FOR_OPLOCK:
result = talloc_asprintf(talloc_tos(), "cb record %llu for "
- "pending mid %d", r->id,
- (int)r->data.mid);
+ "pending mid %llu", r->id,
+ (unsigned long long)r->data.mid);
break;
default:
result = talloc_asprintf(talloc_tos(), "cb record %llu unknown "
@@ -196,7 +196,7 @@ void destroy_onefs_callback_record(uint64_t id)
* 2. OPEN_FILE: Once ifs_createfile completes, the callback record is
* transitioned to this state via onefs_set_oplock_callback.
*/
-uint64_t onefs_oplock_wait_record(uint16_t mid)
+uint64_t onefs_oplock_wait_record(uint64_t mid)
{
struct onefs_callback_record *result;
static uint64_t id_generator = 0;
@@ -250,7 +250,7 @@ void onefs_set_oplock_callback(uint64_t id, files_struct *fsp)
*/
if (open_was_deferred(cb->data.mid)) {
if (asprintf(&msg, "Trying to upgrade callback for deferred "
- "open mid=%d\n", cb->data.mid) != -1) {
+ "open mid=%llu\n", (unsigned long long)cb->data.mid) != -1) {
smb_panic(msg);
}
smb_panic("Trying to upgrade callback for deferred open "
@@ -407,7 +407,8 @@ static void semlock_available_handler(uint64_t id)
return;
}
- DEBUG(10, ("Got semlock available for mid %d\n", cb->data.mid));
+ DEBUG(10, ("Got semlock available for mid %llu\n",
+ (unsigned long long)cb->data.mid));
/* Paranoia check */
if (!(open_was_deferred(cb->data.mid))) {
@@ -450,7 +451,8 @@ static void semlock_async_failure_handler(uint64_t id)
return;
}
- DEBUG(1, ("Got semlock_async_failure message for mid %d\n", cb->data.mid));
+ DEBUG(1, ("Got semlock_async_failure message for mid %llu\n",
+ (unsigned long long)cb->data.mid));
/* Paranoia check */
if (!(open_was_deferred(cb->data.mid))) {
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 1a000f1f08..8d3c65a802 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -39,7 +39,7 @@ extern bool global_machine_password_needs_changing;
static void construct_reply_common(struct smb_request *req, const char *inbuf,
char *outbuf);
-static struct pending_message_list *get_deferred_open_message_smb(uint16_t mid);
+static struct pending_message_list *get_deferred_open_message_smb(uint64_t mid);
static bool smbd_lock_socket_internal(struct smbd_server_connection *sconn)
{
@@ -454,7 +454,7 @@ static bool init_smb_request(struct smb_request *req, const uint8 *inbuf,
req->cmd = CVAL(inbuf, smb_com);
req->flags2 = SVAL(inbuf, smb_flg2);
req->smbpid = SVAL(inbuf, smb_pid);
- req->mid = SVAL(inbuf, smb_mid);
+ req->mid = (uint64_t)SVAL(inbuf, smb_mid);
req->seqnum = seqnum;
req->vuid = SVAL(inbuf, smb_uid);
req->tid = SVAL(inbuf, smb_tid);
@@ -505,7 +505,7 @@ static void smbd_deferred_open_timer(struct event_context *ev,
struct pending_message_list *msg = talloc_get_type(private_data,
struct pending_message_list);
TALLOC_CTX *mem_ctx = talloc_tos();
- uint16_t mid = SVAL(msg->buf.data,smb_mid);
+ uint64_t mid = (uint64_t)SVAL(msg->buf.data,smb_mid);
uint8_t *inbuf;
inbuf = (uint8_t *)talloc_memdup(mem_ctx, msg->buf.data,
@@ -517,8 +517,8 @@ static void smbd_deferred_open_timer(struct event_context *ev,
/* We leave this message on the queue so the open code can
know this is a retry. */
- DEBUG(5,("smbd_deferred_open_timer: trigger mid %u.\n",
- (unsigned int)mid ));
+ DEBUG(5,("smbd_deferred_open_timer: trigger mid %llu.\n",
+ (unsigned long long)mid ));
/* Mark the message as processed so this is not
* re-processed in error. */
@@ -601,7 +601,7 @@ static bool push_queued_message(struct smb_request *req,
Function to delete a sharing violation open message by mid.
****************************************************************************/
-void remove_deferred_open_message_smb(uint16_t mid)
+void remove_deferred_open_message_smb(uint64_t mid)
{
struct pending_message_list *pml;
@@ -611,10 +611,10 @@ void remove_deferred_open_message_smb(uint16_t mid)
}
for (pml = deferred_open_queue; pml; pml = pml->next) {
- if (mid == SVAL(pml->buf.data,smb_mid)) {
+ if (mid == (uint64_t)SVAL(pml->buf.data,smb_mid)) {
DEBUG(10,("remove_deferred_open_message_smb: "
- "deleting mid %u len %u\n",
- (unsigned int)mid,
+ "deleting mid %llu len %u\n",
+ (unsigned long long)mid,
(unsigned int)pml->buf.length ));
DLIST_REMOVE(deferred_open_queue, pml);
TALLOC_FREE(pml);
@@ -628,7 +628,7 @@ void remove_deferred_open_message_smb(uint16_t mid)
schedule it for immediate processing.
****************************************************************************/
-void schedule_deferred_open_message_smb(uint16_t mid)
+void schedule_deferred_open_message_smb(uint64_t mid)
{
struct pending_message_list *pml;
int i = 0;
@@ -639,10 +639,12 @@ void schedule_deferred_open_message_smb(uint16_t mid)
}
for (pml = deferred_open_queue; pml; pml = pml->next) {
- uint16 msg_mid = SVAL(pml->buf.data,smb_mid);
+ uint64_t msg_mid = (uint64_t)SVAL(pml->buf.data,smb_mid);
- DEBUG(10,("schedule_deferred_open_message_smb: [%d] msg_mid = %u\n", i++,
- (unsigned int)msg_mid ));
+ DEBUG(10,("schedule_deferred_open_message_smb: [%d] "
+ "msg_mid = %llu\n",
+ i++,
+ (unsigned long long)msg_mid ));
if (mid == msg_mid) {
struct timed_event *te;
@@ -651,13 +653,14 @@ void schedule_deferred_open_message_smb(uint16_t mid)
/* A processed message should not be
* rescheduled. */
DEBUG(0,("schedule_deferred_open_message_smb: LOGIC ERROR "
- "message mid %u was already processed\n",
- msg_mid ));
+ "message mid %llu was already processed\n",
+ (unsigned long long)msg_mid ));
continue;
}
- DEBUG(10,("schedule_deferred_open_message_smb: scheduling mid %u\n",
- mid ));
+ DEBUG(10,("schedule_deferred_open_message_smb: "
+ "scheduling mid %llu\n",
+ (unsigned long long)mid ));
te = event_add_timed(smbd_event_context(),
pml,
@@ -666,8 +669,9 @@ void schedule_deferred_open_message_smb(uint16_t mid)
pml);
if (!te) {
DEBUG(10,("schedule_deferred_open_message_smb: "
- "event_add_timed() failed, skipping mid %u\n",
- mid ));
+ "event_add_timed() failed, "
+ "skipping mid %llu\n",
+ (unsigned long long)msg_mid ));
}
TALLOC_FREE(pml->te);
@@ -677,15 +681,16 @@ void schedule_deferred_open_message_smb(uint16_t mid)
}
}
- DEBUG(10,("schedule_deferred_open_message_smb: failed to find message mid %u\n",
- mid ));
+ DEBUG(10,("schedule_deferred_open_message_smb: failed to "
+ "find message mid %llu\n",
+ (unsigned long long)mid ));
}
/****************************************************************************
Return true if this mid is on the deferred queue and was not yet processed.
****************************************************************************/
-bool open_was_deferred(uint16_t mid)
+bool open_was_deferred(uint64_t mid)
{
struct pending_message_list *pml;
@@ -694,7 +699,7 @@ bool open_was_deferred(uint16_t mid)
}
for (pml = deferred_open_queue; pml; pml = pml->next) {
- if (SVAL(pml->buf.data,smb_mid) == mid && !pml->processed) {
+ if (((uint64_t)SVAL(pml->buf.data,smb_mid)) == mid && !pml->processed) {
return True;
}
}
@@ -705,12 +710,12 @@ bool open_was_deferred(uint16_t mid)
Return the message queued by this mid.
****************************************************************************/
-static struct pending_message_list *get_deferred_open_message_smb(uint16_t mid)
+static struct pending_message_list *get_deferred_open_message_smb(uint64_t mid)
{
struct pending_message_list *pml;
for (pml = deferred_open_queue; pml; pml = pml->next) {
- if (SVAL(pml->buf.data,smb_mid) == mid) {
+ if (((uint64_t)SVAL(pml->buf.data,smb_mid)) == mid) {
return pml;
}
}
@@ -721,7 +726,7 @@ static struct pending_message_list *get_deferred_open_message_smb(uint16_t mid)
Get the state data queued by this mid.
****************************************************************************/
-bool get_deferred_open_message_state(uint16_t mid,
+bool get_deferred_open_message_state(uint64_t mid,
struct timeval *p_request_time,
void **pp_state)
{
@@ -776,11 +781,12 @@ bool push_deferred_open_message_smb(struct smb_request *req,
end_time = timeval_sum(&request_time, &timeout);
- DEBUG(10,("push_deferred_open_message_smb: pushing message len %u mid %u "
- "timeout time [%u.%06u]\n",
- (unsigned int) smb_len(req->inbuf)+4, (unsigned int)req->mid,
- (unsigned int)end_time.tv_sec,
- (unsigned int)end_time.tv_usec));
+ DEBUG(10,("push_deferred_open_message_smb: pushing message "
+ "len %u mid %llu timeout time [%u.%06u]\n",
+ (unsigned int) smb_len(req->inbuf)+4,
+ (unsigned long long)req->mid,
+ (unsigned int)end_time.tv_sec,
+ (unsigned int)end_time.tv_usec));
return push_queued_message(req, request_time, end_time,
private_data, priv_len);
@@ -986,7 +992,7 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *
* prevent a DoS.
*/
-NTSTATUS allow_new_trans(struct trans_state *list, int mid)
+NTSTATUS allow_new_trans(struct trans_state *list, uint64_t mid)
{
int count = 0;
for (; list != NULL; list = list->next) {
@@ -1467,7 +1473,8 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
if (!change_to_user(conn,session_tag)) {
DEBUG(0, ("Error: Could not change to user. Removing "
- "deferred open, mid=%d.\n", req->mid));
+ "deferred open, mid=%llu.\n",
+ (unsigned long long)req->mid));
reply_force_doserror(req, ERRSRV, ERRbaduid);
return conn;
}
diff --git a/source3/smbd/smb2_glue.c b/source3/smbd/smb2_glue.c
index ac31ce54f0..26107df389 100644
--- a/source3/smbd/smb2_glue.c
+++ b/source3/smbd/smb2_glue.c
@@ -22,18 +22,6 @@
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
-static uint16_t allocate_next_mid(void)
-{
- struct smbd_server_connection *sconn = smbd_server_conn;
-
- sconn->smb2.next_compat_mid++;
- /* Avoid mid == 0 and mid == 0xffff. */
- if (sconn->smb2.next_compat_mid == 0xFFFF) {
- sconn->smb2.next_compat_mid += 2;
- }
- return sconn->smb2.next_compat_mid;
-}
-
struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req)
{
struct smb_request *smbreq;
@@ -58,7 +46,7 @@ struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req)
if (IVAL(inhdr, SMB2_HDR_FLAGS) & SMB2_HDR_FLAG_DFS) {
smbreq->flags2 |= FLAGS2_DFS_PATHNAMES;
}
- req->compat_mid = smbreq->mid = allocate_next_mid();
+ smbreq->mid = BVAL(inhdr, SMB2_HDR_MESSAGE_ID);
smbreq->chain_fsp = req->compat_chain_fsp;
smbreq->smb2req = req;
@@ -68,20 +56,20 @@ struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req)
/* Dummy functions for the SMB1 -> SMB2 deferred open message
* hooks. */
-void remove_deferred_open_message_smb2(uint16_t mid)
+void remove_deferred_open_message_smb2(uint64_t mid)
{
}
-void schedule_deferred_open_message_smb2(uint16_t mid)
+void schedule_deferred_open_message_smb2(uint64_t mid)
{
}
-bool open_was_deferred_smb2(uint16_t mid)
+bool open_was_deferred_smb2(uint64_t mid)
{
return false;
}
-bool get_deferred_open_message_state_smb2(uint16_t mid,
+bool get_deferred_open_message_state_smb2(uint64_t mid,
struct timeval *p_request_time,
void **pp_state)
{