aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-28 13:49:40 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-02 02:22:13 -0400
commitbb33381d0c97cdee25f2cdab540b6e2bd16fa03b (patch)
treea4def6ec9f554908e07efa8671ca52f60f9a2a18 /include
parent1067964305df131ede2c08c2f3c9b3892640f1c6 (diff)
net: sctp: rework debugging framework to use pr_debug and friends
We should get rid of all own SCTP debug printk macros and use the ones that the kernel offers anyway instead. This makes the code more readable and conform to the kernel code, and offers all the features of dynamic debbuging that pr_debug() et al has, such as only turning on/off portions of debug messages at runtime through debugfs. The runtime cost of having CONFIG_DYNAMIC_DEBUG enabled, but none of the debug statements printing, is negligible [1]. If kernel debugging is completly turned off, then these statements will also compile into "empty" functions. While we're at it, we also need to change the Kconfig option as it /now/ only refers to the ifdef'ed code portions in outqueue.c that enable further debugging/tracing of SCTP transaction fields. Also, since SCTP_ASSERT code was enabled with this Kconfig option and has now been removed, we transform those code parts into WARNs resp. where appropriate BUG_ONs so that those bugs can be more easily detected as probably not many people have SCTP debugging permanently turned on. To turn on all SCTP debugging, the following steps are needed: # mount -t debugfs none /sys/kernel/debug # echo -n 'module sctp +p' > /sys/kernel/debug/dynamic_debug/control This can be done more fine-grained on a per file, per line basis and others as described in [2]. [1] https://www.kernel.org/doc/ols/2009/ols2009-pages-39-46.pdf [2] Documentation/dynamic-debug-howto.txt Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/sctp/sctp.h75
1 files changed, 0 insertions, 75 deletions
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index e6b95bc4d8e6..d8e37ecea691 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -83,16 +83,6 @@
83#include <net/sctp/structs.h> 83#include <net/sctp/structs.h>
84#include <net/sctp/constants.h> 84#include <net/sctp/constants.h>
85 85
86
87/* Set SCTP_DEBUG flag via config if not already set. */
88#ifndef SCTP_DEBUG
89#ifdef CONFIG_SCTP_DBG_MSG
90#define SCTP_DEBUG 1
91#else
92#define SCTP_DEBUG 0
93#endif /* CONFIG_SCTP_DBG */
94#endif /* SCTP_DEBUG */
95
96#ifdef CONFIG_IP_SCTP_MODULE 86#ifdef CONFIG_IP_SCTP_MODULE
97#define SCTP_PROTOSW_FLAG 0 87#define SCTP_PROTOSW_FLAG 0
98#else /* static! */ 88#else /* static! */
@@ -270,61 +260,6 @@ static inline void sctp_max_rto(struct sctp_association *asoc,
270 } 260 }
271} 261}
272 262
273/* Print debugging messages. */
274#if SCTP_DEBUG
275extern int sctp_debug_flag;
276#define SCTP_DEBUG_PRINTK(fmt, args...) \
277do { \
278 if (sctp_debug_flag) \
279 printk(KERN_DEBUG pr_fmt(fmt), ##args); \
280} while (0)
281#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) \
282do { \
283 if (sctp_debug_flag) \
284 pr_cont(fmt, ##args); \
285} while (0)
286#define SCTP_DEBUG_PRINTK_IPADDR(fmt_lead, fmt_trail, \
287 args_lead, addr, args_trail...) \
288do { \
289 const union sctp_addr *_addr = (addr); \
290 if (sctp_debug_flag) { \
291 if (_addr->sa.sa_family == AF_INET6) { \
292 printk(KERN_DEBUG \
293 pr_fmt(fmt_lead "%pI6" fmt_trail), \
294 args_lead, \
295 &_addr->v6.sin6_addr, \
296 args_trail); \
297 } else { \
298 printk(KERN_DEBUG \
299 pr_fmt(fmt_lead "%pI4" fmt_trail), \
300 args_lead, \
301 &_addr->v4.sin_addr.s_addr, \
302 args_trail); \
303 } \
304 } \
305} while (0)
306#define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; }
307#define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; }
308
309#define SCTP_ASSERT(expr, str, func) \
310 if (!(expr)) { \
311 SCTP_DEBUG_PRINTK("Assertion Failed: %s(%s) at %s:%s:%d\n", \
312 str, (#expr), __FILE__, __func__, __LINE__); \
313 func; \
314 }
315
316#else /* SCTP_DEBUG */
317
318#define SCTP_DEBUG_PRINTK(whatever...)
319#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
320#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
321#define SCTP_ENABLE_DEBUG
322#define SCTP_DISABLE_DEBUG
323#define SCTP_ASSERT(expr, str, func)
324
325#endif /* SCTP_DEBUG */
326
327
328/* 263/*
329 * Macros for keeping a global reference of object allocations. 264 * Macros for keeping a global reference of object allocations.
330 */ 265 */
@@ -597,16 +532,6 @@ static inline int param_type2af(__be16 type)
597 } 532 }
598} 533}
599 534
600/* Perform some sanity checks. */
601static inline int sctp_sanity_check(void)
602{
603 SCTP_ASSERT(sizeof(struct sctp_ulpevent) <=
604 sizeof(((struct sk_buff *)0)->cb),
605 "SCTP: ulpevent does not fit in skb!\n", return 0);
606
607 return 1;
608}
609
610/* Warning: The following hash functions assume a power of two 'size'. */ 535/* Warning: The following hash functions assume a power of two 'size'. */
611/* This is the hash function for the SCTP port hash table. */ 536/* This is the hash function for the SCTP port hash table. */
612static inline int sctp_phashfn(struct net *net, __u16 lport) 537static inline int sctp_phashfn(struct net *net, __u16 lport)