aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-05-16 05:55:56 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-17 04:34:38 -0400
commita4ca44fa578c7c7fd123b7fba3c2c98d4ba4e53d (patch)
tree58be0839a0c08ee8eaff4fac160dfb70b6982a70
parent028940342a906db8da014a7603a0deddc2c323dd (diff)
net: l2tp: Standardize logging styles
Use more current logging styles. Add pr_fmt to prefix output appropriately. Convert printks to pr_<level>. Convert PRINTK macros to new l2tp_<level> macros. Neaten some <foo>_refcount debugging macros. Use print_hex_dump_bytes instead of hand-coded loops. Coalesce formats and align arguments. Some KERN_DEBUG output is not now emitted unless dynamic_debugging is enabled. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: James Chapman <jchapman@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/l2tp/l2tp_core.c216
-rw-r--r--net/l2tp/l2tp_core.h35
-rw-r--r--net/l2tp/l2tp_debugfs.c6
-rw-r--r--net/l2tp/l2tp_eth.c15
-rw-r--r--net/l2tp/l2tp_ip.c15
-rw-r--r--net/l2tp/l2tp_ip6.c15
-rw-r--r--net/l2tp/l2tp_netlink.c4
-rw-r--r--net/l2tp/l2tp_ppp.c128
8 files changed, 213 insertions, 221 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 0d6aedc3a0ce..32b2155e7ab4 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -18,6 +18,8 @@
18 * published by the Free Software Foundation. 18 * published by the Free Software Foundation.
19 */ 19 */
20 20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
21#include <linux/module.h> 23#include <linux/module.h>
22#include <linux/string.h> 24#include <linux/string.h>
23#include <linux/list.h> 25#include <linux/list.h>
@@ -86,12 +88,6 @@
86/* Default trace flags */ 88/* Default trace flags */
87#define L2TP_DEFAULT_DEBUG_FLAGS 0 89#define L2TP_DEFAULT_DEBUG_FLAGS 0
88 90
89#define PRINTK(_mask, _type, _lvl, _fmt, args...) \
90 do { \
91 if ((_mask) & (_type)) \
92 printk(_lvl "L2TP: " _fmt, ##args); \
93 } while (0)
94
95/* Private data stored for received packets in the skb. 91/* Private data stored for received packets in the skb.
96 */ 92 */
97struct l2tp_skb_cb { 93struct l2tp_skb_cb {
@@ -141,14 +137,20 @@ static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel)
141 l2tp_tunnel_free(tunnel); 137 l2tp_tunnel_free(tunnel);
142} 138}
143#ifdef L2TP_REFCNT_DEBUG 139#ifdef L2TP_REFCNT_DEBUG
144#define l2tp_tunnel_inc_refcount(_t) do { \ 140#define l2tp_tunnel_inc_refcount(_t) \
145 printk(KERN_DEBUG "l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \ 141do { \
146 l2tp_tunnel_inc_refcount_1(_t); \ 142 pr_debug("l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n", \
147 } while (0) 143 __func__, __LINE__, (_t)->name, \
148#define l2tp_tunnel_dec_refcount(_t) do { \ 144 atomic_read(&_t->ref_count)); \
149 printk(KERN_DEBUG "l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \ 145 l2tp_tunnel_inc_refcount_1(_t); \
150 l2tp_tunnel_dec_refcount_1(_t); \ 146} while (0)
151 } while (0) 147#define l2tp_tunnel_dec_refcount(_t)
148do { \
149 pr_debug("l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n", \
150 __func__, __LINE__, (_t)->name, \
151 atomic_read(&_t->ref_count)); \
152 l2tp_tunnel_dec_refcount_1(_t); \
153} while (0)
152#else 154#else
153#define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t) 155#define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t)
154#define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t) 156#define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t)
@@ -337,10 +339,10 @@ static void l2tp_recv_queue_skb(struct l2tp_session *session, struct sk_buff *sk
337 skb_queue_walk_safe(&session->reorder_q, skbp, tmp) { 339 skb_queue_walk_safe(&session->reorder_q, skbp, tmp) {
338 if (L2TP_SKB_CB(skbp)->ns > ns) { 340 if (L2TP_SKB_CB(skbp)->ns > ns) {
339 __skb_queue_before(&session->reorder_q, skbp, skb); 341 __skb_queue_before(&session->reorder_q, skbp, skb);
340 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 342 l2tp_dbg(session, L2TP_MSG_SEQ,
341 "%s: pkt %hu, inserted before %hu, reorder_q len=%d\n", 343 "%s: pkt %hu, inserted before %hu, reorder_q len=%d\n",
342 session->name, ns, L2TP_SKB_CB(skbp)->ns, 344 session->name, ns, L2TP_SKB_CB(skbp)->ns,
343 skb_queue_len(&session->reorder_q)); 345 skb_queue_len(&session->reorder_q));
344 u64_stats_update_begin(&sstats->syncp); 346 u64_stats_update_begin(&sstats->syncp);
345 sstats->rx_oos_packets++; 347 sstats->rx_oos_packets++;
346 u64_stats_update_end(&sstats->syncp); 348 u64_stats_update_end(&sstats->syncp);
@@ -386,8 +388,8 @@ static void l2tp_recv_dequeue_skb(struct l2tp_session *session, struct sk_buff *
386 else 388 else
387 session->nr &= 0xffffff; 389 session->nr &= 0xffffff;
388 390
389 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 391 l2tp_dbg(session, L2TP_MSG_SEQ, "%s: updated nr to %hu\n",
390 "%s: updated nr to %hu\n", session->name, session->nr); 392 session->name, session->nr);
391 } 393 }
392 394
393 /* call private receive handler */ 395 /* call private receive handler */
@@ -422,12 +424,11 @@ start:
422 sstats->rx_seq_discards++; 424 sstats->rx_seq_discards++;
423 sstats->rx_errors++; 425 sstats->rx_errors++;
424 u64_stats_update_end(&sstats->syncp); 426 u64_stats_update_end(&sstats->syncp);
425 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 427 l2tp_dbg(session, L2TP_MSG_SEQ,
426 "%s: oos pkt %u len %d discarded (too old), " 428 "%s: oos pkt %u len %d discarded (too old), waiting for %u, reorder_q_len=%d\n",
427 "waiting for %u, reorder_q_len=%d\n", 429 session->name, L2TP_SKB_CB(skb)->ns,
428 session->name, L2TP_SKB_CB(skb)->ns, 430 L2TP_SKB_CB(skb)->length, session->nr,
429 L2TP_SKB_CB(skb)->length, session->nr, 431 skb_queue_len(&session->reorder_q));
430 skb_queue_len(&session->reorder_q));
431 session->reorder_skip = 1; 432 session->reorder_skip = 1;
432 __skb_unlink(skb, &session->reorder_q); 433 __skb_unlink(skb, &session->reorder_q);
433 kfree_skb(skb); 434 kfree_skb(skb);
@@ -438,20 +439,19 @@ start:
438 439
439 if (L2TP_SKB_CB(skb)->has_seq) { 440 if (L2TP_SKB_CB(skb)->has_seq) {
440 if (session->reorder_skip) { 441 if (session->reorder_skip) {
441 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 442 l2tp_dbg(session, L2TP_MSG_SEQ,
442 "%s: advancing nr to next pkt: %u -> %u", 443 "%s: advancing nr to next pkt: %u -> %u",
443 session->name, session->nr, 444 session->name, session->nr,
444 L2TP_SKB_CB(skb)->ns); 445 L2TP_SKB_CB(skb)->ns);
445 session->reorder_skip = 0; 446 session->reorder_skip = 0;
446 session->nr = L2TP_SKB_CB(skb)->ns; 447 session->nr = L2TP_SKB_CB(skb)->ns;
447 } 448 }
448 if (L2TP_SKB_CB(skb)->ns != session->nr) { 449 if (L2TP_SKB_CB(skb)->ns != session->nr) {
449 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 450 l2tp_dbg(session, L2TP_MSG_SEQ,
450 "%s: holding oos pkt %u len %d, " 451 "%s: holding oos pkt %u len %d, waiting for %u, reorder_q_len=%d\n",
451 "waiting for %u, reorder_q_len=%d\n", 452 session->name, L2TP_SKB_CB(skb)->ns,
452 session->name, L2TP_SKB_CB(skb)->ns, 453 L2TP_SKB_CB(skb)->length, session->nr,
453 L2TP_SKB_CB(skb)->length, session->nr, 454 skb_queue_len(&session->reorder_q));
454 skb_queue_len(&session->reorder_q));
455 goto out; 455 goto out;
456 } 456 }
457 } 457 }
@@ -595,9 +595,10 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
595 /* Parse and check optional cookie */ 595 /* Parse and check optional cookie */
596 if (session->peer_cookie_len > 0) { 596 if (session->peer_cookie_len > 0) {
597 if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) { 597 if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) {
598 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO, 598 l2tp_info(tunnel, L2TP_MSG_DATA,
599 "%s: cookie mismatch (%u/%u). Discarding.\n", 599 "%s: cookie mismatch (%u/%u). Discarding.\n",
600 tunnel->name, tunnel->tunnel_id, session->session_id); 600 tunnel->name, tunnel->tunnel_id,
601 session->session_id);
601 u64_stats_update_begin(&sstats->syncp); 602 u64_stats_update_begin(&sstats->syncp);
602 sstats->rx_cookie_discards++; 603 sstats->rx_cookie_discards++;
603 u64_stats_update_end(&sstats->syncp); 604 u64_stats_update_end(&sstats->syncp);
@@ -626,9 +627,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
626 L2TP_SKB_CB(skb)->ns = ns; 627 L2TP_SKB_CB(skb)->ns = ns;
627 L2TP_SKB_CB(skb)->has_seq = 1; 628 L2TP_SKB_CB(skb)->has_seq = 1;
628 629
629 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 630 l2tp_dbg(session, L2TP_MSG_SEQ,
630 "%s: recv data ns=%u, nr=%u, session nr=%u\n", 631 "%s: recv data ns=%u, nr=%u, session nr=%u\n",
631 session->name, ns, nr, session->nr); 632 session->name, ns, nr, session->nr);
632 } 633 }
633 } else if (session->l2specific_type == L2TP_L2SPECTYPE_DEFAULT) { 634 } else if (session->l2specific_type == L2TP_L2SPECTYPE_DEFAULT) {
634 u32 l2h = ntohl(*(__be32 *) ptr); 635 u32 l2h = ntohl(*(__be32 *) ptr);
@@ -640,9 +641,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
640 L2TP_SKB_CB(skb)->ns = ns; 641 L2TP_SKB_CB(skb)->ns = ns;
641 L2TP_SKB_CB(skb)->has_seq = 1; 642 L2TP_SKB_CB(skb)->has_seq = 1;
642 643
643 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 644 l2tp_dbg(session, L2TP_MSG_SEQ,
644 "%s: recv data ns=%u, session nr=%u\n", 645 "%s: recv data ns=%u, session nr=%u\n",
645 session->name, ns, session->nr); 646 session->name, ns, session->nr);
646 } 647 }
647 } 648 }
648 649
@@ -655,9 +656,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
655 * configure it so. 656 * configure it so.
656 */ 657 */
657 if ((!session->lns_mode) && (!session->send_seq)) { 658 if ((!session->lns_mode) && (!session->send_seq)) {
658 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_INFO, 659 l2tp_info(session, L2TP_MSG_SEQ,
659 "%s: requested to enable seq numbers by LNS\n", 660 "%s: requested to enable seq numbers by LNS\n",
660 session->name); 661 session->name);
661 session->send_seq = -1; 662 session->send_seq = -1;
662 l2tp_session_set_header_len(session, tunnel->version); 663 l2tp_session_set_header_len(session, tunnel->version);
663 } 664 }
@@ -666,9 +667,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
666 * If user has configured mandatory sequence numbers, discard. 667 * If user has configured mandatory sequence numbers, discard.
667 */ 668 */
668 if (session->recv_seq) { 669 if (session->recv_seq) {
669 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_WARNING, 670 l2tp_warn(session, L2TP_MSG_SEQ,
670 "%s: recv data has no seq numbers when required. " 671 "%s: recv data has no seq numbers when required. Discarding.\n",
671 "Discarding\n", session->name); 672 session->name);
672 u64_stats_update_begin(&sstats->syncp); 673 u64_stats_update_begin(&sstats->syncp);
673 sstats->rx_seq_discards++; 674 sstats->rx_seq_discards++;
674 u64_stats_update_end(&sstats->syncp); 675 u64_stats_update_end(&sstats->syncp);
@@ -681,15 +682,15 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
681 * LAC is broken. Discard the frame. 682 * LAC is broken. Discard the frame.
682 */ 683 */
683 if ((!session->lns_mode) && (session->send_seq)) { 684 if ((!session->lns_mode) && (session->send_seq)) {
684 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_INFO, 685 l2tp_info(session, L2TP_MSG_SEQ,
685 "%s: requested to disable seq numbers by LNS\n", 686 "%s: requested to disable seq numbers by LNS\n",
686 session->name); 687 session->name);
687 session->send_seq = 0; 688 session->send_seq = 0;
688 l2tp_session_set_header_len(session, tunnel->version); 689 l2tp_session_set_header_len(session, tunnel->version);
689 } else if (session->send_seq) { 690 } else if (session->send_seq) {
690 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_WARNING, 691 l2tp_warn(session, L2TP_MSG_SEQ,
691 "%s: recv data has no seq numbers when required. " 692 "%s: recv data has no seq numbers when required. Discarding.\n",
692 "Discarding\n", session->name); 693 session->name);
693 u64_stats_update_begin(&sstats->syncp); 694 u64_stats_update_begin(&sstats->syncp);
694 sstats->rx_seq_discards++; 695 sstats->rx_seq_discards++;
695 u64_stats_update_end(&sstats->syncp); 696 u64_stats_update_end(&sstats->syncp);
@@ -749,12 +750,11 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
749 u64_stats_update_begin(&sstats->syncp); 750 u64_stats_update_begin(&sstats->syncp);
750 sstats->rx_seq_discards++; 751 sstats->rx_seq_discards++;
751 u64_stats_update_end(&sstats->syncp); 752 u64_stats_update_end(&sstats->syncp);
752 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 753 l2tp_dbg(session, L2TP_MSG_SEQ,
753 "%s: oos pkt %u len %d discarded, " 754 "%s: oos pkt %u len %d discarded, waiting for %u, reorder_q_len=%d\n",
754 "waiting for %u, reorder_q_len=%d\n", 755 session->name, L2TP_SKB_CB(skb)->ns,
755 session->name, L2TP_SKB_CB(skb)->ns, 756 L2TP_SKB_CB(skb)->length, session->nr,
756 L2TP_SKB_CB(skb)->length, session->nr, 757 skb_queue_len(&session->reorder_q));
757 skb_queue_len(&session->reorder_q));
758 goto discard; 758 goto discard;
759 } 759 }
760 skb_queue_tail(&session->reorder_q, skb); 760 skb_queue_tail(&session->reorder_q, skb);
@@ -800,7 +800,6 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
800 unsigned char *ptr, *optr; 800 unsigned char *ptr, *optr;
801 u16 hdrflags; 801 u16 hdrflags;
802 u32 tunnel_id, session_id; 802 u32 tunnel_id, session_id;
803 int offset;
804 u16 version; 803 u16 version;
805 int length; 804 int length;
806 struct l2tp_stats *tstats; 805 struct l2tp_stats *tstats;
@@ -813,8 +812,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
813 812
814 /* Short packet? */ 813 /* Short packet? */
815 if (!pskb_may_pull(skb, L2TP_HDR_SIZE_SEQ)) { 814 if (!pskb_may_pull(skb, L2TP_HDR_SIZE_SEQ)) {
816 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO, 815 l2tp_info(tunnel, L2TP_MSG_DATA,
817 "%s: recv short packet (len=%d)\n", tunnel->name, skb->len); 816 "%s: recv short packet (len=%d)\n",
817 tunnel->name, skb->len);
818 goto error; 818 goto error;
819 } 819 }
820 820
@@ -824,14 +824,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
824 if (!pskb_may_pull(skb, length)) 824 if (!pskb_may_pull(skb, length))
825 goto error; 825 goto error;
826 826
827 printk(KERN_DEBUG "%s: recv: ", tunnel->name); 827 pr_debug("%s: recv\n", tunnel->name);
828 828 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, skb->data, length);
829 offset = 0;
830 do {
831 printk(" %02X", skb->data[offset]);
832 } while (++offset < length);
833
834 printk("\n");
835 } 829 }
836 830
837 /* Point to L2TP header */ 831 /* Point to L2TP header */
@@ -843,9 +837,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
843 /* Check protocol version */ 837 /* Check protocol version */
844 version = hdrflags & L2TP_HDR_VER_MASK; 838 version = hdrflags & L2TP_HDR_VER_MASK;
845 if (version != tunnel->version) { 839 if (version != tunnel->version) {
846 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO, 840 l2tp_info(tunnel, L2TP_MSG_DATA,
847 "%s: recv protocol version mismatch: got %d expected %d\n", 841 "%s: recv protocol version mismatch: got %d expected %d\n",
848 tunnel->name, version, tunnel->version); 842 tunnel->name, version, tunnel->version);
849 goto error; 843 goto error;
850 } 844 }
851 845
@@ -854,8 +848,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
854 848
855 /* If type is control packet, it is handled by userspace. */ 849 /* If type is control packet, it is handled by userspace. */
856 if (hdrflags & L2TP_HDRFLAG_T) { 850 if (hdrflags & L2TP_HDRFLAG_T) {
857 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_DEBUG, 851 l2tp_dbg(tunnel, L2TP_MSG_DATA,
858 "%s: recv control packet, len=%d\n", tunnel->name, length); 852 "%s: recv control packet, len=%d\n",
853 tunnel->name, length);
859 goto error; 854 goto error;
860 } 855 }
861 856
@@ -883,9 +878,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
883 session = l2tp_session_find(tunnel->l2tp_net, tunnel, session_id); 878 session = l2tp_session_find(tunnel->l2tp_net, tunnel, session_id);
884 if (!session || !session->recv_skb) { 879 if (!session || !session->recv_skb) {
885 /* Not found? Pass to userspace to deal with */ 880 /* Not found? Pass to userspace to deal with */
886 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO, 881 l2tp_info(tunnel, L2TP_MSG_DATA,
887 "%s: no session found (%u/%u). Passing up.\n", 882 "%s: no session found (%u/%u). Passing up.\n",
888 tunnel->name, tunnel_id, session_id); 883 tunnel->name, tunnel_id, session_id);
889 goto error; 884 goto error;
890 } 885 }
891 886
@@ -925,8 +920,8 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
925 if (tunnel == NULL) 920 if (tunnel == NULL)
926 goto pass_up; 921 goto pass_up;
927 922
928 PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_DEBUG, 923 l2tp_dbg(tunnel, L2TP_MSG_DATA, "%s: received %d bytes\n",
929 "%s: received %d bytes\n", tunnel->name, skb->len); 924 tunnel->name, skb->len);
930 925
931 if (l2tp_udp_recv_core(tunnel, skb, tunnel->recv_payload_hook)) 926 if (l2tp_udp_recv_core(tunnel, skb, tunnel->recv_payload_hook))
932 goto pass_up_put; 927 goto pass_up_put;
@@ -968,8 +963,8 @@ static int l2tp_build_l2tpv2_header(struct l2tp_session *session, void *buf)
968 *bufp++ = 0; 963 *bufp++ = 0;
969 session->ns++; 964 session->ns++;
970 session->ns &= 0xffff; 965 session->ns &= 0xffff;
971 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 966 l2tp_dbg(session, L2TP_MSG_SEQ, "%s: updated ns to %u\n",
972 "%s: updated ns to %u\n", session->name, session->ns); 967 session->name, session->ns);
973 } 968 }
974 969
975 return bufp - optr; 970 return bufp - optr;
@@ -1005,8 +1000,9 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf)
1005 l2h = 0x40000000 | session->ns; 1000 l2h = 0x40000000 | session->ns;
1006 session->ns++; 1001 session->ns++;
1007 session->ns &= 0xffffff; 1002 session->ns &= 0xffffff;
1008 PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, 1003 l2tp_dbg(session, L2TP_MSG_SEQ,
1009 "%s: updated ns to %u\n", session->name, session->ns); 1004 "%s: updated ns to %u\n",
1005 session->name, session->ns);
1010 } 1006 }
1011 1007
1012 *((__be32 *) bufp) = htonl(l2h); 1008 *((__be32 *) bufp) = htonl(l2h);
@@ -1029,27 +1025,19 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
1029 1025
1030 /* Debug */ 1026 /* Debug */
1031 if (session->send_seq) 1027 if (session->send_seq)
1032 PRINTK(session->debug, L2TP_MSG_DATA, KERN_DEBUG, 1028 l2tp_dbg(session, L2TP_MSG_DATA, "%s: send %Zd bytes, ns=%u\n",
1033 "%s: send %Zd bytes, ns=%u\n", session->name, 1029 session->name, data_len, session->ns - 1);
1034 data_len, session->ns - 1);
1035 else 1030 else
1036 PRINTK(session->debug, L2TP_MSG_DATA, KERN_DEBUG, 1031 l2tp_dbg(session, L2TP_MSG_DATA, "%s: send %Zd bytes\n",
1037 "%s: send %Zd bytes\n", session->name, data_len); 1032 session->name, data_len);
1038 1033
1039 if (session->debug & L2TP_MSG_DATA) { 1034 if (session->debug & L2TP_MSG_DATA) {
1040 int i;
1041 int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0; 1035 int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
1042 unsigned char *datap = skb->data + uhlen; 1036 unsigned char *datap = skb->data + uhlen;
1043 1037
1044 printk(KERN_DEBUG "%s: xmit:", session->name); 1038 pr_debug("%s: xmit\n", session->name);
1045 for (i = 0; i < (len - uhlen); i++) { 1039 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
1046 printk(" %02X", *datap++); 1040 datap, min_t(size_t, 32, len - uhlen));
1047 if (i == 31) {
1048 printk(" ...");
1049 break;
1050 }
1051 }
1052 printk("\n");
1053 } 1041 }
1054 1042
1055 /* Queue the packet to IP for output */ 1043 /* Queue the packet to IP for output */
@@ -1248,8 +1236,7 @@ static void l2tp_tunnel_destruct(struct sock *sk)
1248 if (tunnel == NULL) 1236 if (tunnel == NULL)
1249 goto end; 1237 goto end;
1250 1238
1251 PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO, 1239 l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing...\n", tunnel->name);
1252 "%s: closing...\n", tunnel->name);
1253 1240
1254 /* Close all sessions */ 1241 /* Close all sessions */
1255 l2tp_tunnel_closeall(tunnel); 1242 l2tp_tunnel_closeall(tunnel);
@@ -1291,8 +1278,8 @@ static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
1291 1278
1292 BUG_ON(tunnel == NULL); 1279 BUG_ON(tunnel == NULL);
1293 1280
1294 PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO, 1281 l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing all sessions...\n",
1295 "%s: closing all sessions...\n", tunnel->name); 1282 tunnel->name);
1296 1283
1297 write_lock_bh(&tunnel->hlist_lock); 1284 write_lock_bh(&tunnel->hlist_lock);
1298 for (hash = 0; hash < L2TP_HASH_SIZE; hash++) { 1285 for (hash = 0; hash < L2TP_HASH_SIZE; hash++) {
@@ -1300,8 +1287,8 @@ again:
1300 hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) { 1287 hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) {
1301 session = hlist_entry(walk, struct l2tp_session, hlist); 1288 session = hlist_entry(walk, struct l2tp_session, hlist);
1302 1289
1303 PRINTK(session->debug, L2TP_MSG_CONTROL, KERN_INFO, 1290 l2tp_info(session, L2TP_MSG_CONTROL,
1304 "%s: closing session\n", session->name); 1291 "%s: closing session\n", session->name);
1305 1292
1306 hlist_del_init(&session->hlist); 1293 hlist_del_init(&session->hlist);
1307 1294
@@ -1354,8 +1341,7 @@ static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel)
1354 BUG_ON(atomic_read(&tunnel->ref_count) != 0); 1341 BUG_ON(atomic_read(&tunnel->ref_count) != 0);
1355 BUG_ON(tunnel->sock != NULL); 1342 BUG_ON(tunnel->sock != NULL);
1356 1343
1357 PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO, 1344 l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: free...\n", tunnel->name);
1358 "%s: free...\n", tunnel->name);
1359 1345
1360 /* Remove from tunnel list */ 1346 /* Remove from tunnel list */
1361 spin_lock_bh(&pn->l2tp_tunnel_list_lock); 1347 spin_lock_bh(&pn->l2tp_tunnel_list_lock);
@@ -1536,7 +1522,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
1536 err = -EBADF; 1522 err = -EBADF;
1537 sock = sockfd_lookup(fd, &err); 1523 sock = sockfd_lookup(fd, &err);
1538 if (!sock) { 1524 if (!sock) {
1539 printk(KERN_ERR "tunl %hu: sockfd_lookup(fd=%d) returned %d\n", 1525 pr_err("tunl %hu: sockfd_lookup(fd=%d) returned %d\n",
1540 tunnel_id, fd, err); 1526 tunnel_id, fd, err);
1541 goto err; 1527 goto err;
1542 } 1528 }
@@ -1552,7 +1538,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
1552 case L2TP_ENCAPTYPE_UDP: 1538 case L2TP_ENCAPTYPE_UDP:
1553 err = -EPROTONOSUPPORT; 1539 err = -EPROTONOSUPPORT;
1554 if (sk->sk_protocol != IPPROTO_UDP) { 1540 if (sk->sk_protocol != IPPROTO_UDP) {
1555 printk(KERN_ERR "tunl %hu: fd %d wrong protocol, got %d, expected %d\n", 1541 pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
1556 tunnel_id, fd, sk->sk_protocol, IPPROTO_UDP); 1542 tunnel_id, fd, sk->sk_protocol, IPPROTO_UDP);
1557 goto err; 1543 goto err;
1558 } 1544 }
@@ -1560,7 +1546,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
1560 case L2TP_ENCAPTYPE_IP: 1546 case L2TP_ENCAPTYPE_IP:
1561 err = -EPROTONOSUPPORT; 1547 err = -EPROTONOSUPPORT;
1562 if (sk->sk_protocol != IPPROTO_L2TP) { 1548 if (sk->sk_protocol != IPPROTO_L2TP) {
1563 printk(KERN_ERR "tunl %hu: fd %d wrong protocol, got %d, expected %d\n", 1549 pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
1564 tunnel_id, fd, sk->sk_protocol, IPPROTO_L2TP); 1550 tunnel_id, fd, sk->sk_protocol, IPPROTO_L2TP);
1565 goto err; 1551 goto err;
1566 } 1552 }
@@ -1868,7 +1854,7 @@ static int __init l2tp_init(void)
1868 if (rc) 1854 if (rc)
1869 goto out; 1855 goto out;
1870 1856
1871 printk(KERN_INFO "L2TP core driver, %s\n", L2TP_DRV_VERSION); 1857 pr_info("L2TP core driver, %s\n", L2TP_DRV_VERSION);
1872 1858
1873out: 1859out:
1874 return rc; 1860 return rc;
diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
index 90026341a1e5..a38ec6cdeee1 100644
--- a/net/l2tp/l2tp_core.h
+++ b/net/l2tp/l2tp_core.h
@@ -261,17 +261,36 @@ static inline void l2tp_session_dec_refcount_1(struct l2tp_session *session)
261} 261}
262 262
263#ifdef L2TP_REFCNT_DEBUG 263#ifdef L2TP_REFCNT_DEBUG
264#define l2tp_session_inc_refcount(_s) do { \ 264#define l2tp_session_inc_refcount(_s) \
265 printk(KERN_DEBUG "l2tp_session_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_s)->name, atomic_read(&_s->ref_count)); \ 265do { \
266 l2tp_session_inc_refcount_1(_s); \ 266 pr_debug("l2tp_session_inc_refcount: %s:%d %s: cnt=%d\n", \
267 } while (0) 267 __func__, __LINE__, (_s)->name, \
268#define l2tp_session_dec_refcount(_s) do { \ 268 atomic_read(&_s->ref_count)); \
269 printk(KERN_DEBUG "l2tp_session_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_s)->name, atomic_read(&_s->ref_count)); \ 269 l2tp_session_inc_refcount_1(_s); \
270 l2tp_session_dec_refcount_1(_s); \ 270} while (0)
271 } while (0) 271#define l2tp_session_dec_refcount(_s) \
272do { \
273 pr_debug("l2tp_session_dec_refcount: %s:%d %s: cnt=%d\n", \
274 __func__, __LINE__, (_s)->name, \
275 atomic_read(&_s->ref_count)); \
276 l2tp_session_dec_refcount_1(_s); \
277} while (0)
272#else 278#else
273#define l2tp_session_inc_refcount(s) l2tp_session_inc_refcount_1(s) 279#define l2tp_session_inc_refcount(s) l2tp_session_inc_refcount_1(s)
274#define l2tp_session_dec_refcount(s) l2tp_session_dec_refcount_1(s) 280#define l2tp_session_dec_refcount(s) l2tp_session_dec_refcount_1(s)
275#endif 281#endif
276 282
283#define l2tp_printk(ptr, type, func, fmt, ...) \
284do { \
285 if (((ptr)->debug) & (type)) \
286 func(fmt, ##__VA_ARGS__); \
287} while (0)
288
289#define l2tp_warn(ptr, type, fmt, ...) \
290 l2tp_printk(ptr, type, pr_warn, fmt, ##__VA_ARGS__)
291#define l2tp_info(ptr, type, fmt, ...) \
292 l2tp_printk(ptr, type, pr_info, fmt, ##__VA_ARGS__)
293#define l2tp_dbg(ptr, type, fmt, ...) \
294 l2tp_printk(ptr, type, pr_debug, fmt, ##__VA_ARGS__)
295
277#endif /* _L2TP_CORE_H_ */ 296#endif /* _L2TP_CORE_H_ */
diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c
index c0d57bad8b79..c3813bc84552 100644
--- a/net/l2tp/l2tp_debugfs.c
+++ b/net/l2tp/l2tp_debugfs.c
@@ -9,6 +9,8 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/module.h> 14#include <linux/module.h>
13#include <linux/skbuff.h> 15#include <linux/skbuff.h>
14#include <linux/socket.h> 16#include <linux/socket.h>
@@ -325,11 +327,11 @@ static int __init l2tp_debugfs_init(void)
325 if (tunnels == NULL) 327 if (tunnels == NULL)
326 rc = -EIO; 328 rc = -EIO;
327 329
328 printk(KERN_INFO "L2TP debugfs support\n"); 330 pr_info("L2TP debugfs support\n");
329 331
330out: 332out:
331 if (rc) 333 if (rc)
332 printk(KERN_WARNING "l2tp debugfs: unable to init\n"); 334 pr_warn("unable to init\n");
333 335
334 return rc; 336 return rc;
335} 337}
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 63fe5f353f04..443591d629ca 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -9,6 +9,8 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/module.h> 14#include <linux/module.h>
13#include <linux/skbuff.h> 15#include <linux/skbuff.h>
14#include <linux/socket.h> 16#include <linux/socket.h>
@@ -115,21 +117,14 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
115 117
116 if (session->debug & L2TP_MSG_DATA) { 118 if (session->debug & L2TP_MSG_DATA) {
117 unsigned int length; 119 unsigned int length;
118 int offset;
119 u8 *ptr = skb->data; 120 u8 *ptr = skb->data;
120 121
121 length = min(32u, skb->len); 122 length = min(32u, skb->len);
122 if (!pskb_may_pull(skb, length)) 123 if (!pskb_may_pull(skb, length))
123 goto error; 124 goto error;
124 125
125 printk(KERN_DEBUG "%s: eth recv: ", session->name); 126 pr_debug("%s: eth recv\n", session->name);
126 127 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
127 offset = 0;
128 do {
129 printk(" %02X", ptr[offset]);
130 } while (++offset < length);
131
132 printk("\n");
133 } 128 }
134 129
135 if (!pskb_may_pull(skb, sizeof(ETH_HLEN))) 130 if (!pskb_may_pull(skb, sizeof(ETH_HLEN)))
@@ -308,7 +303,7 @@ static int __init l2tp_eth_init(void)
308 if (err) 303 if (err)
309 goto out_unreg; 304 goto out_unreg;
310 305
311 printk(KERN_INFO "L2TP ethernet pseudowire support (L2TPv3)\n"); 306 pr_info("L2TP ethernet pseudowire support (L2TPv3)\n");
312 307
313 return 0; 308 return 0;
314 309
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index c89a32fb5d5e..889f5d13d7ba 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -9,6 +9,8 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/icmp.h> 14#include <linux/icmp.h>
13#include <linux/module.h> 15#include <linux/module.h>
14#include <linux/skbuff.h> 16#include <linux/skbuff.h>
@@ -120,7 +122,6 @@ static int l2tp_ip_recv(struct sk_buff *skb)
120 struct l2tp_session *session; 122 struct l2tp_session *session;
121 struct l2tp_tunnel *tunnel = NULL; 123 struct l2tp_tunnel *tunnel = NULL;
122 int length; 124 int length;
123 int offset;
124 125
125 /* Point to L2TP header */ 126 /* Point to L2TP header */
126 optr = ptr = skb->data; 127 optr = ptr = skb->data;
@@ -155,14 +156,8 @@ static int l2tp_ip_recv(struct sk_buff *skb)
155 if (!pskb_may_pull(skb, length)) 156 if (!pskb_may_pull(skb, length))
156 goto discard; 157 goto discard;
157 158
158 printk(KERN_DEBUG "%s: ip recv: ", tunnel->name); 159 pr_debug("%s: ip recv\n", tunnel->name);
159 160 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
160 offset = 0;
161 do {
162 printk(" %02X", ptr[offset]);
163 } while (++offset < length);
164
165 printk("\n");
166 } 161 }
167 162
168 l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, tunnel->recv_payload_hook); 163 l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, tunnel->recv_payload_hook);
@@ -593,7 +588,7 @@ static int __init l2tp_ip_init(void)
593{ 588{
594 int err; 589 int err;
595 590
596 printk(KERN_INFO "L2TP IP encapsulation support (L2TPv3)\n"); 591 pr_info("L2TP IP encapsulation support (L2TPv3)\n");
597 592
598 err = proto_register(&l2tp_ip_prot, 1); 593 err = proto_register(&l2tp_ip_prot, 1);
599 if (err != 0) 594 if (err != 0)
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index 88f0abe35443..0291d8d85f30 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -9,6 +9,8 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/icmp.h> 14#include <linux/icmp.h>
13#include <linux/module.h> 15#include <linux/module.h>
14#include <linux/skbuff.h> 16#include <linux/skbuff.h>
@@ -133,7 +135,6 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
133 struct l2tp_session *session; 135 struct l2tp_session *session;
134 struct l2tp_tunnel *tunnel = NULL; 136 struct l2tp_tunnel *tunnel = NULL;
135 int length; 137 int length;
136 int offset;
137 138
138 /* Point to L2TP header */ 139 /* Point to L2TP header */
139 optr = ptr = skb->data; 140 optr = ptr = skb->data;
@@ -168,14 +169,8 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
168 if (!pskb_may_pull(skb, length)) 169 if (!pskb_may_pull(skb, length))
169 goto discard; 170 goto discard;
170 171
171 printk(KERN_DEBUG "%s: ip recv: ", tunnel->name); 172 pr_debug("%s: ip recv\n", tunnel->name);
172 173 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
173 offset = 0;
174 do {
175 printk(" %02X", ptr[offset]);
176 } while (++offset < length);
177
178 printk("\n");
179 } 174 }
180 175
181 l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, 176 l2tp_recv_common(session, skb, ptr, optr, 0, skb->len,
@@ -752,7 +747,7 @@ static int __init l2tp_ip6_init(void)
752{ 747{
753 int err; 748 int err;
754 749
755 printk(KERN_INFO "L2TP IP encapsulation support for IPv6 (L2TPv3)\n"); 750 pr_info("L2TP IP encapsulation support for IPv6 (L2TPv3)\n");
756 751
757 err = proto_register(&l2tp_ip6_prot, 1); 752 err = proto_register(&l2tp_ip6_prot, 1);
758 if (err != 0) 753 if (err != 0)
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index 24edad0fd9ba..8577264378fe 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -14,6 +14,8 @@
14 * published by the Free Software Foundation. 14 * published by the Free Software Foundation.
15 */ 15 */
16 16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
17#include <net/sock.h> 19#include <net/sock.h>
18#include <net/genetlink.h> 20#include <net/genetlink.h>
19#include <net/udp.h> 21#include <net/udp.h>
@@ -902,7 +904,7 @@ static int l2tp_nl_init(void)
902{ 904{
903 int err; 905 int err;
904 906
905 printk(KERN_INFO "L2TP netlink interface\n"); 907 pr_info("L2TP netlink interface\n");
906 err = genl_register_family_with_ops(&l2tp_nl_family, l2tp_nl_ops, 908 err = genl_register_family_with_ops(&l2tp_nl_family, l2tp_nl_ops,
907 ARRAY_SIZE(l2tp_nl_ops)); 909 ARRAY_SIZE(l2tp_nl_ops));
908 910
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 9f2c421aa307..8ef6b9416cba 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -57,6 +57,8 @@
57 * http://openl2tp.sourceforge.net. 57 * http://openl2tp.sourceforge.net.
58 */ 58 */
59 59
60#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
61
60#include <linux/module.h> 62#include <linux/module.h>
61#include <linux/string.h> 63#include <linux/string.h>
62#include <linux/list.h> 64#include <linux/list.h>
@@ -106,12 +108,6 @@
106/* Space for UDP, L2TP and PPP headers */ 108/* Space for UDP, L2TP and PPP headers */
107#define PPPOL2TP_HEADER_OVERHEAD 40 109#define PPPOL2TP_HEADER_OVERHEAD 40
108 110
109#define PRINTK(_mask, _type, _lvl, _fmt, args...) \
110 do { \
111 if ((_mask) & (_type)) \
112 printk(_lvl "PPPOL2TP: " _fmt, ##args); \
113 } while (0)
114
115/* Number of bytes to build transmit L2TP headers. 111/* Number of bytes to build transmit L2TP headers.
116 * Unfortunately the size is different depending on whether sequence numbers 112 * Unfortunately the size is different depending on whether sequence numbers
117 * are enabled. 113 * are enabled.
@@ -236,9 +232,9 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
236 232
237 if (sk->sk_state & PPPOX_BOUND) { 233 if (sk->sk_state & PPPOX_BOUND) {
238 struct pppox_sock *po; 234 struct pppox_sock *po;
239 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG, 235 l2tp_dbg(session, PPPOL2TP_MSG_DATA,
240 "%s: recv %d byte data frame, passing to ppp\n", 236 "%s: recv %d byte data frame, passing to ppp\n",
241 session->name, data_len); 237 session->name, data_len);
242 238
243 /* We need to forget all info related to the L2TP packet 239 /* We need to forget all info related to the L2TP packet
244 * gathered in the skb as we are going to reuse the same 240 * gathered in the skb as we are going to reuse the same
@@ -259,8 +255,8 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
259 po = pppox_sk(sk); 255 po = pppox_sk(sk);
260 ppp_input(&po->chan, skb); 256 ppp_input(&po->chan, skb);
261 } else { 257 } else {
262 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_INFO, 258 l2tp_info(session, PPPOL2TP_MSG_DATA, "%s: socket not bound\n",
263 "%s: socket not bound\n", session->name); 259 session->name);
264 260
265 /* Not bound. Nothing we can do, so discard. */ 261 /* Not bound. Nothing we can do, so discard. */
266 session->stats.rx_errors++; 262 session->stats.rx_errors++;
@@ -270,8 +266,7 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
270 return; 266 return;
271 267
272no_sock: 268no_sock:
273 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_INFO, 269 l2tp_info(session, PPPOL2TP_MSG_DATA, "%s: no socket\n", session->name);
274 "%s: no socket\n", session->name);
275 kfree_skb(skb); 270 kfree_skb(skb);
276} 271}
277 272
@@ -827,8 +822,8 @@ out_no_ppp:
827 /* This is how we get the session context from the socket. */ 822 /* This is how we get the session context from the socket. */
828 sk->sk_user_data = session; 823 sk->sk_user_data = session;
829 sk->sk_state = PPPOX_CONNECTED; 824 sk->sk_state = PPPOX_CONNECTED;
830 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 825 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: created\n",
831 "%s: created\n", session->name); 826 session->name);
832 827
833end: 828end:
834 release_sock(sk); 829 release_sock(sk);
@@ -881,8 +876,8 @@ static int pppol2tp_session_create(struct net *net, u32 tunnel_id, u32 session_i
881 ps = l2tp_session_priv(session); 876 ps = l2tp_session_priv(session);
882 ps->tunnel_sock = tunnel->sock; 877 ps->tunnel_sock = tunnel->sock;
883 878
884 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 879 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: created\n",
885 "%s: created\n", session->name); 880 session->name);
886 881
887 error = 0; 882 error = 0;
888 883
@@ -1058,9 +1053,9 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1058 struct l2tp_tunnel *tunnel = session->tunnel; 1053 struct l2tp_tunnel *tunnel = session->tunnel;
1059 struct pppol2tp_ioc_stats stats; 1054 struct pppol2tp_ioc_stats stats;
1060 1055
1061 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG, 1056 l2tp_dbg(session, PPPOL2TP_MSG_CONTROL,
1062 "%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n", 1057 "%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n",
1063 session->name, cmd, arg); 1058 session->name, cmd, arg);
1064 1059
1065 sk = ps->sock; 1060 sk = ps->sock;
1066 sock_hold(sk); 1061 sock_hold(sk);
@@ -1078,8 +1073,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1078 if (copy_to_user((void __user *) arg, &ifr, sizeof(struct ifreq))) 1073 if (copy_to_user((void __user *) arg, &ifr, sizeof(struct ifreq)))
1079 break; 1074 break;
1080 1075
1081 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1076 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get mtu=%d\n",
1082 "%s: get mtu=%d\n", session->name, session->mtu); 1077 session->name, session->mtu);
1083 err = 0; 1078 err = 0;
1084 break; 1079 break;
1085 1080
@@ -1094,8 +1089,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1094 1089
1095 session->mtu = ifr.ifr_mtu; 1090 session->mtu = ifr.ifr_mtu;
1096 1091
1097 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1092 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set mtu=%d\n",
1098 "%s: set mtu=%d\n", session->name, session->mtu); 1093 session->name, session->mtu);
1099 err = 0; 1094 err = 0;
1100 break; 1095 break;
1101 1096
@@ -1108,8 +1103,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1108 if (put_user(session->mru, (int __user *) arg)) 1103 if (put_user(session->mru, (int __user *) arg))
1109 break; 1104 break;
1110 1105
1111 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1106 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get mru=%d\n",
1112 "%s: get mru=%d\n", session->name, session->mru); 1107 session->name, session->mru);
1113 err = 0; 1108 err = 0;
1114 break; 1109 break;
1115 1110
@@ -1123,8 +1118,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1123 break; 1118 break;
1124 1119
1125 session->mru = val; 1120 session->mru = val;
1126 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1121 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set mru=%d\n",
1127 "%s: set mru=%d\n", session->name, session->mru); 1122 session->name, session->mru);
1128 err = 0; 1123 err = 0;
1129 break; 1124 break;
1130 1125
@@ -1133,8 +1128,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1133 if (put_user(ps->flags, (int __user *) arg)) 1128 if (put_user(ps->flags, (int __user *) arg))
1134 break; 1129 break;
1135 1130
1136 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1131 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get flags=%d\n",
1137 "%s: get flags=%d\n", session->name, ps->flags); 1132 session->name, ps->flags);
1138 err = 0; 1133 err = 0;
1139 break; 1134 break;
1140 1135
@@ -1143,8 +1138,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1143 if (get_user(val, (int __user *) arg)) 1138 if (get_user(val, (int __user *) arg))
1144 break; 1139 break;
1145 ps->flags = val; 1140 ps->flags = val;
1146 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1141 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set flags=%d\n",
1147 "%s: set flags=%d\n", session->name, ps->flags); 1142 session->name, ps->flags);
1148 err = 0; 1143 err = 0;
1149 break; 1144 break;
1150 1145
@@ -1160,8 +1155,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1160 if (copy_to_user((void __user *) arg, &stats, 1155 if (copy_to_user((void __user *) arg, &stats,
1161 sizeof(stats))) 1156 sizeof(stats)))
1162 break; 1157 break;
1163 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1158 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get L2TP stats\n",
1164 "%s: get L2TP stats\n", session->name); 1159 session->name);
1165 err = 0; 1160 err = 0;
1166 break; 1161 break;
1167 1162
@@ -1188,9 +1183,9 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
1188 struct sock *sk; 1183 struct sock *sk;
1189 struct pppol2tp_ioc_stats stats; 1184 struct pppol2tp_ioc_stats stats;
1190 1185
1191 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG, 1186 l2tp_dbg(tunnel, PPPOL2TP_MSG_CONTROL,
1192 "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n", 1187 "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n",
1193 tunnel->name, cmd, arg); 1188 tunnel->name, cmd, arg);
1194 1189
1195 sk = tunnel->sock; 1190 sk = tunnel->sock;
1196 sock_hold(sk); 1191 sock_hold(sk);
@@ -1224,8 +1219,8 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
1224 err = -EFAULT; 1219 err = -EFAULT;
1225 break; 1220 break;
1226 } 1221 }
1227 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1222 l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: get L2TP stats\n",
1228 "%s: get L2TP stats\n", tunnel->name); 1223 tunnel->name);
1229 err = 0; 1224 err = 0;
1230 break; 1225 break;
1231 1226
@@ -1314,8 +1309,8 @@ static int pppol2tp_tunnel_setsockopt(struct sock *sk,
1314 switch (optname) { 1309 switch (optname) {
1315 case PPPOL2TP_SO_DEBUG: 1310 case PPPOL2TP_SO_DEBUG:
1316 tunnel->debug = val; 1311 tunnel->debug = val;
1317 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1312 l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: set debug=%x\n",
1318 "%s: set debug=%x\n", tunnel->name, tunnel->debug); 1313 tunnel->name, tunnel->debug);
1319 break; 1314 break;
1320 1315
1321 default: 1316 default:
@@ -1342,8 +1337,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
1342 break; 1337 break;
1343 } 1338 }
1344 session->recv_seq = val ? -1 : 0; 1339 session->recv_seq = val ? -1 : 0;
1345 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1340 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1346 "%s: set recv_seq=%d\n", session->name, session->recv_seq); 1341 "%s: set recv_seq=%d\n",
1342 session->name, session->recv_seq);
1347 break; 1343 break;
1348 1344
1349 case PPPOL2TP_SO_SENDSEQ: 1345 case PPPOL2TP_SO_SENDSEQ:
@@ -1358,8 +1354,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
1358 po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ : 1354 po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ :
1359 PPPOL2TP_L2TP_HDR_SIZE_NOSEQ; 1355 PPPOL2TP_L2TP_HDR_SIZE_NOSEQ;
1360 } 1356 }
1361 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1357 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1362 "%s: set send_seq=%d\n", session->name, session->send_seq); 1358 "%s: set send_seq=%d\n",
1359 session->name, session->send_seq);
1363 break; 1360 break;
1364 1361
1365 case PPPOL2TP_SO_LNSMODE: 1362 case PPPOL2TP_SO_LNSMODE:
@@ -1368,20 +1365,22 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
1368 break; 1365 break;
1369 } 1366 }
1370 session->lns_mode = val ? -1 : 0; 1367 session->lns_mode = val ? -1 : 0;
1371 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1368 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1372 "%s: set lns_mode=%d\n", session->name, session->lns_mode); 1369 "%s: set lns_mode=%d\n",
1370 session->name, session->lns_mode);
1373 break; 1371 break;
1374 1372
1375 case PPPOL2TP_SO_DEBUG: 1373 case PPPOL2TP_SO_DEBUG:
1376 session->debug = val; 1374 session->debug = val;
1377 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1375 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set debug=%x\n",
1378 "%s: set debug=%x\n", session->name, session->debug); 1376 session->name, session->debug);
1379 break; 1377 break;
1380 1378
1381 case PPPOL2TP_SO_REORDERTO: 1379 case PPPOL2TP_SO_REORDERTO:
1382 session->reorder_timeout = msecs_to_jiffies(val); 1380 session->reorder_timeout = msecs_to_jiffies(val);
1383 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1381 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1384 "%s: set reorder_timeout=%d\n", session->name, session->reorder_timeout); 1382 "%s: set reorder_timeout=%d\n",
1383 session->name, session->reorder_timeout);
1385 break; 1384 break;
1386 1385
1387 default: 1386 default:
@@ -1460,8 +1459,8 @@ static int pppol2tp_tunnel_getsockopt(struct sock *sk,
1460 switch (optname) { 1459 switch (optname) {
1461 case PPPOL2TP_SO_DEBUG: 1460 case PPPOL2TP_SO_DEBUG:
1462 *val = tunnel->debug; 1461 *val = tunnel->debug;
1463 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1462 l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: get debug=%x\n",
1464 "%s: get debug=%x\n", tunnel->name, tunnel->debug); 1463 tunnel->name, tunnel->debug);
1465 break; 1464 break;
1466 1465
1467 default: 1466 default:
@@ -1483,32 +1482,32 @@ static int pppol2tp_session_getsockopt(struct sock *sk,
1483 switch (optname) { 1482 switch (optname) {
1484 case PPPOL2TP_SO_RECVSEQ: 1483 case PPPOL2TP_SO_RECVSEQ:
1485 *val = session->recv_seq; 1484 *val = session->recv_seq;
1486 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1485 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1487 "%s: get recv_seq=%d\n", session->name, *val); 1486 "%s: get recv_seq=%d\n", session->name, *val);
1488 break; 1487 break;
1489 1488
1490 case PPPOL2TP_SO_SENDSEQ: 1489 case PPPOL2TP_SO_SENDSEQ:
1491 *val = session->send_seq; 1490 *val = session->send_seq;
1492 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1491 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1493 "%s: get send_seq=%d\n", session->name, *val); 1492 "%s: get send_seq=%d\n", session->name, *val);
1494 break; 1493 break;
1495 1494
1496 case PPPOL2TP_SO_LNSMODE: 1495 case PPPOL2TP_SO_LNSMODE:
1497 *val = session->lns_mode; 1496 *val = session->lns_mode;
1498 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1497 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1499 "%s: get lns_mode=%d\n", session->name, *val); 1498 "%s: get lns_mode=%d\n", session->name, *val);
1500 break; 1499 break;
1501 1500
1502 case PPPOL2TP_SO_DEBUG: 1501 case PPPOL2TP_SO_DEBUG:
1503 *val = session->debug; 1502 *val = session->debug;
1504 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1503 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get debug=%d\n",
1505 "%s: get debug=%d\n", session->name, *val); 1504 session->name, *val);
1506 break; 1505 break;
1507 1506
1508 case PPPOL2TP_SO_REORDERTO: 1507 case PPPOL2TP_SO_REORDERTO:
1509 *val = (int) jiffies_to_msecs(session->reorder_timeout); 1508 *val = (int) jiffies_to_msecs(session->reorder_timeout);
1510 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1509 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1511 "%s: get reorder_timeout=%d\n", session->name, *val); 1510 "%s: get reorder_timeout=%d\n", session->name, *val);
1512 break; 1511 break;
1513 1512
1514 default: 1513 default:
@@ -1871,8 +1870,7 @@ static int __init pppol2tp_init(void)
1871 goto out_unregister_pppox; 1870 goto out_unregister_pppox;
1872#endif 1871#endif
1873 1872
1874 printk(KERN_INFO "PPPoL2TP kernel driver, %s\n", 1873 pr_info("PPPoL2TP kernel driver, %s\n", PPPOL2TP_DRV_VERSION);
1875 PPPOL2TP_DRV_VERSION);
1876 1874
1877out: 1875out:
1878 return err; 1876 return err;