Skip to contentSkip to conversation

Rework SCTP debugging framework

PATCH Superseded Daniel Borkmann 2 participants 9 messages Jun 28, 2013

Subsystems (6)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Rework SCTP debugging framework

Please see patch 2 for a detailed description. Tested with lksctp-tools suite and other stress tests. For the changes between v1,v2,v3, please have a look into the individual patches.

Thanks for feedback/comments to Vlad Yasevich, Neil Horman, Joe Perches, Andy Shevchenko.

Daniel Borkmann (2):
lib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier
net: sctp: rework debugging framework to use pr_debug and friends

 Documentation/printk-formats.txt |  32 ++++++++
 include/net/sctp/sctp.h          |  75 -----------------
 lib/vsprintf.c                   | 108 ++++++++++++++++++++++++-
 net/sctp/Kconfig                 |  12 +--
 net/sctp/associola.c             |  67 ++++++++--------
 net/sctp/chunk.c                 |   5 +-
 net/sctp/debug.c                 |   4 -
 net/sctp/endpointola.c           |   5 +-
 net/sctp/input.c                 |   6 +-
 net/sctp/inqueue.c               |   9 +--
 net/sctp/ipv6.c                  |  21 ++---
 net/sctp/output.c                |  40 ++++------
 net/sctp/outqueue.c              | 160 ++++++++++++++++---------------------
 net/sctp/protocol.c              |  48 +++++------
 net/sctp/sm_make_chunk.c         |  25 +++---
 net/sctp/sm_sideeffect.c         |  96 ++++++++++------------
 net/sctp/sm_statefuns.c          |  77 +++++++++++-------
 net/sctp/socket.c                | 168 +++++++++++++++++++--------------------
 net/sctp/transport.c             |  49 ++++++------
 19 files changed, 521 insertions(+), 486 deletions(-)
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH v3 1/2 lib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier

In order to avoid making code that deals with printing both, IPv4 and IPv6 addresses, unnecessary complicated as for example ...

  if (sa.sa_family = AF_INET6)
    printk("... %pI6 ...", ..sin6_addr);
  else
    printk("... %pI4 ...", ..sin_addr.s_addr);

... it would be better to introduce a format specifier that can deal with those kind of situations internally; just as we have a "struct sockaddr" for generic mapping into "struct sockaddr_in" or "struct sockaddr_in6" as e.g. done in "union sctp_addr". Then, we could reduce the above statement into something like:

  printk("... %pIS ..", &sockaddr);

In case our pointer is NULL, pointer() then deals with that already at an earlier point in time internally. While we're at it, support for both %piS/%pIS, where 'S' stands for sockaddr, comes (almost) for free.

Additionally to that, postfix specifiers 'p', 'f' and 's' are supported as suggested and initially implemented in 2009 by Joe Perches [1]. Handling of those additional specifiers orientate on the initial RFC that was proposed. Also we support IPv6 compressed format specified by 'c' and various other IPv4 extensions as stated in the documentation part.

Likely, there are many other areas than just SCTP in the kernel to make use of this extension as well.

[1] http://patchwork.ozlabs.org/patch/31480/

---
v1->v2:
- Added documentation into printk-formats.txt
- Changed %pig/%pIg into %piS/%pIS
- Changed braces/indent in pointer()
- Also CC lkml
v2->v3:
- Reworked entire patch to include port, flowinfo, scope and others
- Various printk tests with these new specifiers
- Improved documentation

 Documentation/printk-formats.txt |  32 ++++++++++++
 lib/vsprintf.c                   | 108 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 138 insertions(+), 2 deletions(-)
Documentation/printk-formats.txt +32 -0
index 3af5ae6..3d4b76f 100644
@@ -121,6 +121,38 @@ IPv6 addresses:
 	print a compressed IPv6 address as described by
 	http://tools.ietf.org/html/rfc5952
 
