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
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -86,12 +88,6 @@ ...@@ -86,12 +88,6 @@
/* Default trace flags */ /* Default trace flags */
#define L2TP_DEFAULT_DEBUG_FLAGS 0 #define L2TP_DEFAULT_DEBUG_FLAGS 0
#define PRINTK(_mask, _type, _lvl, _fmt, args...) \
do { \
if ((_mask) & (_type)) \
printk(_lvl "L2TP: " _fmt, ##args); \
} while (0)
/* Private data stored for received packets in the skb. /* Private data stored for received packets in the skb.
*/ */
struct l2tp_skb_cb { struct l2tp_skb_cb {
...@@ -141,14 +137,20 @@ static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel) ...@@ -141,14 +137,20 @@ static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel)
l2tp_tunnel_free(tunnel); l2tp_tunnel_free(tunnel);
} }
#ifdef L2TP_REFCNT_DEBUG #ifdef L2TP_REFCNT_DEBUG
#define l2tp_tunnel_inc_refcount(_t) do { \ #define l2tp_tunnel_inc_refcount(_t) \
printk(KERN_DEBUG "l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \ do { \
pr_debug("l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n", \
__func__, __LINE__, (_t)->name, \
atomic_read(&_t->ref_count)); \
l2tp_tunnel_inc_refcount_1(_t); \ l2tp_tunnel_inc_refcount_1(_t); \
} while (0) } while (0)
#define l2tp_tunnel_dec_refcount(_t) do { \ #define l2tp_tunnel_dec_refcount(_t)
printk(KERN_DEBUG "l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \ do { \
pr_debug("l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n", \
__func__, __LINE__, (_t)->name, \
atomic_read(&_t->ref_count)); \
l2tp_tunnel_dec_refcount_1(_t); \ l2tp_tunnel_dec_refcount_1(_t); \
} while (0) } while (0)
#else #else
#define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t) #define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t)
#define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t) #define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t)
...@@ -337,7 +339,7 @@ static void l2tp_recv_queue_skb(struct l2tp_session *session, struct sk_buff *sk ...@@ -337,7 +339,7 @@ static void l2tp_recv_queue_skb(struct l2tp_session *session, struct sk_buff *sk
skb_queue_walk_safe(&session->reorder_q, skbp, tmp) { skb_queue_walk_safe(&session->reorder_q, skbp, tmp) {
if (L2TP_SKB_CB(skbp)->ns > ns) { if (L2TP_SKB_CB(skbp)->ns > ns) {
__skb_queue_before(&session->reorder_q, skbp, skb); __skb_queue_before(&session->reorder_q, skbp, skb);
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ,
"%s: pkt %hu, inserted before %hu, reorder_q len=%d\n", "%s: pkt %hu, inserted before %hu, reorder_q len=%d\n",
session->name, ns, L2TP_SKB_CB(skbp)->ns, session->name, ns, L2TP_SKB_CB(skbp)->ns,
skb_queue_len(&session->reorder_q)); skb_queue_len(&session->reorder_q));
...@@ -386,8 +388,8 @@ static void l2tp_recv_dequeue_skb(struct l2tp_session *session, struct sk_buff * ...@@ -386,8 +388,8 @@ static void l2tp_recv_dequeue_skb(struct l2tp_session *session, struct sk_buff *
else else
session->nr &= 0xffffff; session->nr &= 0xffffff;
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ, "%s: updated nr to %hu\n",
"%s: updated nr to %hu\n", session->name, session->nr); session->name, session->nr);
} }
/* call private receive handler */ /* call private receive handler */
...@@ -422,9 +424,8 @@ static void l2tp_recv_dequeue(struct l2tp_session *session) ...@@ -422,9 +424,8 @@ static void l2tp_recv_dequeue(struct l2tp_session *session)
sstats->rx_seq_discards++; sstats->rx_seq_discards++;
sstats->rx_errors++; sstats->rx_errors++;
u64_stats_update_end(&sstats->syncp); u64_stats_update_end(&sstats->syncp);
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ,
"%s: oos pkt %u len %d discarded (too old), " "%s: oos pkt %u len %d discarded (too old), waiting for %u, reorder_q_len=%d\n",
"waiting for %u, reorder_q_len=%d\n",
session->name, L2TP_SKB_CB(skb)->ns, session->name, L2TP_SKB_CB(skb)->ns,
L2TP_SKB_CB(skb)->length, session->nr, L2TP_SKB_CB(skb)->length, session->nr,
skb_queue_len(&session->reorder_q)); skb_queue_len(&session->reorder_q));
...@@ -438,7 +439,7 @@ static void l2tp_recv_dequeue(struct l2tp_session *session) ...@@ -438,7 +439,7 @@ static void l2tp_recv_dequeue(struct l2tp_session *session)
if (L2TP_SKB_CB(skb)->has_seq) { if (L2TP_SKB_CB(skb)->has_seq) {
if (session->reorder_skip) { if (session->reorder_skip) {
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ,
"%s: advancing nr to next pkt: %u -> %u", "%s: advancing nr to next pkt: %u -> %u",
session->name, session->nr, session->name, session->nr,
L2TP_SKB_CB(skb)->ns); L2TP_SKB_CB(skb)->ns);
...@@ -446,9 +447,8 @@ static void l2tp_recv_dequeue(struct l2tp_session *session) ...@@ -446,9 +447,8 @@ static void l2tp_recv_dequeue(struct l2tp_session *session)
session->nr = L2TP_SKB_CB(skb)->ns; session->nr = L2TP_SKB_CB(skb)->ns;
} }
if (L2TP_SKB_CB(skb)->ns != session->nr) { if (L2TP_SKB_CB(skb)->ns != session->nr) {
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ,
"%s: holding oos pkt %u len %d, " "%s: holding oos pkt %u len %d, waiting for %u, reorder_q_len=%d\n",
"waiting for %u, reorder_q_len=%d\n",
session->name, L2TP_SKB_CB(skb)->ns, session->name, L2TP_SKB_CB(skb)->ns,
L2TP_SKB_CB(skb)->length, session->nr, L2TP_SKB_CB(skb)->length, session->nr,
skb_queue_len(&session->reorder_q)); skb_queue_len(&session->reorder_q));
...@@ -595,9 +595,10 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, ...@@ -595,9 +595,10 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
/* Parse and check optional cookie */ /* Parse and check optional cookie */
if (session->peer_cookie_len > 0) { if (session->peer_cookie_len > 0) {
if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) { if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) {
PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO, l2tp_info(tunnel, L2TP_MSG_DATA,
"%s: cookie mismatch (%u/%u). Discarding.\n", "%s: cookie mismatch (%u/%u). Discarding.\n",
tunnel->name, tunnel->tunnel_id, session->session_id); tunnel->name, tunnel->tunnel_id,
session->session_id);
u64_stats_update_begin(&sstats->syncp); u64_stats_update_begin(&sstats->syncp);
sstats->rx_cookie_discards++; sstats->rx_cookie_discards++;
u64_stats_update_end(&sstats->syncp); u64_stats_update_end(&sstats->syncp);
...@@ -626,7 +627,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, ...@@ -626,7 +627,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
L2TP_SKB_CB(skb)->ns = ns; L2TP_SKB_CB(skb)->ns = ns;
L2TP_SKB_CB(skb)->has_seq = 1; L2TP_SKB_CB(skb)->has_seq = 1;
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ,
"%s: recv data ns=%u, nr=%u, session nr=%u\n", "%s: recv data ns=%u, nr=%u, session nr=%u\n",
session->name, ns, nr, session->nr); session->name, ns, nr, session->nr);
} }
...@@ -640,7 +641,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, ...@@ -640,7 +641,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
L2TP_SKB_CB(skb)->ns = ns; L2TP_SKB_CB(skb)->ns = ns;
L2TP_SKB_CB(skb)->has_seq = 1; L2TP_SKB_CB(skb)->has_seq = 1;
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ,
"%s: recv data ns=%u, session nr=%u\n", "%s: recv data ns=%u, session nr=%u\n",
session->name, ns, session->nr); session->name, ns, session->nr);
} }
...@@ -655,7 +656,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, ...@@ -655,7 +656,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
* configure it so. * configure it so.
*/ */
if ((!session->lns_mode) && (!session->send_seq)) { if ((!session->lns_mode) && (!session->send_seq)) {
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_INFO, l2tp_info(session, L2TP_MSG_SEQ,
"%s: requested to enable seq numbers by LNS\n", "%s: requested to enable seq numbers by LNS\n",
session->name); session->name);
session->send_seq = -1; session->send_seq = -1;
...@@ -666,9 +667,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, ...@@ -666,9 +667,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
* If user has configured mandatory sequence numbers, discard. * If user has configured mandatory sequence numbers, discard.
*/ */
if (session->recv_seq) { if (session->recv_seq) {
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_WARNING, l2tp_warn(session, L2TP_MSG_SEQ,
"%s: recv data has no seq numbers when required. " "%s: recv data has no seq numbers when required. Discarding.\n",
"Discarding\n", session->name); session->name);
u64_stats_update_begin(&sstats->syncp); u64_stats_update_begin(&sstats->syncp);
sstats->rx_seq_discards++; sstats->rx_seq_discards++;
u64_stats_update_end(&sstats->syncp); u64_stats_update_end(&sstats->syncp);
...@@ -681,15 +682,15 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, ...@@ -681,15 +682,15 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
* LAC is broken. Discard the frame. * LAC is broken. Discard the frame.
*/ */
if ((!session->lns_mode) && (session->send_seq)) { if ((!session->lns_mode) && (session->send_seq)) {
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_INFO, l2tp_info(session, L2TP_MSG_SEQ,
"%s: requested to disable seq numbers by LNS\n", "%s: requested to disable seq numbers by LNS\n",
session->name); session->name);
session->send_seq = 0; session->send_seq = 0;
l2tp_session_set_header_len(session, tunnel->version); l2tp_session_set_header_len(session, tunnel->version);
} else if (session->send_seq) { } else if (session->send_seq) {
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_WARNING, l2tp_warn(session, L2TP_MSG_SEQ,
"%s: recv data has no seq numbers when required. " "%s: recv data has no seq numbers when required. Discarding.\n",
"Discarding\n", session->name); session->name);
u64_stats_update_begin(&sstats->syncp); u64_stats_update_begin(&sstats->syncp);
sstats->rx_seq_discards++; sstats->rx_seq_discards++;
u64_stats_update_end(&sstats->syncp); u64_stats_update_end(&sstats->syncp);
...@@ -749,9 +750,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, ...@@ -749,9 +750,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
u64_stats_update_begin(&sstats->syncp); u64_stats_update_begin(&sstats->syncp);
sstats->rx_seq_discards++; sstats->rx_seq_discards++;
u64_stats_update_end(&sstats->syncp); u64_stats_update_end(&sstats->syncp);
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ,
"%s: oos pkt %u len %d discarded, " "%s: oos pkt %u len %d discarded, waiting for %u, reorder_q_len=%d\n",
"waiting for %u, reorder_q_len=%d\n",
session->name, L2TP_SKB_CB(skb)->ns, session->name, L2TP_SKB_CB(skb)->ns,
L2TP_SKB_CB(skb)->length, session->nr, L2TP_SKB_CB(skb)->length, session->nr,
skb_queue_len(&session->reorder_q)); skb_queue_len(&session->reorder_q));
...@@ -800,7 +800,6 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, ...@@ -800,7 +800,6 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
unsigned char *ptr, *optr; unsigned char *ptr, *optr;
u16 hdrflags; u16 hdrflags;
u32 tunnel_id, session_id; u32 tunnel_id, session_id;
int offset;
u16 version; u16 version;
int length; int length;
struct l2tp_stats *tstats; struct l2tp_stats *tstats;
...@@ -813,8 +812,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, ...@@ -813,8 +812,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
/* Short packet? */ /* Short packet? */
if (!pskb_may_pull(skb, L2TP_HDR_SIZE_SEQ)) { if (!pskb_may_pull(skb, L2TP_HDR_SIZE_SEQ)) {
PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO, l2tp_info(tunnel, L2TP_MSG_DATA,
"%s: recv short packet (len=%d)\n", tunnel->name, skb->len); "%s: recv short packet (len=%d)\n",
tunnel->name, skb->len);
goto error; goto error;
} }
...@@ -824,14 +824,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, ...@@ -824,14 +824,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
if (!pskb_may_pull(skb, length)) if (!pskb_may_pull(skb, length))
goto error; goto error;
printk(KERN_DEBUG "%s: recv: ", tunnel->name); pr_debug("%s: recv\n", tunnel->name);
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, skb->data, length);
offset = 0;
do {
printk(" %02X", skb->data[offset]);
} while (++offset < length);
printk("\n");
} }
/* Point to L2TP header */ /* Point to L2TP header */
...@@ -843,7 +837,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, ...@@ -843,7 +837,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
/* Check protocol version */ /* Check protocol version */
version = hdrflags & L2TP_HDR_VER_MASK; version = hdrflags & L2TP_HDR_VER_MASK;
if (version != tunnel->version) { if (version != tunnel->version) {
PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO, l2tp_info(tunnel, L2TP_MSG_DATA,
"%s: recv protocol version mismatch: got %d expected %d\n", "%s: recv protocol version mismatch: got %d expected %d\n",
tunnel->name, version, tunnel->version); tunnel->name, version, tunnel->version);
goto error; goto error;
...@@ -854,8 +848,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, ...@@ -854,8 +848,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
/* If type is control packet, it is handled by userspace. */ /* If type is control packet, it is handled by userspace. */
if (hdrflags & L2TP_HDRFLAG_T) { if (hdrflags & L2TP_HDRFLAG_T) {
PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_DEBUG, l2tp_dbg(tunnel, L2TP_MSG_DATA,
"%s: recv control packet, len=%d\n", tunnel->name, length); "%s: recv control packet, len=%d\n",
tunnel->name, length);
goto error; goto error;
} }
...@@ -883,7 +878,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, ...@@ -883,7 +878,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
session = l2tp_session_find(tunnel->l2tp_net, tunnel, session_id); session = l2tp_session_find(tunnel->l2tp_net, tunnel, session_id);
if (!session || !session->recv_skb) { if (!session || !session->recv_skb) {
/* Not found? Pass to userspace to deal with */ /* Not found? Pass to userspace to deal with */
PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO, l2tp_info(tunnel, L2TP_MSG_DATA,
"%s: no session found (%u/%u). Passing up.\n", "%s: no session found (%u/%u). Passing up.\n",
tunnel->name, tunnel_id, session_id); tunnel->name, tunnel_id, session_id);
goto error; goto error;
...@@ -925,8 +920,8 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb) ...@@ -925,8 +920,8 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
if (tunnel == NULL) if (tunnel == NULL)
goto pass_up; goto pass_up;
PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_DEBUG, l2tp_dbg(tunnel, L2TP_MSG_DATA, "%s: received %d bytes\n",
"%s: received %d bytes\n", tunnel->name, skb->len); tunnel->name, skb->len);
if (l2tp_udp_recv_core(tunnel, skb, tunnel->recv_payload_hook)) if (l2tp_udp_recv_core(tunnel, skb, tunnel->recv_payload_hook))
goto pass_up_put; goto pass_up_put;
...@@ -968,8 +963,8 @@ static int l2tp_build_l2tpv2_header(struct l2tp_session *session, void *buf) ...@@ -968,8 +963,8 @@ static int l2tp_build_l2tpv2_header(struct l2tp_session *session, void *buf)
*bufp++ = 0; *bufp++ = 0;
session->ns++; session->ns++;
session->ns &= 0xffff; session->ns &= 0xffff;
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ, "%s: updated ns to %u\n",
"%s: updated ns to %u\n", session->name, session->ns); session->name, session->ns);
} }
return bufp - optr; return bufp - optr;
...@@ -1005,8 +1000,9 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf) ...@@ -1005,8 +1000,9 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf)
l2h = 0x40000000 | session->ns; l2h = 0x40000000 | session->ns;
session->ns++; session->ns++;
session->ns &= 0xffffff; session->ns &= 0xffffff;
PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_SEQ,
"%s: updated ns to %u\n", session->name, session->ns); "%s: updated ns to %u\n",
session->name, session->ns);
} }
*((__be32 *) bufp) = htonl(l2h); *((__be32 *) bufp) = htonl(l2h);
...@@ -1029,27 +1025,19 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, ...@@ -1029,27 +1025,19 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
/* Debug */ /* Debug */
if (session->send_seq) if (session->send_seq)
PRINTK(session->debug, L2TP_MSG_DATA, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_DATA, "%s: send %Zd bytes, ns=%u\n",
"%s: send %Zd bytes, ns=%u\n", session->name, session->name, data_len, session->ns - 1);
data_len, session->ns - 1);
else else
PRINTK(session->debug, L2TP_MSG_DATA, KERN_DEBUG, l2tp_dbg(session, L2TP_MSG_DATA, "%s: send %Zd bytes\n",
"%s: send %Zd bytes\n", session->name, data_len); session->name, data_len);
if (session->debug & L2TP_MSG_DATA) { if (session->debug & L2TP_MSG_DATA) {
int i;
int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0; int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
unsigned char *datap = skb->data + uhlen; unsigned char *datap = skb->data + uhlen;
printk(KERN_DEBUG "%s: xmit:", session->name); pr_debug("%s: xmit\n", session->name);
for (i = 0; i < (len - uhlen); i++) { print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
printk(" %02X", *datap++); datap, min_t(size_t, 32, len - uhlen));
if (i == 31) {
printk(" ...");
break;
}
}
printk("\n");
} }
/* Queue the packet to IP for output */ /* Queue the packet to IP for output */
...@@ -1248,8 +1236,7 @@ static void l2tp_tunnel_destruct(struct sock *sk) ...@@ -1248,8 +1236,7 @@ static void l2tp_tunnel_destruct(struct sock *sk)
if (tunnel == NULL) if (tunnel == NULL)
goto end; goto end;
PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO, l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing...\n", tunnel->name);
"%s: closing...\n", tunnel->name);
/* Close all sessions */ /* Close all sessions */
l2tp_tunnel_closeall(tunnel); l2tp_tunnel_closeall(tunnel);
...@@ -1291,8 +1278,8 @@ static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel) ...@@ -1291,8 +1278,8 @@ static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
BUG_ON(tunnel == NULL); BUG_ON(tunnel == NULL);
PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO, l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing all sessions...\n",
"%s: closing all sessions...\n", tunnel->name); tunnel->name);
write_lock_bh(&tunnel->hlist_lock); write_lock_bh(&tunnel->hlist_lock);
for (hash = 0; hash < L2TP_HASH_SIZE; hash++) { for (hash = 0; hash < L2TP_HASH_SIZE; hash++) {
...@@ -1300,7 +1287,7 @@ static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel) ...@@ -1300,7 +1287,7 @@ static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) { hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) {
session = hlist_entry(walk, struct l2tp_session, hlist); session = hlist_entry(walk, struct l2tp_session, hlist);
PRINTK(session->debug, L2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, L2TP_MSG_CONTROL,
"%s: closing session\n", session->name); "%s: closing session\n", session->name);
hlist_del_init(&session->hlist); hlist_del_init(&session->hlist);
...@@ -1354,8 +1341,7 @@ static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel) ...@@ -1354,8 +1341,7 @@ static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel)
BUG_ON(atomic_read(&tunnel->ref_count) != 0); BUG_ON(atomic_read(&tunnel->ref_count) != 0);
BUG_ON(tunnel->sock != NULL); BUG_ON(tunnel->sock != NULL);
PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO, l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: free...\n", tunnel->name);
"%s: free...\n", tunnel->name);
/* Remove from tunnel list */ /* Remove from tunnel list */
spin_lock_bh(&pn->l2tp_tunnel_list_lock); 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,7 +1522,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
err = -EBADF; err = -EBADF;
sock = sockfd_lookup(fd, &err); sock = sockfd_lookup(fd, &err);
if (!sock) { if (!sock) {
printk(KERN_ERR "tunl %hu: sockfd_lookup(fd=%d) returned %d\n", pr_err("tunl %hu: sockfd_lookup(fd=%d) returned %d\n",
tunnel_id, fd, err); tunnel_id, fd, err);
goto err; goto err;
} }
...@@ -1552,7 +1538,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32 ...@@ -1552,7 +1538,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
case L2TP_ENCAPTYPE_UDP: case L2TP_ENCAPTYPE_UDP:
err = -EPROTONOSUPPORT; err = -EPROTONOSUPPORT;
if (sk->sk_protocol != IPPROTO_UDP) { if (sk->sk_protocol != IPPROTO_UDP) {
printk(KERN_ERR "tunl %hu: fd %d wrong protocol, got %d, expected %d\n", pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
tunnel_id, fd, sk->sk_protocol, IPPROTO_UDP); tunnel_id, fd, sk->sk_protocol, IPPROTO_UDP);
goto err; goto err;
} }
...@@ -1560,7 +1546,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32 ...@@ -1560,7 +1546,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
case L2TP_ENCAPTYPE_IP: case L2TP_ENCAPTYPE_IP:
err = -EPROTONOSUPPORT; err = -EPROTONOSUPPORT;
if (sk->sk_protocol != IPPROTO_L2TP) { if (sk->sk_protocol != IPPROTO_L2TP) {
printk(KERN_ERR "tunl %hu: fd %d wrong protocol, got %d, expected %d\n", pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
tunnel_id, fd, sk->sk_protocol, IPPROTO_L2TP); tunnel_id, fd, sk->sk_protocol, IPPROTO_L2TP);
goto err; goto err;
} }
...@@ -1868,7 +1854,7 @@ static int __init l2tp_init(void) ...@@ -1868,7 +1854,7 @@ static int __init l2tp_init(void)
if (rc) if (rc)
goto out; goto out;
printk(KERN_INFO "L2TP core driver, %s\n", L2TP_DRV_VERSION); pr_info("L2TP core driver, %s\n", L2TP_DRV_VERSION);
out: out:
return rc; return rc;
......
...@@ -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));
......
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
* http://openl2tp.sourceforge.net. * http://openl2tp.sourceforge.net.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -106,12 +108,6 @@ ...@@ -106,12 +108,6 @@
/* Space for UDP, L2TP and PPP headers */ /* Space for UDP, L2TP and PPP headers */
#define PPPOL2TP_HEADER_OVERHEAD 40 #define PPPOL2TP_HEADER_OVERHEAD 40
#define PRINTK(_mask, _type, _lvl, _fmt, args...) \
do { \
if ((_mask) & (_type)) \
printk(_lvl "PPPOL2TP: " _fmt, ##args); \
} while (0)
/* Number of bytes to build transmit L2TP headers. /* Number of bytes to build transmit L2TP headers.
* Unfortunately the size is different depending on whether sequence numbers * Unfortunately the size is different depending on whether sequence numbers
* are enabled. * are enabled.
...@@ -236,7 +232,7 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int ...@@ -236,7 +232,7 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
if (sk->sk_state & PPPOX_BOUND) { if (sk->sk_state & PPPOX_BOUND) {
struct pppox_sock *po; struct pppox_sock *po;
PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG, l2tp_dbg(session, PPPOL2TP_MSG_DATA,
"%s: recv %d byte data frame, passing to ppp\n", "%s: recv %d byte data frame, passing to ppp\n",
session->name, data_len); session->name, data_len);
...@@ -259,8 +255,8 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int ...@@ -259,8 +255,8 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
po = pppox_sk(sk); po = pppox_sk(sk);
ppp_input(&po->chan, skb); ppp_input(&po->chan, skb);
} else { } else {
PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_DATA, "%s: socket not bound\n",
"%s: socket not bound\n", session->name); session->name);
/* Not bound. Nothing we can do, so discard. */ /* Not bound. Nothing we can do, so discard. */
session->stats.rx_errors++; session->stats.rx_errors++;
...@@ -270,8 +266,7 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int ...@@ -270,8 +266,7 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
return; return;
no_sock: no_sock:
PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_DATA, "%s: no socket\n", session->name);
"%s: no socket\n", session->name);
kfree_skb(skb); kfree_skb(skb);
} }
...@@ -827,8 +822,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, ...@@ -827,8 +822,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
/* This is how we get the session context from the socket. */ /* This is how we get the session context from the socket. */
sk->sk_user_data = session; sk->sk_user_data = session;
sk->sk_state = PPPOX_CONNECTED; sk->sk_state = PPPOX_CONNECTED;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: created\n",
"%s: created\n", session->name); session->name);
end: end:
release_sock(sk); release_sock(sk);
...@@ -881,8 +876,8 @@ static int pppol2tp_session_create(struct net *net, u32 tunnel_id, u32 session_i ...@@ -881,8 +876,8 @@ static int pppol2tp_session_create(struct net *net, u32 tunnel_id, u32 session_i
ps = l2tp_session_priv(session); ps = l2tp_session_priv(session);
ps->tunnel_sock = tunnel->sock; ps->tunnel_sock = tunnel->sock;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: created\n",
"%s: created\n", session->name); session->name);
error = 0; error = 0;
...@@ -1058,7 +1053,7 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, ...@@ -1058,7 +1053,7 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
struct l2tp_tunnel *tunnel = session->tunnel; struct l2tp_tunnel *tunnel = session->tunnel;
struct pppol2tp_ioc_stats stats; struct pppol2tp_ioc_stats stats;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG, l2tp_dbg(session, PPPOL2TP_MSG_CONTROL,
"%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n", "%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n",
session->name, cmd, arg); session->name, cmd, arg);
...@@ -1078,8 +1073,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, ...@@ -1078,8 +1073,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
if (copy_to_user((void __user *) arg, &ifr, sizeof(struct ifreq))) if (copy_to_user((void __user *) arg, &ifr, sizeof(struct ifreq)))
break; break;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get mtu=%d\n",
"%s: get mtu=%d\n", session->name, session->mtu); session->name, session->mtu);
err = 0; err = 0;
break; break;
...@@ -1094,8 +1089,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, ...@@ -1094,8 +1089,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
session->mtu = ifr.ifr_mtu; session->mtu = ifr.ifr_mtu;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set mtu=%d\n",
"%s: set mtu=%d\n", session->name, session->mtu); session->name, session->mtu);
err = 0; err = 0;
break; break;
...@@ -1108,8 +1103,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, ...@@ -1108,8 +1103,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
if (put_user(session->mru, (int __user *) arg)) if (put_user(session->mru, (int __user *) arg))
break; break;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get mru=%d\n",
"%s: get mru=%d\n", session->name, session->mru); session->name, session->mru);
err = 0; err = 0;
break; break;
...@@ -1123,8 +1118,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, ...@@ -1123,8 +1118,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
break; break;
session->mru = val; session->mru = val;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set mru=%d\n",
"%s: set mru=%d\n", session->name, session->mru); session->name, session->mru);
err = 0; err = 0;
break; break;
...@@ -1133,8 +1128,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, ...@@ -1133,8 +1128,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
if (put_user(ps->flags, (int __user *) arg)) if (put_user(ps->flags, (int __user *) arg))
break; break;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get flags=%d\n",
"%s: get flags=%d\n", session->name, ps->flags); session->name, ps->flags);
err = 0; err = 0;
break; break;
...@@ -1143,8 +1138,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, ...@@ -1143,8 +1138,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
if (get_user(val, (int __user *) arg)) if (get_user(val, (int __user *) arg))
break; break;
ps->flags = val; ps->flags = val;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set flags=%d\n",
"%s: set flags=%d\n", session->name, ps->flags); session->name, ps->flags);
err = 0; err = 0;
break; break;
...@@ -1160,8 +1155,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, ...@@ -1160,8 +1155,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
if (copy_to_user((void __user *) arg, &stats, if (copy_to_user((void __user *) arg, &stats,
sizeof(stats))) sizeof(stats)))
break; break;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get L2TP stats\n",
"%s: get L2TP stats\n", session->name); session->name);
err = 0; err = 0;
break; break;
...@@ -1188,7 +1183,7 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel, ...@@ -1188,7 +1183,7 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
struct sock *sk; struct sock *sk;
struct pppol2tp_ioc_stats stats; struct pppol2tp_ioc_stats stats;
PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG, l2tp_dbg(tunnel, PPPOL2TP_MSG_CONTROL,
"%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n", "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n",
tunnel->name, cmd, arg); tunnel->name, cmd, arg);
...@@ -1224,8 +1219,8 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel, ...@@ -1224,8 +1219,8 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
err = -EFAULT; err = -EFAULT;
break; break;
} }
PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: get L2TP stats\n",
"%s: get L2TP stats\n", tunnel->name); tunnel->name);
err = 0; err = 0;
break; break;
...@@ -1314,8 +1309,8 @@ static int pppol2tp_tunnel_setsockopt(struct sock *sk, ...@@ -1314,8 +1309,8 @@ static int pppol2tp_tunnel_setsockopt(struct sock *sk,
switch (optname) { switch (optname) {
case PPPOL2TP_SO_DEBUG: case PPPOL2TP_SO_DEBUG:
tunnel->debug = val; tunnel->debug = val;
PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: set debug=%x\n",
"%s: set debug=%x\n", tunnel->name, tunnel->debug); tunnel->name, tunnel->debug);
break; break;
default: default:
...@@ -1342,8 +1337,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk, ...@@ -1342,8 +1337,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
break; break;
} }
session->recv_seq = val ? -1 : 0; session->recv_seq = val ? -1 : 0;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL,
"%s: set recv_seq=%d\n", session->name, session->recv_seq); "%s: set recv_seq=%d\n",
session->name, session->recv_seq);
break; break;
case PPPOL2TP_SO_SENDSEQ: case PPPOL2TP_SO_SENDSEQ:
...@@ -1358,8 +1354,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk, ...@@ -1358,8 +1354,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ : po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ :
PPPOL2TP_L2TP_HDR_SIZE_NOSEQ; PPPOL2TP_L2TP_HDR_SIZE_NOSEQ;
} }
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL,
"%s: set send_seq=%d\n", session->name, session->send_seq); "%s: set send_seq=%d\n",
session->name, session->send_seq);
break; break;
case PPPOL2TP_SO_LNSMODE: case PPPOL2TP_SO_LNSMODE:
...@@ -1368,20 +1365,22 @@ static int pppol2tp_session_setsockopt(struct sock *sk, ...@@ -1368,20 +1365,22 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
break; break;
} }
session->lns_mode = val ? -1 : 0; session->lns_mode = val ? -1 : 0;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL,
"%s: set lns_mode=%d\n", session->name, session->lns_mode); "%s: set lns_mode=%d\n",
session->name, session->lns_mode);
break; break;
case PPPOL2TP_SO_DEBUG: case PPPOL2TP_SO_DEBUG:
session->debug = val; session->debug = val;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set debug=%x\n",
"%s: set debug=%x\n", session->name, session->debug); session->name, session->debug);
break; break;
case PPPOL2TP_SO_REORDERTO: case PPPOL2TP_SO_REORDERTO:
session->reorder_timeout = msecs_to_jiffies(val); session->reorder_timeout = msecs_to_jiffies(val);
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL,
"%s: set reorder_timeout=%d\n", session->name, session->reorder_timeout); "%s: set reorder_timeout=%d\n",
session->name, session->reorder_timeout);
break; break;
default: default:
...@@ -1460,8 +1459,8 @@ static int pppol2tp_tunnel_getsockopt(struct sock *sk, ...@@ -1460,8 +1459,8 @@ static int pppol2tp_tunnel_getsockopt(struct sock *sk,
switch (optname) { switch (optname) {
case PPPOL2TP_SO_DEBUG: case PPPOL2TP_SO_DEBUG:
*val = tunnel->debug; *val = tunnel->debug;
PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: get debug=%x\n",
"%s: get debug=%x\n", tunnel->name, tunnel->debug); tunnel->name, tunnel->debug);
break; break;
default: default:
...@@ -1483,31 +1482,31 @@ static int pppol2tp_session_getsockopt(struct sock *sk, ...@@ -1483,31 +1482,31 @@ static int pppol2tp_session_getsockopt(struct sock *sk,
switch (optname) { switch (optname) {
case PPPOL2TP_SO_RECVSEQ: case PPPOL2TP_SO_RECVSEQ:
*val = session->recv_seq; *val = session->recv_seq;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL,
"%s: get recv_seq=%d\n", session->name, *val); "%s: get recv_seq=%d\n", session->name, *val);
break; break;
case PPPOL2TP_SO_SENDSEQ: case PPPOL2TP_SO_SENDSEQ:
*val = session->send_seq; *val = session->send_seq;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL,
"%s: get send_seq=%d\n", session->name, *val); "%s: get send_seq=%d\n", session->name, *val);
break; break;
case PPPOL2TP_SO_LNSMODE: case PPPOL2TP_SO_LNSMODE:
*val = session->lns_mode; *val = session->lns_mode;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL,
"%s: get lns_mode=%d\n", session->name, *val); "%s: get lns_mode=%d\n", session->name, *val);
break; break;
case PPPOL2TP_SO_DEBUG: case PPPOL2TP_SO_DEBUG:
*val = session->debug; *val = session->debug;
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get debug=%d\n",
"%s: get debug=%d\n", session->name, *val); session->name, *val);
break; break;
case PPPOL2TP_SO_REORDERTO: case PPPOL2TP_SO_REORDERTO:
*val = (int) jiffies_to_msecs(session->reorder_timeout); *val = (int) jiffies_to_msecs(session->reorder_timeout);
PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, l2tp_info(session, PPPOL2TP_MSG_CONTROL,
"%s: get reorder_timeout=%d\n", session->name, *val); "%s: get reorder_timeout=%d\n", session->name, *val);
break; break;
...@@ -1871,8 +1870,7 @@ static int __init pppol2tp_init(void) ...@@ -1871,8 +1870,7 @@ static int __init pppol2tp_init(void)
goto out_unregister_pppox; goto out_unregister_pppox;
#endif #endif
printk(KERN_INFO "PPPoL2TP kernel driver, %s\n", pr_info("PPPoL2TP kernel driver, %s\n", PPPOL2TP_DRV_VERSION);
PPPOL2TP_DRV_VERSION);
out: out:
return err; return err;
......
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