From 08b96503c5d217aafeccb5bf42a00c2f3fdfc91a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Mar 2018 12:01:05 -0700 Subject: [PATCH 1/4] s3: debug: smb2: Create a new DBGC_SMB2 debug class and mark all smbd/smb2_*.c files with it. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Will allow easier smb2-specific debugging. https://bugzilla.samba.org/show_bug.cgi?id=13347 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme (cherry picked from commit 8dabcf8948c2e514b489169c34673e093519b583) --- lib/util/debug.c | 1 + lib/util/debug.h | 1 + source3/smbd/smb2_break.c | 3 +++ source3/smbd/smb2_close.c | 3 +++ source3/smbd/smb2_create.c | 3 +++ source3/smbd/smb2_flush.c | 3 +++ source3/smbd/smb2_getinfo.c | 3 +++ source3/smbd/smb2_glue.c | 3 +++ source3/smbd/smb2_ioctl.c | 3 +++ source3/smbd/smb2_ioctl_dfs.c | 3 +++ source3/smbd/smb2_ioctl_filesys.c | 3 +++ source3/smbd/smb2_ioctl_named_pipe.c | 3 +++ source3/smbd/smb2_ioctl_network_fs.c | 3 +++ source3/smbd/smb2_keepalive.c | 3 +++ source3/smbd/smb2_lock.c | 3 +++ source3/smbd/smb2_negprot.c | 3 +++ source3/smbd/smb2_notify.c | 3 +++ source3/smbd/smb2_query_directory.c | 3 +++ source3/smbd/smb2_read.c | 3 +++ source3/smbd/smb2_server.c | 3 +++ source3/smbd/smb2_sesssetup.c | 3 +++ source3/smbd/smb2_setinfo.c | 3 +++ source3/smbd/smb2_tcon.c | 3 +++ source3/smbd/smb2_write.c | 3 +++ 24 files changed, 68 insertions(+) diff --git a/lib/util/debug.c b/lib/util/debug.c index 64285506d1b..47590403e1d 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -541,6 +541,7 @@ static const char *default_classname_table[] = { [DBGC_AUTH_AUDIT_JSON] = "auth_json_audit", [DBGC_KERBEROS] = "kerberos", [DBGC_DRS_REPL] = "drs_repl", + [DBGC_SMB2] = "smb2", }; /* diff --git a/lib/util/debug.h b/lib/util/debug.h index e82553aaf71..47280da1a78 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -93,6 +93,7 @@ bool dbghdr( int level, const char *location, const char *func); #define DBGC_AUTH_AUDIT_JSON 25 #define DBGC_KERBEROS 26 #define DBGC_DRS_REPL 27 +#define DBGC_SMB2 28 /* So you can define DBGC_CLASS before including debug.h */ #ifndef DBGC_CLASS diff --git a/source3/smbd/smb2_break.c b/source3/smbd/smb2_break.c index 4c5d62e73d6..86529ed2e1f 100644 --- a/source3/smbd/smb2_break.c +++ b/source3/smbd/smb2_break.c @@ -26,6 +26,9 @@ #include "../lib/util/tevent_ntstatus.h" #include "locking/leases_db.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static NTSTATUS smbd_smb2_request_process_lease_break( struct smbd_smb2_request *req); diff --git a/source3/smbd/smb2_close.c b/source3/smbd/smb2_close.c index 5830228ed6f..992b52929ec 100644 --- a/source3/smbd/smb2_close.c +++ b/source3/smbd/smb2_close.c @@ -25,6 +25,9 @@ #include "../lib/util/tevent_ntstatus.h" #include "lib/tevent_wait.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_close_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c index d34a5f7d448..3f38af5dde2 100644 --- a/source3/smbd/smb2_create.c +++ b/source3/smbd/smb2_create.c @@ -29,6 +29,9 @@ #include "../lib/util/tevent_ntstatus.h" #include "messages.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + int map_smb2_oplock_levels_to_samba(uint8_t in_oplock_level) { switch(in_oplock_level) { diff --git a/source3/smbd/smb2_flush.c b/source3/smbd/smb2_flush.c index 51584ca876f..d1ab3a09839 100644 --- a/source3/smbd/smb2_flush.c +++ b/source3/smbd/smb2_flush.c @@ -24,6 +24,9 @@ #include "../libcli/smb/smb_common.h" #include "../lib/util/tevent_ntstatus.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, diff --git a/source3/smbd/smb2_getinfo.c b/source3/smbd/smb2_getinfo.c index 7f44868bade..694e9f83b75 100644 --- a/source3/smbd/smb2_getinfo.c +++ b/source3/smbd/smb2_getinfo.c @@ -26,6 +26,9 @@ #include "trans2.h" #include "../lib/util/tevent_ntstatus.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, diff --git a/source3/smbd/smb2_glue.c b/source3/smbd/smb2_glue.c index bf2ea5a9138..6a73ec050e2 100644 --- a/source3/smbd/smb2_glue.c +++ b/source3/smbd/smb2_glue.c @@ -23,6 +23,9 @@ #include "smbd/globals.h" #include "../libcli/smb/smb_common.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req) { struct smb_request *smbreq; diff --git a/source3/smbd/smb2_ioctl.c b/source3/smbd/smb2_ioctl.c index 993682ffdbb..be70e3a0912 100644 --- a/source3/smbd/smb2_ioctl.c +++ b/source3/smbd/smb2_ioctl.c @@ -27,6 +27,9 @@ #include "smb2_ioctl_private.h" #include "librpc/gen_ndr/ioctl.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_ioctl_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, diff --git a/source3/smbd/smb2_ioctl_dfs.c b/source3/smbd/smb2_ioctl_dfs.c index f4dd189f355..72893ca4237 100644 --- a/source3/smbd/smb2_ioctl_dfs.c +++ b/source3/smbd/smb2_ioctl_dfs.c @@ -26,6 +26,9 @@ #include "include/ntioctl.h" #include "smb2_ioctl_private.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static NTSTATUS fsctl_dfs_get_refers(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct connection_struct *conn, diff --git a/source3/smbd/smb2_ioctl_filesys.c b/source3/smbd/smb2_ioctl_filesys.c index 79c50219643..8a9c8c64ec9 100644 --- a/source3/smbd/smb2_ioctl_filesys.c +++ b/source3/smbd/smb2_ioctl_filesys.c @@ -31,6 +31,9 @@ #include "librpc/gen_ndr/ndr_ioctl.h" #include "smb2_ioctl_private.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + /* * XXX this may reduce dup_extents->byte_count so that it's less than the * target file size. diff --git a/source3/smbd/smb2_ioctl_named_pipe.c b/source3/smbd/smb2_ioctl_named_pipe.c index 13c4982d640..f9e3dec049c 100644 --- a/source3/smbd/smb2_ioctl_named_pipe.c +++ b/source3/smbd/smb2_ioctl_named_pipe.c @@ -27,6 +27,9 @@ #include "include/ntioctl.h" #include "smb2_ioctl_private.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static void smbd_smb2_ioctl_pipe_write_done(struct tevent_req *subreq); static void smbd_smb2_ioctl_pipe_read_done(struct tevent_req *subreq); diff --git a/source3/smbd/smb2_ioctl_network_fs.c b/source3/smbd/smb2_ioctl_network_fs.c index 4006ccf3162..c0d175609ec 100644 --- a/source3/smbd/smb2_ioctl_network_fs.c +++ b/source3/smbd/smb2_ioctl_network_fs.c @@ -31,6 +31,9 @@ #include "smb2_ioctl_private.h" #include "../lib/tsocket/tsocket.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static void copychunk_pack_limits(struct srv_copychunk_rsp *cc_rsp) { cc_rsp->chunks_written = COPYCHUNK_MAX_CHUNKS; diff --git a/source3/smbd/smb2_keepalive.c b/source3/smbd/smb2_keepalive.c index b16ff6bd983..fac567c1ce9 100644 --- a/source3/smbd/smb2_keepalive.c +++ b/source3/smbd/smb2_keepalive.c @@ -23,6 +23,9 @@ #include "smbd/globals.h" #include "../libcli/smb/smb_common.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + NTSTATUS smbd_smb2_request_process_keepalive(struct smbd_smb2_request *req) { DATA_BLOB outbody; diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c index 45b833cbca6..a05470e52e4 100644 --- a/source3/smbd/smb2_lock.c +++ b/source3/smbd/smb2_lock.c @@ -26,6 +26,9 @@ #include "../lib/util/tevent_ntstatus.h" #include "messages.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + struct smbd_smb2_lock_element { uint64_t offset; uint64_t length; diff --git a/source3/smbd/smb2_negprot.c b/source3/smbd/smb2_negprot.c index f8133b239af..2b725f30f75 100644 --- a/source3/smbd/smb2_negprot.c +++ b/source3/smbd/smb2_negprot.c @@ -27,6 +27,9 @@ #include "../librpc/ndr/libndr.h" #include "../libcli/smb/smb_signing.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + extern fstring remote_proto; /* diff --git a/source3/smbd/smb2_notify.c b/source3/smbd/smb2_notify.c index 573635b89d1..24241562556 100644 --- a/source3/smbd/smb2_notify.c +++ b/source3/smbd/smb2_notify.c @@ -25,6 +25,9 @@ #include "../libcli/smb/smb_common.h" #include "../lib/util/tevent_ntstatus.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + struct smbd_smb2_notify_state { struct smbd_smb2_request *smb2req; struct smb_request *smbreq; diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c index 888473853d4..700f43e3126 100644 --- a/source3/smbd/smb2_query_directory.c +++ b/source3/smbd/smb2_query_directory.c @@ -26,6 +26,9 @@ #include "../lib/util/tevent_ntstatus.h" #include "system/filesys.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c index 273c56cf352..a7d2496bc6f 100644 --- a/source3/smbd/smb2_read.c +++ b/source3/smbd/smb2_read.c @@ -28,6 +28,9 @@ #include "rpc_server/srv_pipe_hnd.h" #include "lib/util/sys_rw_data.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index a731880e98e..c44f9cda850 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -32,6 +32,9 @@ #include "auth.h" #include "lib/crypto/sha512.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static void smbd_smb2_connection_handler(struct tevent_context *ev, struct tevent_fd *fde, uint16_t flags, diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c index eda538f17f6..5e1e8b4ec57 100644 --- a/source3/smbd/smb2_sesssetup.c +++ b/source3/smbd/smb2_sesssetup.c @@ -33,6 +33,9 @@ #include "lib/crypto/aes_ccm_128.h" #include "lib/crypto/aes_gcm_128.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_session_setup_wrap_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c index 0355095c8b1..30ef17cd6da 100644 --- a/source3/smbd/smb2_setinfo.c +++ b/source3/smbd/smb2_setinfo.c @@ -29,6 +29,9 @@ #include "source3/lib/dbwrap/dbwrap_watch.h" #include "messages.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, diff --git a/source3/smbd/smb2_tcon.c b/source3/smbd/smb2_tcon.c index 914eb87aa8c..07e01cddd46 100644 --- a/source3/smbd/smb2_tcon.c +++ b/source3/smbd/smb2_tcon.c @@ -27,6 +27,9 @@ #include "lib/param/loadparm.h" #include "../lib/util/tevent_ntstatus.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_tree_connect_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, diff --git a/source3/smbd/smb2_write.c b/source3/smbd/smb2_write.c index 5657c6618d2..ee95bd317ae 100644 --- a/source3/smbd/smb2_write.c +++ b/source3/smbd/smb2_write.c @@ -25,6 +25,9 @@ #include "../lib/util/tevent_ntstatus.h" #include "rpc_server/srv_pipe_hnd.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_SMB2 + static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, -- 2.17.0.rc0.231.g781580f067-goog From 75693d64acf08d608f39cde866c528d92276a5c2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Mar 2018 12:40:50 -0700 Subject: [PATCH 2/4] lib: debug: Add DBGC_XXX versions of the macros to allow class-specific messages. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://bugzilla.samba.org/show_bug.cgi?id=13347 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme (cherry picked from commit cdde6d93605d15a59e816a35e8e02ca193bf1403) --- lib/util/debug.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/util/debug.h b/lib/util/debug.h index 47280da1a78..1b17fad9694 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -217,6 +217,14 @@ extern int *DEBUGLEVEL_CLASS; && (dbgtext("%s: ", __func__)) \ && (dbgtext body) ) +/* Prefix messages with the function name - class specific */ +#define DBGC_PREFIX(dbgc_class, level, body ) \ + (void)( ((level) <= MAX_DEBUG_LEVEL) && \ + unlikely(DEBUGLEVEL_CLASS[ dbgc_class ] >= (level)) \ + && (dbghdrclass(level, dbgc_class, __location__, __func__ )) \ + && (dbgtext("%s: ", __func__)) \ + && (dbgtext body) ) + /* * Debug levels matching RFC 3164 */ @@ -232,12 +240,34 @@ extern int *DEBUGLEVEL_CLASS; #define DBG_INFO(...) DBG_PREFIX(DBGLVL_INFO, (__VA_ARGS__)) #define DBG_DEBUG(...) DBG_PREFIX(DBGLVL_DEBUG, (__VA_ARGS__)) +#define DBGC_ERR(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_ERR, (__VA_ARGS__)) +#define DBGC_WARNING(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_WARNING, (__VA_ARGS__)) +#define DBGC_NOTICE(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_NOTICE, (__VA_ARGS__)) +#define DBGC_INFO(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_INFO, (__VA_ARGS__)) +#define DBGC_DEBUG(dbgc_class, ...) DBGC_PREFIX(dbgc_class, \ + DBGLVL_DEBUG, (__VA_ARGS__)) + #define D_ERR(...) DEBUG(DBGLVL_ERR, (__VA_ARGS__)) #define D_WARNING(...) DEBUG(DBGLVL_WARNING, (__VA_ARGS__)) #define D_NOTICE(...) DEBUG(DBGLVL_NOTICE, (__VA_ARGS__)) #define D_INFO(...) DEBUG(DBGLVL_INFO, (__VA_ARGS__)) #define D_DEBUG(...) DEBUG(DBGLVL_DEBUG, (__VA_ARGS__)) +#define DC_ERR(...) DEBUGC(dbgc_class, \ + DBGLVL_ERR, (__VA_ARGS__)) +#define DC_WARNING(...) DEBUGC(dbgc_class, \ + DBGLVL_WARNING, (__VA_ARGS__)) +#define DC_NOTICE(...) DEBUGC(dbgc_class, \ + DBGLVL_NOTICE, (__VA_ARGS__)) +#define DC_INFO(...) DEBUGC(dbgc_class, \ + DBGLVL_INFO, (__VA_ARGS__)) +#define DC_DEBUG(...) DEBUGC(dbgc_class, \ + DBGLVL_DEBUG, (__VA_ARGS__)) + /* The following definitions come from lib/debug.c */ /** Possible destinations for the debug log (in order of precedence - -- 2.17.0.rc0.231.g781580f067-goog From 61a5c375f2c861fc69e86b0c4419eb3493e74ac6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Mar 2018 12:52:49 -0700 Subject: [PATCH 3/4] s3: smbd: SMB2: Add DBGC_SMB2_CREDITS class to specifically debug credit issues. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://bugzilla.samba.org/show_bug.cgi?id=13347 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme (cherry picked from commit ad973fddef00d6d92443be89e7f5404006a94d99) --- lib/util/debug.c | 1 + lib/util/debug.h | 1 + source3/smbd/smb2_server.c | 48 ++++++++++++++++++++++++-------------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/lib/util/debug.c b/lib/util/debug.c index 47590403e1d..d010b724203 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -542,6 +542,7 @@ static const char *default_classname_table[] = { [DBGC_KERBEROS] = "kerberos", [DBGC_DRS_REPL] = "drs_repl", [DBGC_SMB2] = "smb2", + [DBGC_SMB2_CREDITS] = "smb2_credits", }; /* diff --git a/lib/util/debug.h b/lib/util/debug.h index 1b17fad9694..1e184b47de9 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -94,6 +94,7 @@ bool dbghdr( int level, const char *location, const char *func); #define DBGC_KERBEROS 26 #define DBGC_DRS_REPL 27 #define DBGC_SMB2 28 +#define DBGC_SMB2_CREDITS 29 /* So you can define DBGC_CLASS before including debug.h */ #ifndef DBGC_CLASS diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index c44f9cda850..ee03a8eb0bb 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -616,34 +616,37 @@ static bool smb2_validate_sequence_number(struct smbXsrv_connection *xconn, seq_tmp = xconn->smb2.credits.seq_low; if (seq_id < seq_tmp) { - DEBUG(0,("smb2_validate_sequence_number: bad message_id " + DBGC_ERR(DBGC_SMB2_CREDITS, + "smb2_validate_sequence_number: bad message_id " "%llu (sequence id %llu) " "(granted = %u, low = %llu, range = %u)\n", (unsigned long long)message_id, (unsigned long long)seq_id, (unsigned int)xconn->smb2.credits.granted, (unsigned long long)xconn->smb2.credits.seq_low, - (unsigned int)xconn->smb2.credits.seq_range)); + (unsigned int)xconn->smb2.credits.seq_range); return false; } seq_tmp += xconn->smb2.credits.seq_range; if (seq_id >= seq_tmp) { - DEBUG(0,("smb2_validate_sequence_number: bad message_id " + DBGC_ERR(DBGC_SMB2_CREDITS, + "smb2_validate_sequence_number: bad message_id " "%llu (sequence id %llu) " "(granted = %u, low = %llu, range = %u)\n", (unsigned long long)message_id, (unsigned long long)seq_id, (unsigned int)xconn->smb2.credits.granted, (unsigned long long)xconn->smb2.credits.seq_low, - (unsigned int)xconn->smb2.credits.seq_range)); + (unsigned int)xconn->smb2.credits.seq_range); return false; } offset = seq_id % xconn->smb2.credits.max; if (bitmap_query(credits_bm, offset)) { - DEBUG(0,("smb2_validate_sequence_number: duplicate message_id " + DBGC_ERR(DBGC_SMB2_CREDITS, + "smb2_validate_sequence_number: duplicate message_id " "%llu (sequence id %llu) " "(granted = %u, low = %llu, range = %u) " "(bm offset %u)\n", @@ -652,7 +655,7 @@ static bool smb2_validate_sequence_number(struct smbXsrv_connection *xconn, (unsigned int)xconn->smb2.credits.granted, (unsigned long long)xconn->smb2.credits.seq_low, (unsigned int)xconn->smb2.credits.seq_range, - offset)); + offset); return false; } @@ -668,10 +671,11 @@ static bool smb2_validate_sequence_number(struct smbXsrv_connection *xconn, * already seen. */ while (bitmap_query(credits_bm, offset)) { - DEBUG(10,("smb2_validate_sequence_number: clearing " + DBGC_DEBUG(DBGC_SMB2_CREDITS, + "smb2_validate_sequence_number: clearing " "id %llu (position %u) from bitmap\n", (unsigned long long)(xconn->smb2.credits.seq_low), - offset)); + offset); bitmap_clear(credits_bm, offset); xconn->smb2.credits.seq_low += 1; @@ -700,7 +704,9 @@ static bool smb2_validate_message_id(struct smbXsrv_connection *xconn, credit_charge = MAX(credit_charge, 1); } - DEBUG(11, ("smb2_validate_message_id: mid %llu (charge %llu), " + DEBUGC(11, + DBGC_SMB2_CREDITS, + ("smb2_validate_message_id: mid %llu (charge %llu), " "credits_granted %llu, " "seqnum low/range: %llu/%llu\n", (unsigned long long) message_id, @@ -710,7 +716,8 @@ static bool smb2_validate_message_id(struct smbXsrv_connection *xconn, (unsigned long long) xconn->smb2.credits.seq_range)); if (xconn->smb2.credits.granted < credit_charge) { - DEBUG(0, ("smb2_validate_message_id: client used more " + DBGC_ERR(DBGC_SMB2_CREDITS, + "smb2_validate_message_id: client used more " "credits than granted, mid %llu, charge %llu, " "credits_granted %llu, " "seqnum low/range: %llu/%llu\n", @@ -718,7 +725,7 @@ static bool smb2_validate_message_id(struct smbXsrv_connection *xconn, (unsigned long long) credit_charge, (unsigned long long) xconn->smb2.credits.granted, (unsigned long long) xconn->smb2.credits.seq_low, - (unsigned long long) xconn->smb2.credits.seq_range)); + (unsigned long long) xconn->smb2.credits.seq_range); return false; } @@ -734,7 +741,9 @@ static bool smb2_validate_message_id(struct smbXsrv_connection *xconn, uint64_t id = message_id + i; bool ok; - DEBUG(11, ("Iterating mid %llu charge %u (sequence %llu)\n", + DEBUGC(11, + DBGC_SMB2_CREDITS, + ("Iterating mid %llu charge %u (sequence %llu)\n", (unsigned long long)message_id, credit_charge, (unsigned long long)id)); @@ -912,7 +921,8 @@ static void smb2_set_operation_credit(struct smbXsrv_connection *xconn, xconn->smb2.credits.granted += credits_granted; xconn->smb2.credits.seq_range += credits_granted; - DEBUG(10,("smb2_set_operation_credit: requested %u, charge %u, " + DBGC_DEBUG(DBGC_SMB2_CREDITS, + "smb2_set_operation_credit: requested %u, charge %u, " "granted %u, current possible/max %u/%u, " "total granted/max/low/range %u/%u/%llu/%u\n", (unsigned int)credits_requested, @@ -923,7 +933,7 @@ static void smb2_set_operation_credit(struct smbXsrv_connection *xconn, (unsigned int)xconn->smb2.credits.granted, (unsigned int)xconn->smb2.credits.max, (unsigned long long)xconn->smb2.credits.seq_low, - (unsigned int)xconn->smb2.credits.seq_range)); + (unsigned int)xconn->smb2.credits.seq_range); } static void smb2_calculate_credits(const struct smbd_smb2_request *inreq, @@ -1981,13 +1991,15 @@ NTSTATUS smbd_smb2_request_verify_creditcharge(struct smbd_smb2_request *req, needed_charge = (data_length - 1)/ 65536 + 1; - DEBUG(10, ("mid %llu, CreditCharge: %d, NeededCharge: %d\n", + DBGC_DEBUG(DBGC_SMB2_CREDITS, + "mid %llu, CreditCharge: %d, NeededCharge: %d\n", (unsigned long long) BVAL(inhdr, SMB2_HDR_MESSAGE_ID), - credit_charge, needed_charge)); + credit_charge, needed_charge); if (needed_charge > credit_charge) { - DEBUG(2, ("CreditCharge too low, given %d, needed %d\n", - credit_charge, needed_charge)); + DBGC_WARNING(DBGC_SMB2_CREDITS, + "CreditCharge too low, given %d, needed %d\n", + credit_charge, needed_charge); return NT_STATUS_INVALID_PARAMETER; } -- 2.17.0.rc0.231.g781580f067-goog From 710a63083d015399bd4bfc4e02bef2a51a60df6d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Mar 2018 12:56:12 -0700 Subject: [PATCH 4/4] s3: docs: Add documentation for "smb2" and "smb2_credits" debug classes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://bugzilla.samba.org/show_bug.cgi?id=13347 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme (cherry picked from commit fc922bd29b40a20450f16728fa7347f8f83d3bcd) --- docs-xml/smbdotconf/logging/loglevel.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs-xml/smbdotconf/logging/loglevel.xml b/docs-xml/smbdotconf/logging/loglevel.xml index 1a3767d1472..d3b5c457d0c 100644 --- a/docs-xml/smbdotconf/logging/loglevel.xml +++ b/docs-xml/smbdotconf/logging/loglevel.xml @@ -22,6 +22,8 @@ printdrivers lanman smb + smb2 + smb2_credits rpc_parse rpc_srv rpc_cli -- 2.17.0.rc0.231.g781580f067-goog