aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/transport.c
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 /net/sctp/transport.c
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 'net/sctp/transport.c')
-rw-r--r--net/sctp/transport.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 5d3c71bbd197..bdbbc3fd7c14 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -176,7 +176,10 @@ static void sctp_transport_destroy_rcu(struct rcu_head *head)
176 */ 176 */
177static void sctp_transport_destroy(struct sctp_transport *transport) 177static void sctp_transport_destroy(struct sctp_transport *transport)
178{ 178{
179 SCTP_ASSERT(transport->dead, "Transport is not dead", return); 179 if (unlikely(!transport->dead)) {
180 WARN(1, "Attempt to destroy undead transport %p!\n", transport);
181 return;
182 }
180 183
181 call_rcu(&transport->rcu, sctp_transport_destroy_rcu); 184 call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
182 185
@@ -317,11 +320,9 @@ void sctp_transport_put(struct sctp_transport *transport)
317/* Update transport's RTO based on the newly calculated RTT. */ 320/* Update transport's RTO based on the newly calculated RTT. */
318void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt) 321void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
319{ 322{
320 /* Check for valid transport. */ 323 if (unlikely(!tp->rto_pending))
321 SCTP_ASSERT(tp, "NULL transport", return); 324 /* We should not be doing any RTO updates unless rto_pending is set. */
322 325 pr_debug("%s: rto_pending not set on transport %p!\n", __func__, tp);
323 /* We should not be doing any RTO updates unless rto_pending is set. */
324 SCTP_ASSERT(tp->rto_pending, "rto_pending not set", return);
325 326
326 if (tp->rttvar || tp->srtt) { 327 if (tp->rttvar || tp->srtt) {
327 struct net *net = sock_net(tp->asoc->base.sk); 328 struct net *net = sock_net(tp->asoc->base.sk);
@@ -377,9 +378,8 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
377 */ 378 */
378 tp->rto_pending = 0; 379 tp->rto_pending = 0;
379 380
380 SCTP_DEBUG_PRINTK("%s: transport: %p, rtt: %d, srtt: %d " 381 pr_debug("%s: transport:%p, rtt:%d, srtt:%d rttvar:%d, rto:%ld\n",
381 "rttvar: %d, rto: %ld\n", __func__, 382 __func__, tp, rtt, tp->srtt, tp->rttvar, tp->rto);
382 tp, rtt, tp->srtt, tp->rttvar, tp->rto);
383} 383}
384 384
385/* This routine updates the transport's cwnd and partial_bytes_acked 385/* This routine updates the transport's cwnd and partial_bytes_acked
@@ -433,12 +433,11 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport,
433 cwnd += pmtu; 433 cwnd += pmtu;
434 else 434 else
435 cwnd += bytes_acked; 435 cwnd += bytes_acked;
436 SCTP_DEBUG_PRINTK("%s: SLOW START: transport: %p, " 436
437 "bytes_acked: %d, cwnd: %d, ssthresh: %d, " 437 pr_debug("%s: slow start: transport:%p, bytes_acked:%d, "
438 "flight_size: %d, pba: %d\n", 438 "cwnd:%d, ssthresh:%d, flight_size:%d, pba:%d\n",
439 __func__, 439 __func__, transport, bytes_acked, cwnd, ssthresh,
440 transport, bytes_acked, cwnd, 440 flight_size, pba);
441 ssthresh, flight_size, pba);
442 } else { 441 } else {
443 /* RFC 2960 7.2.2 Whenever cwnd is greater than ssthresh, 442 /* RFC 2960 7.2.2 Whenever cwnd is greater than ssthresh,
444 * upon each SACK arrival that advances the Cumulative TSN Ack 443 * upon each SACK arrival that advances the Cumulative TSN Ack
@@ -459,12 +458,12 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport,
459 cwnd += pmtu; 458 cwnd += pmtu;
460 pba = ((cwnd < pba) ? (pba - cwnd) : 0); 459 pba = ((cwnd < pba) ? (pba - cwnd) : 0);
461 } 460 }
462 SCTP_DEBUG_PRINTK("%s: CONGESTION AVOIDANCE: " 461
463 "transport: %p, bytes_acked: %d, cwnd: %d, " 462 pr_debug("%s: congestion avoidance: transport:%p, "
464 "ssthresh: %d, flight_size: %d, pba: %d\n", 463 "bytes_acked:%d, cwnd:%d, ssthresh:%d, "
465 __func__, 464 "flight_size:%d, pba:%d\n", __func__,
466 transport, bytes_acked, cwnd, 465 transport, bytes_acked, cwnd, ssthresh,
467 ssthresh, flight_size, pba); 466 flight_size, pba);
468 } 467 }
469 468
470 transport->cwnd = cwnd; 469 transport->cwnd = cwnd;
@@ -558,10 +557,10 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
558 } 557 }
559 558
560 transport->partial_bytes_acked = 0; 559 transport->partial_bytes_acked = 0;
561 SCTP_DEBUG_PRINTK("%s: transport: %p reason: %d cwnd: " 560
562 "%d ssthresh: %d\n", __func__, 561 pr_debug("%s: transport:%p, reason:%d, cwnd:%d, ssthresh:%d\n",
563 transport, reason, 562 __func__, transport, reason, transport->cwnd,
564 transport->cwnd, transport->ssthresh); 563 transport->ssthresh);
565} 564}
566 565
567/* Apply Max.Burst limit to the congestion window: 566/* Apply Max.Burst limit to the congestion window: