diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-28 13:49:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-07-02 02:22:13 -0400 |
commit | bb33381d0c97cdee25f2cdab540b6e2bd16fa03b (patch) | |
tree | a4def6ec9f554908e07efa8671ca52f60f9a2a18 /net/sctp/associola.c | |
parent | 1067964305df131ede2c08c2f3c9b3892640f1c6 (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/associola.c')
-rw-r--r-- | net/sctp/associola.c | 67 |
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, | |||
357 | goto fail_init; | 357 | goto fail_init; |
358 | 358 | ||
359 | SCTP_DBG_OBJCNT_INC(assoc); | 359 | SCTP_DBG_OBJCNT_INC(assoc); |
360 | SCTP_DEBUG_PRINTK("Created asoc %p\n", asoc); | 360 | |
361 | pr_debug("Created asoc %p\n", asoc); | ||
361 | 362 | ||
362 | return asoc; | 363 | return asoc; |
363 | 364 | ||
@@ -455,7 +456,10 @@ void sctp_association_free(struct sctp_association *asoc) | |||
455 | /* Cleanup and free up an association. */ | 456 | /* Cleanup and free up an association. */ |
456 | static void sctp_association_destroy(struct sctp_association *asoc) | 457 | static void sctp_association_destroy(struct sctp_association *asoc) |
457 | { | 458 | { |
458 | SCTP_ASSERT(asoc->base.dead, "Assoc is not dead", return); | 459 | if (unlikely(!asoc->base.dead)) { |
460 | WARN(1, "Attempt to destroy undead association %p!\n", asoc); | ||
461 | return; | ||
462 | } | ||
459 | 463 | ||
460 | sctp_endpoint_put(asoc->ep); | 464 | sctp_endpoint_put(asoc->ep); |
461 | sock_put(asoc->base.sk); | 465 | sock_put(asoc->base.sk); |
@@ -536,11 +540,8 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc, | |||
536 | struct list_head *pos; | 540 | struct list_head *pos; |
537 | struct sctp_transport *transport; | 541 | struct sctp_transport *transport; |
538 | 542 | ||
539 | SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_rm_peer:association %p addr: ", | 543 | pr_debug("%s: association:%p addr:%pISpc\n", |
540 | " port: %d\n", | 544 | __func__, asoc, &peer->ipaddr.sa); |
541 | asoc, | ||
542 | (&peer->ipaddr), | ||
543 | ntohs(peer->ipaddr.v4.sin_port)); | ||
544 | 545 | ||
545 | /* If we are to remove the current retran_path, update it | 546 | /* If we are to remove the current retran_path, update it |
546 | * to the next peer before removing this peer from the list. | 547 | * 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, | |||
636 | /* AF_INET and AF_INET6 share common port field. */ | 637 | /* AF_INET and AF_INET6 share common port field. */ |
637 | port = ntohs(addr->v4.sin_port); | 638 | port = ntohs(addr->v4.sin_port); |
638 | 639 | ||
639 | SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ", | 640 | pr_debug("%s: association:%p addr:%pISpc state:%d\n", __func__, |
640 | " port: %d state:%d\n", | 641 | asoc, &addr->sa, peer_state); |
641 | asoc, | ||
642 | addr, | ||
643 | port, | ||
644 | peer_state); | ||
645 | 642 | ||
646 | /* Set the port if it has not been set yet. */ | 643 | /* Set the port if it has not been set yet. */ |
647 | if (0 == asoc->peer.port) | 644 | if (0 == asoc->peer.port) |
@@ -708,8 +705,9 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, | |||
708 | else | 705 | else |
709 | asoc->pathmtu = peer->pathmtu; | 706 | asoc->pathmtu = peer->pathmtu; |
710 | 707 | ||
711 | SCTP_DEBUG_PRINTK("sctp_assoc_add_peer:association %p PMTU set to " | 708 | pr_debug("%s: association:%p PMTU set to %d\n", __func__, asoc, |
712 | "%d\n", asoc, asoc->pathmtu); | 709 | asoc->pathmtu); |
710 | |||
713 | peer->pmtu_pending = 0; | 711 | peer->pmtu_pending = 0; |
714 | 712 | ||
715 | asoc->frag_point = sctp_frag_point(asoc, asoc->pathmtu); | 713 | asoc->frag_point = sctp_frag_point(asoc, asoc->pathmtu); |
@@ -1349,12 +1347,8 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc) | |||
1349 | else | 1347 | else |
1350 | t = asoc->peer.retran_path; | 1348 | t = asoc->peer.retran_path; |
1351 | 1349 | ||
1352 | SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association" | 1350 | pr_debug("%s: association:%p addr:%pISpc\n", __func__, asoc, |
1353 | " %p addr: ", | 1351 | &t->ipaddr.sa); |
1354 | " port: %d\n", | ||
1355 | asoc, | ||
1356 | (&t->ipaddr), | ||
1357 | ntohs(t->ipaddr.v4.sin_port)); | ||
1358 | } | 1352 | } |
1359 | 1353 | ||
1360 | /* Choose the transport for sending retransmit packet. */ | 1354 | /* Choose the transport for sending retransmit packet. */ |
@@ -1401,8 +1395,8 @@ void sctp_assoc_sync_pmtu(struct sock *sk, struct sctp_association *asoc) | |||
1401 | asoc->frag_point = sctp_frag_point(asoc, pmtu); | 1395 | asoc->frag_point = sctp_frag_point(asoc, pmtu); |
1402 | } | 1396 | } |
1403 | 1397 | ||
1404 | SCTP_DEBUG_PRINTK("%s: asoc:%p, pmtu:%d, frag_point:%d\n", | 1398 | pr_debug("%s: asoc:%p, pmtu:%d, frag_point:%d\n", __func__, asoc, |
1405 | __func__, asoc, asoc->pathmtu, asoc->frag_point); | 1399 | asoc->pathmtu, asoc->frag_point); |
1406 | } | 1400 | } |
1407 | 1401 | ||
1408 | /* Should we send a SACK to update our peer? */ | 1402 | /* 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) | |||
1454 | asoc->rwnd_press -= change; | 1448 | asoc->rwnd_press -= change; |
1455 | } | 1449 | } |
1456 | 1450 | ||
1457 | SCTP_DEBUG_PRINTK("%s: asoc %p rwnd increased by %d to (%u, %u) " | 1451 | pr_debug("%s: asoc:%p rwnd increased by %d to (%u, %u) - %u\n", |
1458 | "- %u\n", __func__, asoc, len, asoc->rwnd, | 1452 | __func__, asoc, len, asoc->rwnd, asoc->rwnd_over, |
1459 | asoc->rwnd_over, asoc->a_rwnd); | 1453 | asoc->a_rwnd); |
1460 | 1454 | ||
1461 | /* Send a window update SACK if the rwnd has increased by at least the | 1455 | /* Send a window update SACK if the rwnd has increased by at least the |
1462 | * minimum of the association's PMTU and half of the receive buffer. | 1456 | * 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) | |||
1465 | */ | 1459 | */ |
1466 | if (sctp_peer_needs_update(asoc)) { | 1460 | if (sctp_peer_needs_update(asoc)) { |
1467 | asoc->a_rwnd = asoc->rwnd; | 1461 | asoc->a_rwnd = asoc->rwnd; |
1468 | SCTP_DEBUG_PRINTK("%s: Sending window update SACK- asoc: %p " | 1462 | |
1469 | "rwnd: %u a_rwnd: %u\n", __func__, | 1463 | pr_debug("%s: sending window update SACK- asoc:%p rwnd:%u " |
1470 | asoc, asoc->rwnd, asoc->a_rwnd); | 1464 | "a_rwnd:%u\n", __func__, asoc, asoc->rwnd, |
1465 | asoc->a_rwnd); | ||
1466 | |||
1471 | sack = sctp_make_sack(asoc); | 1467 | sack = sctp_make_sack(asoc); |
1472 | if (!sack) | 1468 | if (!sack) |
1473 | return; | 1469 | return; |
@@ -1489,8 +1485,10 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned int len) | |||
1489 | int rx_count; | 1485 | int rx_count; |
1490 | int over = 0; | 1486 | int over = 0; |
1491 | 1487 | ||
1492 | SCTP_ASSERT(asoc->rwnd, "rwnd zero", return); | 1488 | if (unlikely(!asoc->rwnd || asoc->rwnd_over)) |
1493 | SCTP_ASSERT(!asoc->rwnd_over, "rwnd_over not zero", return); | 1489 | pr_debug("%s: association:%p has asoc->rwnd:%u, " |
1490 | "asoc->rwnd_over:%u!\n", __func__, asoc, | ||
1491 | asoc->rwnd, asoc->rwnd_over); | ||
1494 | 1492 | ||
1495 | if (asoc->ep->rcvbuf_policy) | 1493 | if (asoc->ep->rcvbuf_policy) |
1496 | rx_count = atomic_read(&asoc->rmem_alloc); | 1494 | rx_count = atomic_read(&asoc->rmem_alloc); |
@@ -1515,9 +1513,10 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned int len) | |||
1515 | asoc->rwnd_over = len - asoc->rwnd; | 1513 | asoc->rwnd_over = len - asoc->rwnd; |
1516 | asoc->rwnd = 0; | 1514 | asoc->rwnd = 0; |
1517 | } | 1515 | } |
1518 | SCTP_DEBUG_PRINTK("%s: asoc %p rwnd decreased by %d to (%u, %u, %u)\n", | 1516 | |
1519 | __func__, asoc, len, asoc->rwnd, | 1517 | pr_debug("%s: asoc:%p rwnd decreased by %d to (%u, %u, %u)\n", |
1520 | asoc->rwnd_over, asoc->rwnd_press); | 1518 | __func__, asoc, len, asoc->rwnd, asoc->rwnd_over, |
1519 | asoc->rwnd_press); | ||
1521 | } | 1520 | } |
1522 | 1521 | ||
1523 | /* Build the bind address list for the association based on info from the | 1522 | /* Build the bind address list for the association based on info from the |