Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joe Perches and committed by
David S. Miller
a4ca44fa 02894034

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