Skip to content

Commit

Permalink
net: l2tp: Standardize logging styles
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joe Perches authored and David S. Miller committed May 17, 2012
1 parent 0289403 commit a4ca44f
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 221 deletions.
216 changes: 101 additions & 115 deletions net/l2tp/l2tp_core.c

Large diffs are not rendered by default.

35 changes: 27 additions & 8 deletions net/l2tp/l2tp_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,36 @@ static inline void l2tp_session_dec_refcount_1(struct l2tp_session *session)
}

#ifdef L2TP_REFCNT_DEBUG
#define l2tp_session_inc_refcount(_s) do { \
printk(KERN_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); \
} while (0)
#define l2tp_session_dec_refcount(_s) do { \
printk(KERN_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); \
} while (0)
#define l2tp_session_inc_refcount(_s) \
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); \
} while (0)
#define l2tp_session_dec_refcount(_s) \
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); \
} while (0)
#else
#define l2tp_session_inc_refcount(s) l2tp_session_inc_refcount_1(s)
#define l2tp_session_dec_refcount(s) l2tp_session_dec_refcount_1(s)
#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_ */
6 changes: 4 additions & 2 deletions net/l2tp/l2tp_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* 2 of the License, or (at your option) any later version.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/socket.h>
Expand Down Expand Up @@ -325,11 +327,11 @@ static int __init l2tp_debugfs_init(void)
if (tunnels == NULL)
rc = -EIO;

printk(KERN_INFO "L2TP debugfs support\n");
pr_info("L2TP debugfs support\n");

out:
if (rc)
printk(KERN_WARNING "l2tp debugfs: unable to init\n");
pr_warn("unable to init\n");

return rc;
}
Expand Down
15 changes: 5 additions & 10 deletions net/l2tp/l2tp_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* 2 of the License, or (at your option) any later version.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/socket.h>
Expand Down Expand Up @@ -115,21 +117,14 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,

if (session->debug & L2TP_MSG_DATA) {
unsigned int length;
int offset;
u8 *ptr = skb->data;

length = min(32u, skb->len);
if (!pskb_may_pull(skb, length))
goto error;

printk(KERN_DEBUG "%s: eth recv: ", session->name);

offset = 0;
do {
printk(" %02X", ptr[offset]);
} while (++offset < length);

printk("\n");
pr_debug("%s: eth recv\n", session->name);
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
}

if (!pskb_may_pull(skb, sizeof(ETH_HLEN)))
Expand Down Expand Up @@ -308,7 +303,7 @@ static int __init l2tp_eth_init(void)
if (err)
goto out_unreg;

printk(KERN_INFO "L2TP ethernet pseudowire support (L2TPv3)\n");
pr_info("L2TP ethernet pseudowire support (L2TPv3)\n");

return 0;

Expand Down
15 changes: 5 additions & 10 deletions net/l2tp/l2tp_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* 2 of the License, or (at your option) any later version.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/icmp.h>
#include <linux/module.h>
#include <linux/skbuff.h>
Expand Down Expand Up @@ -120,7 +122,6 @@ static int l2tp_ip_recv(struct sk_buff *skb)
struct l2tp_session *session;
struct l2tp_tunnel *tunnel = NULL;
int length;
int offset;

/* Point to L2TP header */
optr = ptr = skb->data;
Expand Down Expand Up @@ -155,14 +156,8 @@ static int l2tp_ip_recv(struct sk_buff *skb)
if (!pskb_may_pull(skb, length))
goto discard;

printk(KERN_DEBUG "%s: ip recv: ", tunnel->name);

offset = 0;
do {
printk(" %02X", ptr[offset]);
} while (++offset < length);

printk("\n");
pr_debug("%s: ip recv\n", tunnel->name);
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
}

l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, tunnel->recv_payload_hook);
Expand Down Expand Up @@ -593,7 +588,7 @@ static int __init l2tp_ip_init(void)
{
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);
if (err != 0)
Expand Down
15 changes: 5 additions & 10 deletions net/l2tp/l2tp_ip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* 2 of the License, or (at your option) any later version.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/icmp.h>
#include <linux/module.h>
#include <linux/skbuff.h>
Expand Down Expand Up @@ -133,7 +135,6 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
struct l2tp_session *session;
struct l2tp_tunnel *tunnel = NULL;
int length;
int offset;

/* Point to L2TP header */
optr = ptr = skb->data;
Expand Down Expand Up @@ -168,14 +169,8 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
if (!pskb_may_pull(skb, length))
goto discard;

printk(KERN_DEBUG "%s: ip recv: ", tunnel->name);

offset = 0;
do {
printk(" %02X", ptr[offset]);
} while (++offset < length);

printk("\n");
pr_debug("%s: ip recv\n", tunnel->name);
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
}

l2tp_recv_common(session, skb, ptr, optr, 0, skb->len,
Expand Down Expand Up @@ -752,7 +747,7 @@ static int __init l2tp_ip6_init(void)
{
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);
if (err != 0)
Expand Down
4 changes: 3 additions & 1 deletion net/l2tp/l2tp_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* published by the Free Software Foundation.
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <net/sock.h>
#include <net/genetlink.h>
#include <net/udp.h>
Expand Down Expand Up @@ -902,7 +904,7 @@ static int l2tp_nl_init(void)
{
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,
ARRAY_SIZE(l2tp_nl_ops));

Expand Down
Loading

0 comments on commit a4ca44f

Please sign in to comment.