+IPv4/IPv6 addresses (generic, with port, flowinfo, scope):
+
+	%pIS	1.2.3.4		or 0001:0002:0003:0004:0005:0006:0007:0008
+	%piS	001.002.003.004	or 00010002000300040005000600070008
+	%pISc	1.2.3.4		or 1:2:3:4:5:6:7:8
+	%pISpc	1.2.3.4:12345	or [1:2:3:4:5:6:7:8]:12345
+	%p[Ii]S[p][hnblcfs]
+
+	For printing an IP address without the need to distinguish whether it's
+	of type AF_INET or AF_INET6, a pointer to a valid 'struct sockaddr',
+	specified through 'IS' or 'iS', can be passed to this format specifier.
+
+	The additional 'p', 'f', and 's' specifiers are used to specify port
+	(IPv4, IPv6), flowinfo (IPv6) and scope (IPv6). Ports have a ':' prefix,
+	flowinfo a '/' and scope a '%', each followed by the actual value.
+
+	In case of an IPv6 address the compressed IPv6 address as described by
+	http://tools.ietf.org/html/rfc5952 is being used if the additional
+	specifier 'c' is given. The IPv6 address is surrounded by '[', ']' in
+	case of additional specifiers 'p', 'f' or 's' as suggested by
+	https://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-07
+
+	In case of IPv4 addresses, the additional 'h', 'n', 'b', and 'l'
+	specifiers can be used as well and are ignored in case of an IPv6
+	address.
+
+	Further examples:
+
+	%pISfc		1.2.3.4		or [1:2:3:4:5:6:7:8]/123456789
+	%pISsc		1.2.3.4		or [1:2:3:4:5:6:7:8]%1234567890
+	%pISpfc		1.2.3.4:12345	or [1:2:3:4:5:6:7:8]:12345/123456789
+
 UUID/GUID addresses:
 
 	%pUb	00010203-0405-0607-0809-0a0b0c0d0e0f
lib/vsprintf.c +106 -2

135 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#2 lore raw

Re: [PATCH net-next v3 1/2] lib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier

Quoted 2 lines · Daniel Borkmann

In order to avoid making code that deals with printing both, IPv4 and IPv6 addresses, unnecessary complicated as for example ...

Thanks Daniel, seems sensible. Just trivial comments...

[]

lib/vsprintf.c

Quoted 1 line
lib/vsprintf.c +0 -0

[]

Should any other include other than net/addrconf be needed?

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 928

Quoted 3 lines
lib/vsprintf.c +3 -0
+char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa,
+			 struct printf_spec spec, const char *fmt)
+{

[]

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 935

Quoted 1 line
lib/vsprintf.c +1 -0
+	char fmt6[2] = { fmt[0], '6'};

This looks odd to me. why not use a bool compressed flag and identify this before the isalpha loop and not have fmt6 at all?

Quoted 19 lines
lib/vsprintf.c +19 -0
+	u8 off = 0;
+
+	fmt++;
+	while (isalpha(*++fmt)) {
+		switch (*fmt) {
+		case 'p':
+			have_p = true;
+			break;
+		case 'f':
+			have_f = true;
+			break;
+		case 's':
+			have_s = true;
+			break;
+		case 'c':
+			have_c = true;
+			break;
+		}
+	}
#3 lore raw

Re: [PATCH net-next v3 1/2] lib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier

Quoted 5 lines · Joe Perches
Quoted 2 lines · Daniel Borkmann

In order to avoid making code that deals with printing both, IPv4 and IPv6 addresses, unnecessary complicated as for example ...

Thanks Daniel, seems sensible. Just trivial comments...

Ok, thanks.

Quoted 6 lines

[]

lib/vsprintf.c

Quoted 1 line
lib/vsprintf.c +0 -0

[]

Should any other include other than net/addrconf be needed?

I'm not sure I understand this question.

Quoted 9 lines

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 928

Quoted 3 lines
lib/vsprintf.c +3 -0
+char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa,
+			 struct printf_spec spec, const char *fmt)
+{

[]

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 935

Quoted 1 line
lib/vsprintf.c +1 -0
+	char fmt6[2] = { fmt[0], '6'};

This looks odd to me. why not use a bool compressed flag and identify this before the isalpha loop and not have fmt6 at all?

Well, we have a bool called 'have_c' that identifies if 'c' was specified. To have the same behaviour as with %pI6, this is used to create a temporary fmt that we then can pass to ip6_string(). If you look at ip6_addr_string(), it's done the same way, and by that, we stay compatible in behaviour.

Quoted 21 lines
Quoted 19 lines
lib/vsprintf.c +19 -0
+	u8 off = 0;
+
+	fmt++;
+	while (isalpha(*++fmt)) {
+		switch (*fmt) {
+		case 'p':
+			have_p = true;
+			break;
+		case 'f':
+			have_f = true;
+			break;
+		case 's':
+			have_s = true;
+			break;
+		case 'c':
+			have_c = true;
+			break;
+		}
+	}
#4 lore raw

Re: [PATCH net-next v3 1/2] lib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier

Quoted 4 lines · Daniel Borkmann
Quoted 3 lines · Joe Perches
Quoted 2 lines · Daniel Borkmann

In order to avoid making code that deals with printing both, IPv4 and IPv6 addresses, unnecessary complicated as for example ...

[]

Quoted 2 lines
Quoted 1 line

Should any other include other than net/addrconf be needed?

I'm not sure I understand this question.

the #include <net/addrconf.h> indirectly includes <linux/in.h> and <linux/in6.h>
but because this now uses struct sockaddr and family it may be more sensible to directly include those.

No worries really, it works now.

Quoted 10 lines
Quoted 9 lines

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 928

Quoted 3 lines
lib/vsprintf.c +3 -0
+char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa,
+			 struct printf_spec spec, const char *fmt)
+{

[]

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 935

Quoted 1 line
lib/vsprintf.c +1 -0
+	char fmt6[2] = { fmt[0], '6'};

This looks odd to me. why not use a bool compressed flag and identify this before the isalpha loop and not have fmt6 at all?

Quoted 3 lines

Well, we have a bool called 'have_c' that identifies if 'c' was specified. To have the same behaviour as with %pI6, this is used to create a temporary fmt that we then can pass to ip6_string(). If you look at ip6_addr_string(), it's done the same way,

It's a little different than that.

Quoted 1 line

and by that, we stay compatible in behaviour.

That's slightly tricky, ip6_addr_string just needs "I" or "i"

But, your implementation, your choice,

cheers, Joe

#5 lore raw

Re: [PATCH net-next v3 1/2] lib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier

Quoted 30 lines · Joe Perches
Quoted 4 lines · Daniel Borkmann
Quoted 3 lines · Joe Perches
Quoted 2 lines · Daniel Borkmann

In order to avoid making code that deals with printing both, IPv4 and IPv6 addresses, unnecessary complicated as for example ...

[]

Quoted 2 lines
Quoted 1 line

Should any other include other than net/addrconf be needed?

I'm not sure I understand this question.

the #include <net/addrconf.h> indirectly includes <linux/in.h> and <linux/in6.h>
but because this now uses struct sockaddr and family it may be more sensible to directly include those.

No worries really, it works now.

Quoted 10 lines
Quoted 9 lines

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 928

Quoted 3 lines
lib/vsprintf.c +3 -0
+char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa,
+			 struct printf_spec spec, const char *fmt)
+{

[]

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 935

Quoted 1 line
lib/vsprintf.c +1 -0
+	char fmt6[2] = { fmt[0], '6'};

This looks odd to me. why not use a bool compressed flag and identify this before the isalpha loop and not have fmt6 at all?

Quoted 3 lines

Well, we have a bool called 'have_c' that identifies if 'c' was specified. To have the same behaviour as with %pI6, this is used to create a temporary fmt that we then can pass to ip6_string(). If you look at ip6_addr_string(), it's done the same way,

Quoted 7 lines

It's a little different than that.

Quoted 1 line

and by that, we stay compatible in behaviour.

That's slightly tricky, ip6_addr_string just needs "I" or "i"

But, your implementation, your choice,

Ok, I suggest we leave it as posted.

Just to clarify, as a side note: fmt layout is { '[Ii]', '6', 'c' } where the 'c' is optional (so fmt[2] can also be 0), but still tested:

static noinline_for_stack
char *ip6_addr_string(char *buf, char *end, const u8 *addr,
struct printf_spec spec, const char *fmt)

{
	char ip6_addr[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")];

	if (fmt[0] = 'I' && fmt[2] = 'c')
		ip6_compressed_string(ip6_addr, addr);
	else
		ip6_string(ip6_addr, addr, fmt);

	return string(buf, end, ip6_addr, spec);
}

In the patch, those conditions are respected as well.

Thanks,

Daniel

#6 lore raw

Re: [PATCH net-next v3 1/2] lib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier

In reply to Daniel Borkmann
Quoted 15 lines · Daniel Borkmann
Quoted 5 lines · Joe Perches
Quoted 2 lines · Daniel Borkmann

In order to avoid making code that deals with printing both, IPv4 and IPv6 addresses, unnecessary complicated as for example ...

Thanks Daniel, seems sensible. Just trivial comments...

Ok, thanks.

Quoted 6 lines

[]

lib/vsprintf.c

Quoted 1 line
lib/vsprintf.c +0 -0

[]

Should any other include other than net/addrconf be needed?

Ah, you mean net/addrconf.h, ok got it. Hm, well, I've compiled and tested it, no warning or error on my side.

Quoted 43 lines

I'm not sure I understand this question.

Quoted 9 lines

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 928

Quoted 3 lines
lib/vsprintf.c +3 -0
+char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa,
+             struct printf_spec spec, const char *fmt)
+{

[]

Quoted 1 line

+ char fmt6[2] = { fmt[0], '6'};

This looks odd to me. why not use a bool compressed flag and identify this before the isalpha loop and not have fmt6 at all?

Well, we have a bool called 'have_c' that identifies if 'c' was specified. To have the same behaviour as with %pI6, this is used to create a temporary fmt that we then can pass to ip6_string(). If you look at ip6_addr_string(), it's done the same way, and by that, we stay compatible in behaviour.

Quoted 11 lines
Quoted 11 lines
lib/vsprintf.c +11 -0
+    u8 off = 0;
+
+    fmt++;
+    while (isalpha(*++fmt)) {
+        switch (*fmt) {
+        case 'p':
+            have_p = true;
+            break;
+        case 'f':
+            have_f = true;
+            break;
Quoted 10 lines

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 954

Quoted 8 lines
lib/vsprintf.c +8 -0
+        case 's':
+            have_s = true;
+            break;
+        case 'c':
+            have_c = true;
+            break;
+        }
+    }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#7 lore raw

Re: [PATCH net-next v3 1/2] lib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier

In reply to Daniel Borkmann

lib/vsprintf.c char *ip4_addr_string(char *buf, char *end, const u8 *addr, · line 991

Quoted 5 lines · Daniel Borkmann
lib/vsprintf.c +5 -0
+static noinline_for_stack
+char *ip4_addr_string_sa(char *buf, char *end, const struct sockaddr_in *sa,
+			 struct printf_spec spec, const char *fmt)
+{
+	bool have_p = (fmt[2] && fmt[2] = 'p');
	bool have_p = fmt[2] = 'p';

you don't need the first "fmt[2] &&"
but I can imagine a case where the other flow/scope types could be specified generically and the 'p' may not be in array index 2

I think you should probably do the same while loop like the ip6_addr_string_sa block.

#8 lore raw

PATCH v3 2/2 net: sctp: rework debugging framework to use pr_debug and friends

In reply to Daniel Borkmann

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

---
v1->v2:
- Changed %pIg into %pIS
- Changed WARN in sctp_assoc_rwnd_decrease() into pr_debug
- Changed WARN in sctp_transport_update_rto() into pr_debug (We do not have it when debugging is disabled, so pr_debug is better)
- Removed BUG_ON in sctp_transport_update_rto() since it's unnecessary (If it is NULL we would get a panic in the next instructions anyway)
- Rest is unchanged
v2->v3:
- Updated %pIS occurences to include port where appropriate

follow-up work next week:
- Get rid of Kconfig option 'SCTP_DBG_TSNS' and see if we can remove most of that ifdef'd code

 include/net/sctp/sctp.h  |  75 ---------------------
 net/sctp/Kconfig         |  12 ++--
 net/sctp/associola.c     |  67 ++++++++++---------
 net/sctp/chunk.c         |   5 +-
 net/sctp/debug.c         |   4 --
 net/sctp/endpointola.c   |   5 +-
 net/sctp/input.c         |   6 +-
 net/sctp/inqueue.c       |   9 ++-
 net/sctp/ipv6.c          |  21 +++---
 net/sctp/output.c        |  40 +++++------
 net/sctp/outqueue.c      | 160 ++++++++++++++++++++------------------------
 net/sctp/protocol.c      |  48 +++++++-------
 net/sctp/sm_make_chunk.c |  25 +++----
 net/sctp/sm_sideeffect.c |  96 +++++++++++----------------
 net/sctp/sm_statefuns.c  |  77 +++++++++++++---------
 net/sctp/socket.c        | 168 ++++++++++++++++++++++-------------------------
 net/sctp/transport.c     |  49 +++++++-------
 17 files changed, 383 insertions(+), 484 deletions(-)
include/net/sctp/sctp.h +0 -74
index e6b95bc..d8e37ec 100644
@@ -83,16 +83,6 @@
 #include <net/sctp/structs.h>
 #include <net/sctp/constants.h>
 
-
-/* Set SCTP_DEBUG flag via config if not already set. */
-#ifndef SCTP_DEBUG
-#ifdef CONFIG_SCTP_DBG_MSG
-#define SCTP_DEBUG	1
-#else
-#define SCTP_DEBUG      0
-#endif /* CONFIG_SCTP_DBG */
-#endif /* SCTP_DEBUG */
-
 #ifdef CONFIG_IP_SCTP_MODULE
 #define SCTP_PROTOSW_FLAG 0
 #else /* static! */
@@ -270,61 +260,6 @@ static inline void sctp_max_rto(struct sctp_association *asoc,
 	}
 }
 
-/* Print debugging messages.  */
-#if SCTP_DEBUG
-extern int sctp_debug_flag;
-#define SCTP_DEBUG_PRINTK(fmt, args...)			\
-do {							\
-	if (sctp_debug_flag)				\
-		printk(KERN_DEBUG pr_fmt(fmt), ##args);	\
-} while (0)
-#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)		\
-do {							\
-	if (sctp_debug_flag)				\
-		pr_cont(fmt, ##args);			\
-} while (0)
-#define SCTP_DEBUG_PRINTK_IPADDR(fmt_lead, fmt_trail,			\
-				 args_lead, addr, args_trail...)	\
-do {									\
-	const union sctp_addr *_addr = (addr);				\
-	if (sctp_debug_flag) {						\
-		if (_addr->sa.sa_family = AF_INET6) {			\
-			printk(KERN_DEBUG				\
-			       pr_fmt(fmt_lead "%pI6" fmt_trail),	\
-			       args_lead,				\
-			       &_addr->v6.sin6_addr,			\
-			       args_trail);				\
-		} else {						\
-			printk(KERN_DEBUG				\
-			       pr_fmt(fmt_lead "%pI4" fmt_trail),	\
-			       args_lead,				\
-			       &_addr->v4.sin_addr.s_addr,		\
-			       args_trail);				\
-		}							\
-	}								\
-} while (0)
-#define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; }
-#define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; }
-
-#define SCTP_ASSERT(expr, str, func) \
-	if (!(expr)) { \
-		SCTP_DEBUG_PRINTK("Assertion Failed: %s(%s) at %s:%s:%d\n", \
-			str, (#expr), __FILE__, __func__, __LINE__); \
-		func; \
-	}
-
-#else	/* SCTP_DEBUG */
-
-#define SCTP_DEBUG_PRINTK(whatever...)
-#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
-#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
-#define SCTP_ENABLE_DEBUG
-#define SCTP_DISABLE_DEBUG
-#define SCTP_ASSERT(expr, str, func)
-
-#endif /* SCTP_DEBUG */
-
-
 /*
  * Macros for keeping a global reference of object allocations.
  */
@@ -597,16 +532,6 @@ static inline int param_type2af(__be16 type)
 	}
 }
 
-/* Perform some sanity checks. */
-static inline int sctp_sanity_check(void)
-{
-	SCTP_ASSERT(sizeof(struct sctp_ulpevent) <-		    sizeof(((struct sk_buff *)0)->cb),
-		    "SCTP: ulpevent does not fit in skb!\n", return 0);
-
-	return 1;
-}
-
 /* Warning: The following hash functions assume a power of two 'size'. */
 /* This is the hash function for the SCTP port hash table. */
 static inline int sctp_phashfn(struct net *net, __u16 lport)
net/sctp/Kconfig +7 -5
index cf48528..d80bf1a 100644
@@ -30,7 +30,8 @@ menuconfig IP_SCTP
 	  homing at either or both ends of an association."
 
 	  To compile this protocol support as a module, choose M here: the
-	  module will be called sctp.
+	  module will be called sctp. Debug messages are handeled by the
+	  kernel's dynamic debugging framework.
 
 	  If in doubt, say N.
 
@@ -48,13 +49,14 @@ config NET_SCTPPROBE
         To compile this code as a module, choose M here: the
         module will be called sctp_probe.
 
-config SCTP_DBG_MSG
-	bool "SCTP: Debug messages"
+config SCTP_DBG_TSNS
+	bool "SCTP: Debug transactions"
 	help
-	  If you say Y, this will enable verbose debugging messages. 
+	  If you say Y, this will enable transaction debugging, visible
+	  from the kernel's dynamic debugging framework.
 
 	  If unsure, say N.  However, if you are running into problems, use 
-	  this option to gather detailed trace information
+	  this option to gather outqueue trace information.
 
 config SCTP_DBG_OBJCNT
 	bool "SCTP: Debug object counts"
net/sctp/associola.c +33 -34

133 lines not on this page · raw message

net/sctp/chunk.c +3 -2
index 7135fc0..5780565 100644
@@ -193,8 +193,9 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
 		msg->expires_at = jiffies +
 				    msecs_to_jiffies(sinfo->sinfo_timetolive);
 		msg->can_abandon = 1;
-		SCTP_DEBUG_PRINTK("%s: msg:%p expires_at: %ld jiffies:%ld\n",
-				  __func__, msg, msg->expires_at, jiffies);
+
+		pr_debug("%s: msg:%p expires_at:%ld jiffies:%ld\n", __func__,
+			 msg, msg->expires_at, jiffies);
 	}
 
 	/* This is the biggest possible DATA chunk that can fit into
net/sctp/debug.c +0 -4
index ec997cf..f499878 100644
@@ -47,10 +47,6 @@
 
 #include <net/sctp/sctp.h>
 
-#if SCTP_DEBUG
-int sctp_debug_flag = 1;	/* Initially enable DEBUG */
-#endif	/* SCTP_DEBUG */
-
 /* These are printable forms of Chunk ID's from section 3.1.  */
 static const char *const sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
 	"DATA",
net/sctp/endpointola.c +4 -1
index b26999d..9e3d257 100644
@@ -249,7 +249,10 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
 {
 	struct sock *sk;
 
-	SCTP_ASSERT(ep->base.dead, "Endpoint is not dead", return);
+	if (unlikely(!ep->base.dead)) {
+		WARN(1, "Attempt to destroy undead endpoint %p!\n", ep);
+		return;
+	}
 
 	/* Free the digest buffer */
 	kfree(ep->digest);
net/sctp/input.c +3 -3
index 4cfc746..3fa4d85 100644
@@ -454,8 +454,6 @@ void sctp_icmp_proto_unreachable(struct sock *sk,
 			   struct sctp_association *asoc,
 			   struct sctp_transport *t)
 {
-	SCTP_DEBUG_PRINTK("%s\n",  __func__);
-
 	if (sock_owned_by_user(sk)) {
 		if (timer_pending(&t->proto_unreach_timer))
 			return;
@@ -464,10 +462,12 @@ void sctp_icmp_proto_unreachable(struct sock *sk,
 						jiffies + (HZ/20)))
 				sctp_association_hold(asoc);
 		}
-			
 	} else {
 		struct net *net = sock_net(sk);
 
+		pr_debug("%s: unrecognized next header type "
+			 "encountered!\n", __func__);
+
 		if (del_timer(&t->proto_unreach_timer))
 			sctp_association_put(asoc);
 
net/sctp/inqueue.c +4 -5
index 3221d07..cb25f04 100644
@@ -219,10 +219,10 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
 		chunk->end_of_packet = 1;
 	}
 
-	SCTP_DEBUG_PRINTK("+++sctp_inq_pop+++ chunk %p[%s],"
-			  " length %d, skb->len %d\n",chunk,
-			  sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)),
-			  ntohs(chunk->chunk_hdr->length), chunk->skb->len);
+	pr_debug("+++sctp_inq_pop+++ chunk:%p[%s], length:%d, skb->len:%d\n",
+		 chunk, sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)),
+		 ntohs(chunk->chunk_hdr->length), chunk->skb->len);
+
 	return chunk;
 }
 
@@ -238,4 +238,3 @@ void sctp_inq_set_th_handler(struct sctp_inq *q, work_func_t callback)
 {
 	INIT_WORK(&q->immediate, callback);
 }
-
net/sctp/ipv6.c +12 -9
index adeaa0e..09ffcc9 100644
@@ -239,9 +239,8 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
 		fl6.daddr = *rt0->addr;
 	}
 
-	SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n",
-			  __func__, skb, skb->len,
-			  &fl6.saddr, &fl6.daddr);
+	pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb,
+		 skb->len, &fl6.saddr, &fl6.daddr);
 
 	SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
 
@@ -276,7 +275,7 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
 	if (ipv6_addr_type(&daddr->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL)
 		fl6->flowi6_oif = daddr->v6.sin6_scope_id;
 
-	SCTP_DEBUG_PRINTK("%s: DST=%pI6 ", __func__, &fl6->daddr);
+	pr_debug("%s: dst=%pI6 ", __func__, &fl6->daddr);
 
 	if (asoc)
 		fl6->fl6_sport = htons(asoc->base.bind_addr.port);
@@ -284,7 +283,8 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
 	if (saddr) {
 		fl6->saddr = saddr->v6.sin6_addr;
 		fl6->fl6_sport = saddr->v6.sin6_port;
-		SCTP_DEBUG_PRINTK("SRC=%pI6 - ", &fl6->saddr);
+
+		pr_debug("src=%pI6 - ", &fl6->saddr);
 	}
 
 	dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
@@ -348,13 +348,16 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
 out:
 	if (!IS_ERR_OR_NULL(dst)) {
 		struct rt6_info *rt;
+
 		rt = (struct rt6_info *)dst;
 		t->dst = dst;
-		SCTP_DEBUG_PRINTK("rt6_dst:%pI6 rt6_src:%pI6\n",
-			&rt->rt6i_dst.addr, &fl6->saddr);
+
+		pr_debug("rt6_dst:%pI6 rt6_src:%pI6\n", &rt->rt6i_dst.addr,
+			 &fl6->saddr);
 	} else {
 		t->dst = NULL;
-		SCTP_DEBUG_PRINTK("NO ROUTE\n");
+
+		pr_debug("no route\n");
 	}
 }
 
