Commit a4ca44fa authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

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: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarJames Chapman <jchapman@katalix.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 02894034
This diff is collapsed.
...@@ -261,17 +261,36 @@ static inline void l2tp_session_dec_refcount_1(struct l2tp_session *session) ...@@ -261,17 +261,36 @@ static inline void l2tp_session_dec_refcount_1(struct l2tp_session *session)
} }
#ifdef L2TP_REFCNT_DEBUG #ifdef L2TP_REFCNT_DEBUG
#define l2tp_session_inc_refcount(_s) do { \ #define l2tp_session_inc_refcount(_s) \
printk(KERN_DEBUG "l2tp_session_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_s)->name, atomic_read(&_s->ref_count)); \ do { \
pr_debug("l2tp_session_inc_refcount: %s:%d %s: cnt=%d\n", \
__func__, __LINE__, (_s)->name, \
atomic_read(&_s->ref_count)); \
l2tp_session_inc_refcount_1(_s); \ l2tp_session_inc_refcount_1(_s); \
} while (0) } while (0)
#define l2tp_session_dec_refcount(_s) do { \ #define l2tp_session_dec_refcount(_s) \
printk(KERN_DEBUG "l2tp_session_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_s)->name, atomic_read(&_s->ref_count)); \ do { \
pr_debug("l2tp_session_dec_refcount: %s:%d %s: cnt=%d\n", \
__func__, __LINE__, (_s)->name, \
atomic_read(&_s->ref_count)); \
l2tp_session_dec_refcount_1(_s); \ l2tp_session_dec_refcount_1(_s); \
} while (0) } while (0)
#else #else
#define l2tp_session_inc_refcount(s) l2tp_session_inc_refcount_1(s) #define l2tp_session_inc_refcount(s) l2tp_session_inc_refcount_1(s)
#define l2tp_session_dec_refcount(s) l2tp_session_dec_refcount_1(s) #define l2tp_session_dec_refcount(s) l2tp_session_dec_refcount_1(s)
#endif #endif
#define l2tp_printk(ptr, type, func, fmt, ...) \
do { \
if (((ptr)->debug) & (type)) \
func(fmt, ##__VA_ARGS__); \
} while (0)
#define l2tp_warn(ptr, type, fmt, ...) \
l2tp_printk(ptr, type, pr_warn, fmt, ##__VA_ARGS__)
#define l2tp_info(ptr, type, fmt, ...) \
l2tp_printk(ptr, type, pr_info, fmt, ##__VA_ARGS__)
#define l2tp_dbg(ptr, type, fmt, ...) \
l2tp_printk(ptr, type, pr_debug, fmt, ##__VA_ARGS__)
#endif /* _L2TP_CORE_H_ */ #endif /* _L2TP_CORE_H_ */
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/socket.h> #include <linux/socket.h>
...@@ -325,11 +327,11 @@ static int __init l2tp_debugfs_init(void) ...@@ -325,11 +327,11 @@ static int __init l2tp_debugfs_init(void)
if (tunnels == NULL) if (tunnels == NULL)
rc = -EIO; rc = -EIO;
printk(KERN_INFO "L2TP debugfs support\n"); pr_info("L2TP debugfs support\n");
out: out:
if (rc) if (rc)
printk(KERN_WARNING "l2tp debugfs: unable to init\n"); pr_warn("unable to init\n");
return rc; return rc;
} }
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/socket.h> #include <linux/socket.h>
...@@ -115,21 +117,14 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, ...@@ -115,21 +117,14 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
if (session->debug & L2TP_MSG_DATA) { if (session->debug & L2TP_MSG_DATA) {
unsigned int length; unsigned int length;
int offset;
u8 *ptr = skb->data; u8 *ptr = skb->data;
length = min(32u, skb->len); length = min(32u, skb->len);
if (!pskb_may_pull(skb, length)) if (!pskb_may_pull(skb, length))
goto error; goto error;
printk(KERN_DEBUG "%s: eth recv: ", session->name); pr_debug("%s: eth recv\n", session->name);
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
offset = 0;
do {
printk(" %02X", ptr[offset]);
} while (++offset < length);
printk("\n");
} }
if (!pskb_may_pull(skb, sizeof(ETH_HLEN))) if (!pskb_may_pull(skb, sizeof(ETH_HLEN)))
...@@ -308,7 +303,7 @@ static int __init l2tp_eth_init(void) ...@@ -308,7 +303,7 @@ static int __init l2tp_eth_init(void)
if (err) if (err)
goto out_unreg; goto out_unreg;
printk(KERN_INFO "L2TP ethernet pseudowire support (L2TPv3)\n"); pr_info("L2TP ethernet pseudowire support (L2TPv3)\n");
return 0; return 0;
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/icmp.h> #include <linux/icmp.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
...@@ -120,7 +122,6 @@ static int l2tp_ip_recv(struct sk_buff *skb) ...@@ -120,7 +122,6 @@ static int l2tp_ip_recv(struct sk_buff *skb)
struct l2tp_session *session; struct l2tp_session *session;
struct l2tp_tunnel *tunnel = NULL; struct l2tp_tunnel *tunnel = NULL;
int length; int length;
int offset;
/* Point to L2TP header */ /* Point to L2TP header */
optr = ptr = skb->data; optr = ptr = skb->data;
...@@ -155,14 +156,8 @@ static int l2tp_ip_recv(struct sk_buff *skb) ...@@ -155,14 +156,8 @@ static int l2tp_ip_recv(struct sk_buff *skb)
if (!pskb_may_pull(skb, length)) if (!pskb_may_pull(skb, length))
goto discard; goto discard;
printk(KERN_DEBUG "%s: ip recv: ", tunnel->name); pr_debug("%s: ip recv\n", tunnel->name);
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
offset = 0;
do {
printk(" %02X", ptr[offset]);
} while (++offset < length);
printk("\n");
} }
l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, tunnel->recv_payload_hook); 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,7 +588,7 @@ static int __init l2tp_ip_init(void)
{ {
int err; int err;
printk(KERN_INFO "L2TP IP encapsulation support (L2TPv3)\n"); pr_info("L2TP IP encapsulation support (L2TPv3)\n");
err = proto_register(&l2tp_ip_prot, 1); err = proto_register(&l2tp_ip_prot, 1);
if (err != 0) if (err != 0)
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/icmp.h> #include <linux/icmp.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
...@@ -133,7 +135,6 @@ static int l2tp_ip6_recv(struct sk_buff *skb) ...@@ -133,7 +135,6 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
struct l2tp_session *session; struct l2tp_session *session;
struct l2tp_tunnel *tunnel = NULL; struct l2tp_tunnel *tunnel = NULL;
int length; int length;
int offset;
/* Point to L2TP header */ /* Point to L2TP header */
optr = ptr = skb->data; optr = ptr = skb->data;
...@@ -168,14 +169,8 @@ static int l2tp_ip6_recv(struct sk_buff *skb) ...@@ -168,14 +169,8 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
if (!pskb_may_pull(skb, length)) if (!pskb_may_pull(skb, length))
goto discard; goto discard;
printk(KERN_DEBUG "%s: ip recv: ", tunnel->name); pr_debug("%s: ip recv\n", tunnel->name);
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
offset = 0;
do {
printk(" %02X", ptr[offset]);
} while (++offset < length);
printk("\n");
} }
l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, l2tp_recv_common(session, skb, ptr, optr, 0, skb->len,
...@@ -752,7 +747,7 @@ static int __init l2tp_ip6_init(void) ...@@ -752,7 +747,7 @@ static int __init l2tp_ip6_init(void)
{ {
int err; int err;
printk(KERN_INFO "L2TP IP encapsulation support for IPv6 (L2TPv3)\n"); pr_info("L2TP IP encapsulation support for IPv6 (L2TPv3)\n");
err = proto_register(&l2tp_ip6_prot, 1); err = proto_register(&l2tp_ip6_prot, 1);
if (err != 0) if (err != 0)
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <net/sock.h> #include <net/sock.h>
#include <net/genetlink.h> #include <net/genetlink.h>
#include <net/udp.h> #include <net/udp.h>
...@@ -902,7 +904,7 @@ static int l2tp_nl_init(void) ...@@ -902,7 +904,7 @@ static int l2tp_nl_init(void)
{ {
int err; int err;
printk(KERN_INFO "L2TP netlink interface\n"); pr_info("L2TP netlink interface\n");
err = genl_register_family_with_ops(&l2tp_nl_family, l2tp_nl_ops, err = genl_register_family_with_ops(&l2tp_nl_family, l2tp_nl_ops,
ARRAY_SIZE(l2tp_nl_ops)); ARRAY_SIZE(l2tp_nl_ops));
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment