aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/associola.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-28 19:49:40 +0200
committerDavid S. Miller <davem@davemloft.net>2013-07-01 23:22:13 -0700
commitbb33381d0c97cdee25f2cdab540b6e2bd16fa03b (patch)
treea4def6ec9f554908e07efa8671ca52f60f9a2a18 /net/sctp/associola.c
parentlib: vsprintf: add IPv4/v6 generic %p[Ii]S[pfs] format specifier (diff)
downloadlinux-dev-bb33381d0c97cdee25f2cdab540b6e2bd16fa03b.tar.xz
linux-dev-bb33381d0c97cdee25f2cdab540b6e2bd16fa03b.zip
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 'net/sctp/associola.c')
-rw-r--r--net/sctp/associola.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 9a383a8774e8..bce5b79662a6 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -357,7 +357,8 @@ struct sctp_association *sctp_association_new(const struct sctp_endpoint *ep,
goto fail_init;
SCTP_DBG_OBJCNT_INC(assoc);
- SCTP_DEBUG_PRINTK("Created asoc %p\n", asoc);
+
+ pr_debug("Created asoc %p\n", asoc);
return asoc;
@@ -455,7 +456,10 @@ void sctp_association_free(struct sctp_association *asoc)
/* Cleanup and free up an association. */
static void sctp_association_destroy(struct sctp_association *asoc)
{
- SCTP_ASSERT(asoc->base.dead, "Assoc is not dead", return);
+ if (unlikely(!asoc->base.dead)) {
+ WARN(1, "Attempt to destroy undead association %p!\n", asoc);
+ return;
+ }
sctp_endpoint_put(asoc->ep);
sock_put(asoc->base.sk);
@@ -536,11 +540,8 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
struct list_head *pos;
struct sctp_transport *transport;
- SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_rm_peer:association %p addr: ",
- " port: %d\n",
- asoc,
- (&peer->ipaddr),
- ntohs(peer->ipaddr.v4.sin_port));
+ pr_debug("%s: association:%p addr:%pISpc\n",
+ __func__, asoc, &peer->ipaddr.sa);
/* If we are to remove the current retran_path, update it
* to the next peer before removing this peer from the list.
@@ -636,12 +637,8 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
/* AF_INET and AF_INET6 share common port field. */
port = ntohs(addr->v4.sin_port);
- SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ",
- " port: %d state:%d\n",
- asoc,
- addr,
- port,
- peer_state);
+ pr_debug("%s: association:%p addr:%pISpc state:%d\n", __func__,
+ asoc, &addr->sa, peer_state);
/* Set the port if it has not been set yet. */
if (0 == asoc->peer.port)
@@ -708,8 +705,9 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
else
asoc->pathmtu = peer->pathmtu;
- SCTP_DEBUG_PRINTK("sctp_assoc_add_peer:association %p PMTU set to "
- "%d\n", asoc, asoc->pathmtu);
+ pr_debug("%s: association:%p PMTU set to %d\n", __func__, asoc,
+ asoc->pathmtu);
+
peer->pmtu_pending = 0;
asoc->frag_point = sctp_frag_point(asoc, asoc->pathmtu);
@@ -1349,12 +1347,8 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc)
else
t = asoc->peer.retran_path;
- SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association"
- " %p addr: ",
- " port: %d\n",
- asoc,
- (&t->ipaddr),
- ntohs(t->ipaddr.v4.sin_port));
+ pr_debug("%s: association:%p addr:%pISpc\n", __func__, asoc,
+ &t->ipaddr.sa);
}
/* Choose the transport for sending retransmit packet. */
@@ -1401,8 +1395,8 @@ void sctp_assoc_sync_pmtu(struct sock *sk, struct sctp_association *asoc)
asoc->frag_point = sctp_frag_point(asoc, pmtu);
}
- SCTP_DEBUG_PRINTK("%s: asoc:%p, pmtu:%d, frag_point:%d\n",
- __func__, asoc, asoc->pathmtu, asoc->frag_point);
+ pr_debug("%s: asoc:%p, pmtu:%d, frag_point:%d\n", __func__, asoc,
+ asoc->pathmtu, asoc->frag_point);
}
/* Should we send a SACK to update our peer? */
@@ -1454,9 +1448,9 @@ void sctp_assoc_rwnd_increase(struct sctp_association *asoc, unsigned int len)
asoc->rwnd_press -= change;
}
- SCTP_DEBUG_PRINTK("%s: asoc %p rwnd increased by %d to (%u, %u) "
- "- %u\n", __func__, asoc, len, asoc->rwnd,
- asoc->rwnd_over, asoc->a_rwnd);
+ pr_debug("%s: asoc:%p rwnd increased by %d to (%u, %u) - %u\n",
+ __func__, asoc, len, asoc->rwnd, asoc->rwnd_over,
+ asoc->a_rwnd);
/* Send a window update SACK if the rwnd has increased by at least the
* minimum of the association's PMTU and half of the receive buffer.
@@ -1465,9 +1459,11 @@ void sctp_assoc_rwnd_increase(struct sctp_association *asoc, unsigned int len)
*/
if (sctp_peer_needs_update(asoc)) {
asoc->a_rwnd = asoc->rwnd;
- SCTP_DEBUG_PRINTK("%s: Sending window update SACK- asoc: %p "
- "rwnd: %u a_rwnd: %u\n", __func__,
- asoc, asoc->rwnd, asoc->a_rwnd);
+
+ pr_debug("%s: sending window update SACK- asoc:%p rwnd:%u "
+ "a_rwnd:%u\n", __func__, asoc, asoc->rwnd,
+ asoc->a_rwnd);
+
sack = sctp_make_sack(asoc);
if (!sack)
return;
@@ -1489,8 +1485,10 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned int len)
int rx_count;
int over = 0;
- SCTP_ASSERT(asoc->rwnd, "rwnd zero", return);
- SCTP_ASSERT(!asoc->rwnd_over, "rwnd_over not zero", return);
+ if (unlikely(!asoc->rwnd || asoc->rwnd_over))
+ pr_debug("%s: association:%p has asoc->rwnd:%u, "
+ "asoc->rwnd_over:%u!\n", __func__, asoc,
+ asoc->rwnd, asoc->rwnd_over);
if (asoc->ep->rcvbuf_policy)
rx_count = atomic_read(&asoc->rmem_alloc);
@@ -1515,9 +1513,10 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned int len)
asoc->rwnd_over = len - asoc->rwnd;
asoc->rwnd = 0;
}
- SCTP_DEBUG_PRINTK("%s: asoc %p rwnd decreased by %d to (%u, %u, %u)\n",
- __func__, asoc, len, asoc->rwnd,
- asoc->rwnd_over, asoc->rwnd_press);
+
+ pr_debug("%s: asoc:%p rwnd decreased by %d to (%u, %u, %u)\n",
+ __func__, asoc, len, asoc->rwnd, asoc->rwnd_over,
+ asoc->rwnd_press);
}
/* Build the bind address list for the association based on info from the