@@ -377,7 +380,7 @@ static void sctp_v6_get_saddr(struct sctp_sock *sk,
 	struct flowi6 *fl6 = &fl->u.ip6;
 	union sctp_addr *saddr = &t->saddr;
 
-	SCTP_DEBUG_PRINTK("%s: asoc:%p dst:%p\n", __func__, t->asoc, t->dst);
+	pr_debug("%s: asoc:%p dst:%p\n", __func__, t->asoc, t->dst);
 
 	if (t->dst) {
 		saddr->v6.sin6_family = AF_INET6;
net/sctp/output.c +17 -23
index bbef4a7..4948293 100644
@@ -93,8 +93,7 @@ struct sctp_packet *sctp_packet_config(struct sctp_packet *packet,
 {
 	struct sctp_chunk *chunk = NULL;
 
-	SCTP_DEBUG_PRINTK("%s: packet:%p vtag:0x%x\n", __func__,
-			  packet, vtag);
+	pr_debug("%s: packet:%p vtag:0x%x\n", __func__, packet, vtag);
 
 	packet->vtag = vtag;
 
@@ -119,8 +118,7 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet,
 	struct sctp_association *asoc = transport->asoc;
 	size_t overhead;
 
-	SCTP_DEBUG_PRINTK("%s: packet:%p transport:%p\n", __func__,
-			  packet, transport);
+	pr_debug("%s: packet:%p transport:%p\n", __func__, packet, transport);
 
 	packet->transport = transport;
 	packet->source_port = sport;
@@ -145,7 +143,7 @@ void sctp_packet_free(struct sctp_packet *packet)
 {
 	struct sctp_chunk *chunk, *tmp;
 
-	SCTP_DEBUG_PRINTK("%s: packet:%p\n", __func__, packet);
+	pr_debug("%s: packet:%p\n", __func__, packet);
 
 	list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) {
 		list_del_init(&chunk->list);
@@ -167,8 +165,7 @@ sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *packet,
 	sctp_xmit_t retval;
 	int error = 0;
 
-	SCTP_DEBUG_PRINTK("%s: packet:%p chunk:%p\n", __func__,
-			  packet, chunk);
+	pr_debug("%s: packet:%p chunk:%p\n", __func__, packet, chunk);
 
 	switch ((retval = (sctp_packet_append_chunk(packet, chunk)))) {
 	case SCTP_XMIT_PMTU_FULL:
@@ -334,8 +331,7 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
 {
 	sctp_xmit_t retval = SCTP_XMIT_OK;
 
-	SCTP_DEBUG_PRINTK("%s: packet:%p chunk:%p\n", __func__, packet,
-			  chunk);
+	pr_debug("%s: packet:%p chunk:%p\n", __func__, packet, chunk);
 
 	/* Data chunks are special.  Before seeing what else we can
 	 * bundle into this packet, check to see if we are allowed to
@@ -402,7 +398,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
 	unsigned char *auth = NULL;	/* pointer to auth in skb data */
 	__u32 cksum_buf_len = sizeof(struct sctphdr);
 
-	SCTP_DEBUG_PRINTK("%s: packet:%p\n", __func__, packet);
+	pr_debug("%s: packet:%p\n", __func__, packet);
 
 	/* Do NOT generate a chunkless packet. */
 	if (list_empty(&packet->chunk_list))
@@ -472,7 +468,9 @@ int sctp_packet_transmit(struct sctp_packet *packet)
 	 *
 	 * [This whole comment explains WORD_ROUND() below.]
 	 */
-	SCTP_DEBUG_PRINTK("***sctp_transmit_packet***\n");
+
+	pr_debug("***sctp_transmit_packet***\n");
+
 	list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) {
 		list_del_init(&chunk->list);
 		if (sctp_chunk_is_data(chunk)) {
@@ -505,16 +503,13 @@ int sctp_packet_transmit(struct sctp_packet *packet)
 		memcpy(skb_put(nskb, chunk->skb->len),
 			       chunk->skb->data, chunk->skb->len);
 
-		SCTP_DEBUG_PRINTK("%s %p[%s] %s 0x%x, %s %d, %s %d, %s %d\n",
-				  "*** Chunk", chunk,
-				  sctp_cname(SCTP_ST_CHUNK(
-					  chunk->chunk_hdr->type)),
-				  chunk->has_tsn ? "TSN" : "No TSN",
-				  chunk->has_tsn ?
-				  ntohl(chunk->subh.data_hdr->tsn) : 0,
-				  "length", ntohs(chunk->chunk_hdr->length),
-				  "chunk->skb->len", chunk->skb->len,
-				  "rtt_in_progress", chunk->rtt_in_progress);
+		pr_debug("*** Chunk:%p[%s] %s 0x%x, length:%d, chunk->skb->len:%d, "
+			 "rtt_in_progress:%d\n", chunk,
+			 sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)),
+			 chunk->has_tsn ? "TSN" : "No TSN",
+			 chunk->has_tsn ? ntohl(chunk->subh.data_hdr->tsn) : 0,
+			 ntohs(chunk->chunk_hdr->length), chunk->skb->len,
+			 chunk->rtt_in_progress);
 
 		/*
 		 * If this is a control chunk, this is our last
@@ -606,8 +601,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
 		}
 	}
 
-	SCTP_DEBUG_PRINTK("***sctp_transmit_packet*** skb len %d\n",
-			  nskb->len);
+	pr_debug("***sctp_transmit_packet*** skb->len:%d\n", nskb->len);
 
 	nskb->local_df = packet->ipfragok;
 	(*tp->af_specific->sctp_xmit)(nskb, tp);
net/sctp/outqueue.c +70 -90

301 lines not on this page · raw message

net/sctp/protocol.c +25 -23

108 lines not on this page · raw message

net/sctp/sm_make_chunk.c +14 -11
index dd71f1f..362ae6e 100644
@@ -741,7 +741,8 @@ struct sctp_chunk *sctp_make_sack(const struct sctp_association *asoc)
 
 	memset(gabs, 0, sizeof(gabs));
 	ctsn = sctp_tsnmap_get_ctsn(map);
-	SCTP_DEBUG_PRINTK("sackCTSNAck sent:  0x%x.\n", ctsn);
+
+	pr_debug("%s: sackCTSNAck sent:0x%x\n", __func__, ctsn);
 
 	/* How much room is needed in the chunk? */
 	num_gabs = sctp_tsnmap_num_gabs(map, gabs);
@@ -1287,10 +1288,8 @@ struct sctp_chunk *sctp_chunkify(struct sk_buff *skb,
 
 	if (!retval)
 		goto nodata;
-
-	if (!sk) {
-		SCTP_DEBUG_PRINTK("chunkifying skb %p w/o an sk\n", skb);
-	}
+	if (!sk)
+		pr_debug("%s: chunkifying skb:%p w/o an sk\n", __func__, skb);
 
 	INIT_LIST_HEAD(&retval->list);
 	retval->skb		= skb;
@@ -2191,8 +2190,9 @@ static sctp_ierror_t sctp_verify_param(struct net *net,
 		break;
 fallthrough:
 	default:
-		SCTP_DEBUG_PRINTK("Unrecognized param: %d for chunk %d.\n",
-				ntohs(param.p->type), cid);
+		pr_debug("%s: unrecognized param:%d for chunk:%d\n",
+			 __func__, ntohs(param.p->type), cid);
+
 		retval = sctp_process_unk_param(asoc, param, chunk, err_chunk);
 		break;
 	}
@@ -2516,7 +2516,7 @@ do_addr_param:
 		break;
 
 	case SCTP_PARAM_HOST_NAME_ADDRESS:
-		SCTP_DEBUG_PRINTK("unimplemented SCTP_HOST_NAME_ADDRESS\n");
+		pr_debug("%s: unimplemented SCTP_HOST_NAME_ADDRESS\n", __func__);
 		break;
 
 	case SCTP_PARAM_SUPPORTED_ADDRESS_TYPES:
@@ -2662,8 +2662,8 @@ fall_through:
 		 * called prior to this routine.  Simply log the error
 		 * here.
 		 */
-		SCTP_DEBUG_PRINTK("Ignoring param: %d for association %p.\n",
-				  ntohs(param.p->type), asoc);
+		pr_debug("%s: ignoring param:%d for association:%p.\n",
+			 __func__, ntohs(param.p->type), asoc);
 		break;
 	}
 
@@ -2805,7 +2805,10 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
 			totallen += paramlen;
 			totallen += addr_param_len;
 			del_pickup = 1;
-			SCTP_DEBUG_PRINTK("mkasconf_update_ip: picked same-scope del_pending addr, totallen for all addresses is %d\n", totallen);
+
+			pr_debug("%s: picked same-scope del_pending addr, "
+				 "totallen for all addresses is %d\n",
+				 __func__, totallen);
 		}
 	}
 
net/sctp/sm_sideeffect.c +40 -56

189 lines not on this page · raw message

net/sctp/sm_statefuns.c +47 -30

205 lines not on this page · raw message

net/sctp/socket.c +80 -88

430 lines not on this page · raw message

net/sctp/transport.c +24 -25

85 lines not on this page · raw message

Signature · 1 line
1.7.11.7