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/protocol.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/protocol.c')
-rw-r--r-- | net/sctp/protocol.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 1de49c802d83..4a17494d736c 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -451,8 +451,8 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr, | |||
451 | fl4->fl4_sport = saddr->v4.sin_port; | 451 | fl4->fl4_sport = saddr->v4.sin_port; |
452 | } | 452 | } |
453 | 453 | ||
454 | SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ", | 454 | pr_debug("%s: dst:%pI4, src:%pI4 - ", __func__, &fl4->daddr, |
455 | __func__, &fl4->daddr, &fl4->saddr); | 455 | &fl4->saddr); |
456 | 456 | ||
457 | rt = ip_route_output_key(sock_net(sk), fl4); | 457 | rt = ip_route_output_key(sock_net(sk), fl4); |
458 | if (!IS_ERR(rt)) | 458 | if (!IS_ERR(rt)) |
@@ -513,10 +513,10 @@ out_unlock: | |||
513 | out: | 513 | out: |
514 | t->dst = dst; | 514 | t->dst = dst; |
515 | if (dst) | 515 | if (dst) |
516 | SCTP_DEBUG_PRINTK("rt_dst:%pI4, rt_src:%pI4\n", | 516 | pr_debug("rt_dst:%pI4, rt_src:%pI4\n", |
517 | &fl4->daddr, &fl4->saddr); | 517 | &fl4->daddr, &fl4->saddr); |
518 | else | 518 | else |
519 | SCTP_DEBUG_PRINTK("NO ROUTE\n"); | 519 | pr_debug("no route\n"); |
520 | } | 520 | } |
521 | 521 | ||
522 | /* For v4, the source address is cached in the route entry(dst). So no need | 522 | /* For v4, the source address is cached in the route entry(dst). So no need |
@@ -604,9 +604,9 @@ static void sctp_addr_wq_timeout_handler(unsigned long arg) | |||
604 | spin_lock_bh(&net->sctp.addr_wq_lock); | 604 | spin_lock_bh(&net->sctp.addr_wq_lock); |
605 | 605 | ||
606 | list_for_each_entry_safe(addrw, temp, &net->sctp.addr_waitq, list) { | 606 | list_for_each_entry_safe(addrw, temp, &net->sctp.addr_waitq, list) { |
607 | SCTP_DEBUG_PRINTK_IPADDR("sctp_addrwq_timo_handler: the first ent in wq %p is ", | 607 | pr_debug("%s: the first ent in wq:%p is addr:%pISc for cmd:%d at " |
608 | " for cmd %d at entry %p\n", &net->sctp.addr_waitq, &addrw->a, addrw->state, | 608 | "entry:%p\n", __func__, &net->sctp.addr_waitq, &addrw->a.sa, |
609 | addrw); | 609 | addrw->state, addrw); |
610 | 610 | ||
611 | #if IS_ENABLED(CONFIG_IPV6) | 611 | #if IS_ENABLED(CONFIG_IPV6) |
612 | /* Now we send an ASCONF for each association */ | 612 | /* Now we send an ASCONF for each association */ |
@@ -623,8 +623,10 @@ static void sctp_addr_wq_timeout_handler(unsigned long arg) | |||
623 | addrw->state == SCTP_ADDR_NEW) { | 623 | addrw->state == SCTP_ADDR_NEW) { |
624 | unsigned long timeo_val; | 624 | unsigned long timeo_val; |
625 | 625 | ||
626 | SCTP_DEBUG_PRINTK("sctp_timo_handler: this is on DAD, trying %d sec later\n", | 626 | pr_debug("%s: this is on DAD, trying %d sec " |
627 | SCTP_ADDRESS_TICK_DELAY); | 627 | "later\n", __func__, |
628 | SCTP_ADDRESS_TICK_DELAY); | ||
629 | |||
628 | timeo_val = jiffies; | 630 | timeo_val = jiffies; |
629 | timeo_val += msecs_to_jiffies(SCTP_ADDRESS_TICK_DELAY); | 631 | timeo_val += msecs_to_jiffies(SCTP_ADDRESS_TICK_DELAY); |
630 | mod_timer(&net->sctp.addr_wq_timer, timeo_val); | 632 | mod_timer(&net->sctp.addr_wq_timer, timeo_val); |
@@ -641,7 +643,7 @@ static void sctp_addr_wq_timeout_handler(unsigned long arg) | |||
641 | continue; | 643 | continue; |
642 | sctp_bh_lock_sock(sk); | 644 | sctp_bh_lock_sock(sk); |
643 | if (sctp_asconf_mgmt(sp, addrw) < 0) | 645 | if (sctp_asconf_mgmt(sp, addrw) < 0) |
644 | SCTP_DEBUG_PRINTK("sctp_addrwq_timo_handler: sctp_asconf_mgmt failed\n"); | 646 | pr_debug("%s: sctp_asconf_mgmt failed\n", __func__); |
645 | sctp_bh_unlock_sock(sk); | 647 | sctp_bh_unlock_sock(sk); |
646 | } | 648 | } |
647 | #if IS_ENABLED(CONFIG_IPV6) | 649 | #if IS_ENABLED(CONFIG_IPV6) |
@@ -707,9 +709,10 @@ void sctp_addr_wq_mgmt(struct net *net, struct sctp_sockaddr_entry *addr, int cm | |||
707 | addrw = sctp_addr_wq_lookup(net, addr); | 709 | addrw = sctp_addr_wq_lookup(net, addr); |
708 | if (addrw) { | 710 | if (addrw) { |
709 | if (addrw->state != cmd) { | 711 | if (addrw->state != cmd) { |
710 | SCTP_DEBUG_PRINTK_IPADDR("sctp_addr_wq_mgmt offsets existing entry for %d ", | 712 | pr_debug("%s: offsets existing entry for %d, addr:%pISc " |
711 | " in wq %p\n", addrw->state, &addrw->a, | 713 | "in wq:%p\n", __func__, addrw->state, &addrw->a.sa, |
712 | &net->sctp.addr_waitq); | 714 | &net->sctp.addr_waitq); |
715 | |||
713 | list_del(&addrw->list); | 716 | list_del(&addrw->list); |
714 | kfree(addrw); | 717 | kfree(addrw); |
715 | } | 718 | } |
@@ -725,8 +728,9 @@ void sctp_addr_wq_mgmt(struct net *net, struct sctp_sockaddr_entry *addr, int cm | |||
725 | } | 728 | } |
726 | addrw->state = cmd; | 729 | addrw->state = cmd; |
727 | list_add_tail(&addrw->list, &net->sctp.addr_waitq); | 730 | list_add_tail(&addrw->list, &net->sctp.addr_waitq); |
728 | SCTP_DEBUG_PRINTK_IPADDR("sctp_addr_wq_mgmt add new entry for cmd:%d ", | 731 | |
729 | " in wq %p\n", addrw->state, &addrw->a, &net->sctp.addr_waitq); | 732 | pr_debug("%s: add new entry for cmd:%d, addr:%pISc in wq:%p\n", |
733 | __func__, addrw->state, &addrw->a.sa, &net->sctp.addr_waitq); | ||
730 | 734 | ||
731 | if (!timer_pending(&net->sctp.addr_wq_timer)) { | 735 | if (!timer_pending(&net->sctp.addr_wq_timer)) { |
732 | timeo_val = jiffies; | 736 | timeo_val = jiffies; |
@@ -952,15 +956,14 @@ static inline int sctp_v4_xmit(struct sk_buff *skb, | |||
952 | { | 956 | { |
953 | struct inet_sock *inet = inet_sk(skb->sk); | 957 | struct inet_sock *inet = inet_sk(skb->sk); |
954 | 958 | ||
955 | SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, src:%pI4, dst:%pI4\n", | 959 | pr_debug("%s: skb:%p, len:%d, src:%pI4, dst:%pI4\n", __func__, skb, |
956 | __func__, skb, skb->len, | 960 | skb->len, &transport->fl.u.ip4.saddr, &transport->fl.u.ip4.daddr); |
957 | &transport->fl.u.ip4.saddr, | ||
958 | &transport->fl.u.ip4.daddr); | ||
959 | 961 | ||
960 | inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? | 962 | inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? |
961 | IP_PMTUDISC_DO : IP_PMTUDISC_DONT; | 963 | IP_PMTUDISC_DO : IP_PMTUDISC_DONT; |
962 | 964 | ||
963 | SCTP_INC_STATS(sock_net(&inet->sk), SCTP_MIB_OUTSCTPPACKS); | 965 | SCTP_INC_STATS(sock_net(&inet->sk), SCTP_MIB_OUTSCTPPACKS); |
966 | |||
964 | return ip_queue_xmit(skb, &transport->fl); | 967 | return ip_queue_xmit(skb, &transport->fl); |
965 | } | 968 | } |
966 | 969 | ||
@@ -1321,9 +1324,8 @@ static __init int sctp_init(void) | |||
1321 | int max_share; | 1324 | int max_share; |
1322 | int order; | 1325 | int order; |
1323 | 1326 | ||
1324 | /* SCTP_DEBUG sanity check. */ | 1327 | BUILD_BUG_ON(sizeof(struct sctp_ulpevent) > |
1325 | if (!sctp_sanity_check()) | 1328 | sizeof(((struct sk_buff *) 0)->cb)); |
1326 | goto out; | ||
1327 | 1329 | ||
1328 | /* Allocate bind_bucket and chunk caches. */ | 1330 | /* Allocate bind_bucket and chunk caches. */ |
1329 | status = -ENOBUFS; | 1331 | status = -ENOBUFS; |