aboutsummaryrefslogtreecommitdiffstats
path: root/net/l2tp/l2tp_ppp.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-05-16 05:55:56 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-17 04:34:38 -0400
commita4ca44fa578c7c7fd123b7fba3c2c98d4ba4e53d (patch)
tree58be0839a0c08ee8eaff4fac160dfb70b6982a70 /net/l2tp/l2tp_ppp.c
parent028940342a906db8da014a7603a0deddc2c323dd (diff)
net: l2tp: Standardize logging styles
Use more current logging styles. Add pr_fmt to prefix output appropriately. Convert printks to pr_<level>. Convert PRINTK macros to new l2tp_<level> macros. Neaten some <foo>_refcount debugging macros. Use print_hex_dump_bytes instead of hand-coded loops. Coalesce formats and align arguments. Some KERN_DEBUG output is not now emitted unless dynamic_debugging is enabled. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: James Chapman <jchapman@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/l2tp/l2tp_ppp.c')
-rw-r--r--net/l2tp/l2tp_ppp.c128
1 files changed, 63 insertions, 65 deletions
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 9f2c421aa307..8ef6b9416cba 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -57,6 +57,8 @@
57 * http://openl2tp.sourceforge.net. 57 * http://openl2tp.sourceforge.net.
58 */ 58 */
59 59
60#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
61
60#include <linux/module.h> 62#include <linux/module.h>
61#include <linux/string.h> 63#include <linux/string.h>
62#include <linux/list.h> 64#include <linux/list.h>
@@ -106,12 +108,6 @@
106/* Space for UDP, L2TP and PPP headers */ 108/* Space for UDP, L2TP and PPP headers */
107#define PPPOL2TP_HEADER_OVERHEAD 40 109#define PPPOL2TP_HEADER_OVERHEAD 40
108 110
109#define PRINTK(_mask, _type, _lvl, _fmt, args...) \
110 do { \
111 if ((_mask) & (_type)) \
112 printk(_lvl "PPPOL2TP: " _fmt, ##args); \
113 } while (0)
114
115/* Number of bytes to build transmit L2TP headers. 111/* Number of bytes to build transmit L2TP headers.
116 * Unfortunately the size is different depending on whether sequence numbers 112 * Unfortunately the size is different depending on whether sequence numbers
117 * are enabled. 113 * are enabled.
@@ -236,9 +232,9 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
236 232
237 if (sk->sk_state & PPPOX_BOUND) { 233 if (sk->sk_state & PPPOX_BOUND) {
238 struct pppox_sock *po; 234 struct pppox_sock *po;
239 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG, 235 l2tp_dbg(session, PPPOL2TP_MSG_DATA,
240 "%s: recv %d byte data frame, passing to ppp\n", 236 "%s: recv %d byte data frame, passing to ppp\n",
241 session->name, data_len); 237 session->name, data_len);
242 238
243 /* We need to forget all info related to the L2TP packet 239 /* We need to forget all info related to the L2TP packet
244 * gathered in the skb as we are going to reuse the same 240 * gathered in the skb as we are going to reuse the same
@@ -259,8 +255,8 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
259 po = pppox_sk(sk); 255 po = pppox_sk(sk);
260 ppp_input(&po->chan, skb); 256 ppp_input(&po->chan, skb);
261 } else { 257 } else {
262 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_INFO, 258 l2tp_info(session, PPPOL2TP_MSG_DATA, "%s: socket not bound\n",
263 "%s: socket not bound\n", session->name); 259 session->name);
264 260
265 /* Not bound. Nothing we can do, so discard. */ 261 /* Not bound. Nothing we can do, so discard. */
266 session->stats.rx_errors++; 262 session->stats.rx_errors++;
@@ -270,8 +266,7 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
270 return; 266 return;
271 267
272no_sock: 268no_sock:
273 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_INFO, 269 l2tp_info(session, PPPOL2TP_MSG_DATA, "%s: no socket\n", session->name);
274 "%s: no socket\n", session->name);
275 kfree_skb(skb); 270 kfree_skb(skb);
276} 271}
277 272
@@ -827,8 +822,8 @@ out_no_ppp:
827 /* This is how we get the session context from the socket. */ 822 /* This is how we get the session context from the socket. */
828 sk->sk_user_data = session; 823 sk->sk_user_data = session;
829 sk->sk_state = PPPOX_CONNECTED; 824 sk->sk_state = PPPOX_CONNECTED;
830 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 825 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: created\n",
831 "%s: created\n", session->name); 826 session->name);
832 827
833end: 828end:
834 release_sock(sk); 829 release_sock(sk);
@@ -881,8 +876,8 @@ static int pppol2tp_session_create(struct net *net, u32 tunnel_id, u32 session_i
881 ps = l2tp_session_priv(session); 876 ps = l2tp_session_priv(session);
882 ps->tunnel_sock = tunnel->sock; 877 ps->tunnel_sock = tunnel->sock;
883 878
884 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 879 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: created\n",
885 "%s: created\n", session->name); 880 session->name);
886 881
887 error = 0; 882 error = 0;
888 883
@@ -1058,9 +1053,9 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1058 struct l2tp_tunnel *tunnel = session->tunnel; 1053 struct l2tp_tunnel *tunnel = session->tunnel;
1059 struct pppol2tp_ioc_stats stats; 1054 struct pppol2tp_ioc_stats stats;
1060 1055
1061 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG, 1056 l2tp_dbg(session, PPPOL2TP_MSG_CONTROL,
1062 "%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n", 1057 "%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n",
1063 session->name, cmd, arg); 1058 session->name, cmd, arg);
1064 1059
1065 sk = ps->sock; 1060 sk = ps->sock;
1066 sock_hold(sk); 1061 sock_hold(sk);
@@ -1078,8 +1073,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1078 if (copy_to_user((void __user *) arg, &ifr, sizeof(struct ifreq))) 1073 if (copy_to_user((void __user *) arg, &ifr, sizeof(struct ifreq)))
1079 break; 1074 break;
1080 1075
1081 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1076 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get mtu=%d\n",
1082 "%s: get mtu=%d\n", session->name, session->mtu); 1077 session->name, session->mtu);
1083 err = 0; 1078 err = 0;
1084 break; 1079 break;
1085 1080
@@ -1094,8 +1089,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1094 1089
1095 session->mtu = ifr.ifr_mtu; 1090 session->mtu = ifr.ifr_mtu;
1096 1091
1097 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1092 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set mtu=%d\n",
1098 "%s: set mtu=%d\n", session->name, session->mtu); 1093 session->name, session->mtu);
1099 err = 0; 1094 err = 0;
1100 break; 1095 break;
1101 1096
@@ -1108,8 +1103,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1108 if (put_user(session->mru, (int __user *) arg)) 1103 if (put_user(session->mru, (int __user *) arg))
1109 break; 1104 break;
1110 1105
1111 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1106 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get mru=%d\n",
1112 "%s: get mru=%d\n", session->name, session->mru); 1107 session->name, session->mru);
1113 err = 0; 1108 err = 0;
1114 break; 1109 break;
1115 1110
@@ -1123,8 +1118,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1123 break; 1118 break;
1124 1119
1125 session->mru = val; 1120 session->mru = val;
1126 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1121 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set mru=%d\n",
1127 "%s: set mru=%d\n", session->name, session->mru); 1122 session->name, session->mru);
1128 err = 0; 1123 err = 0;
1129 break; 1124 break;
1130 1125
@@ -1133,8 +1128,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1133 if (put_user(ps->flags, (int __user *) arg)) 1128 if (put_user(ps->flags, (int __user *) arg))
1134 break; 1129 break;
1135 1130
1136 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1131 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get flags=%d\n",
1137 "%s: get flags=%d\n", session->name, ps->flags); 1132 session->name, ps->flags);
1138 err = 0; 1133 err = 0;
1139 break; 1134 break;
1140 1135
@@ -1143,8 +1138,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1143 if (get_user(val, (int __user *) arg)) 1138 if (get_user(val, (int __user *) arg))
1144 break; 1139 break;
1145 ps->flags = val; 1140 ps->flags = val;
1146 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1141 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set flags=%d\n",
1147 "%s: set flags=%d\n", session->name, ps->flags); 1142 session->name, ps->flags);
1148 err = 0; 1143 err = 0;
1149 break; 1144 break;
1150 1145
@@ -1160,8 +1155,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1160 if (copy_to_user((void __user *) arg, &stats, 1155 if (copy_to_user((void __user *) arg, &stats,
1161 sizeof(stats))) 1156 sizeof(stats)))
1162 break; 1157 break;
1163 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1158 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get L2TP stats\n",
1164 "%s: get L2TP stats\n", session->name); 1159 session->name);
1165 err = 0; 1160 err = 0;
1166 break; 1161 break;
1167 1162
@@ -1188,9 +1183,9 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
1188 struct sock *sk; 1183 struct sock *sk;
1189 struct pppol2tp_ioc_stats stats; 1184 struct pppol2tp_ioc_stats stats;
1190 1185
1191 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG, 1186 l2tp_dbg(tunnel, PPPOL2TP_MSG_CONTROL,
1192 "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n", 1187 "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n",
1193 tunnel->name, cmd, arg); 1188 tunnel->name, cmd, arg);
1194 1189
1195 sk = tunnel->sock; 1190 sk = tunnel->sock;
1196 sock_hold(sk); 1191 sock_hold(sk);
@@ -1224,8 +1219,8 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
1224 err = -EFAULT; 1219 err = -EFAULT;
1225 break; 1220 break;
1226 } 1221 }
1227 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1222 l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: get L2TP stats\n",
1228 "%s: get L2TP stats\n", tunnel->name); 1223 tunnel->name);
1229 err = 0; 1224 err = 0;
1230 break; 1225 break;
1231 1226
@@ -1314,8 +1309,8 @@ static int pppol2tp_tunnel_setsockopt(struct sock *sk,
1314 switch (optname) { 1309 switch (optname) {
1315 case PPPOL2TP_SO_DEBUG: 1310 case PPPOL2TP_SO_DEBUG:
1316 tunnel->debug = val; 1311 tunnel->debug = val;
1317 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1312 l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: set debug=%x\n",
1318 "%s: set debug=%x\n", tunnel->name, tunnel->debug); 1313 tunnel->name, tunnel->debug);
1319 break; 1314 break;
1320 1315
1321 default: 1316 default:
@@ -1342,8 +1337,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
1342 break; 1337 break;
1343 } 1338 }
1344 session->recv_seq = val ? -1 : 0; 1339 session->recv_seq = val ? -1 : 0;
1345 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1340 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1346 "%s: set recv_seq=%d\n", session->name, session->recv_seq); 1341 "%s: set recv_seq=%d\n",
1342 session->name, session->recv_seq);
1347 break; 1343 break;
1348 1344
1349 case PPPOL2TP_SO_SENDSEQ: 1345 case PPPOL2TP_SO_SENDSEQ:
@@ -1358,8 +1354,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
1358 po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ : 1354 po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ :
1359 PPPOL2TP_L2TP_HDR_SIZE_NOSEQ; 1355 PPPOL2TP_L2TP_HDR_SIZE_NOSEQ;
1360 } 1356 }
1361 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1357 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1362 "%s: set send_seq=%d\n", session->name, session->send_seq); 1358 "%s: set send_seq=%d\n",
1359 session->name, session->send_seq);
1363 break; 1360 break;
1364 1361
1365 case PPPOL2TP_SO_LNSMODE: 1362 case PPPOL2TP_SO_LNSMODE:
@@ -1368,20 +1365,22 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
1368 break; 1365 break;
1369 } 1366 }
1370 session->lns_mode = val ? -1 : 0; 1367 session->lns_mode = val ? -1 : 0;
1371 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1368 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1372 "%s: set lns_mode=%d\n", session->name, session->lns_mode); 1369 "%s: set lns_mode=%d\n",
1370 session->name, session->lns_mode);
1373 break; 1371 break;
1374 1372
1375 case PPPOL2TP_SO_DEBUG: 1373 case PPPOL2TP_SO_DEBUG:
1376 session->debug = val; 1374 session->debug = val;
1377 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1375 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set debug=%x\n",
1378 "%s: set debug=%x\n", session->name, session->debug); 1376 session->name, session->debug);
1379 break; 1377 break;
1380 1378
1381 case PPPOL2TP_SO_REORDERTO: 1379 case PPPOL2TP_SO_REORDERTO:
1382 session->reorder_timeout = msecs_to_jiffies(val); 1380 session->reorder_timeout = msecs_to_jiffies(val);
1383 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1381 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1384 "%s: set reorder_timeout=%d\n", session->name, session->reorder_timeout); 1382 "%s: set reorder_timeout=%d\n",
1383 session->name, session->reorder_timeout);
1385 break; 1384 break;
1386 1385
1387 default: 1386 default:
@@ -1460,8 +1459,8 @@ static int pppol2tp_tunnel_getsockopt(struct sock *sk,
1460 switch (optname) { 1459 switch (optname) {
1461 case PPPOL2TP_SO_DEBUG: 1460 case PPPOL2TP_SO_DEBUG:
1462 *val = tunnel->debug; 1461 *val = tunnel->debug;
1463 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1462 l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: get debug=%x\n",
1464 "%s: get debug=%x\n", tunnel->name, tunnel->debug); 1463 tunnel->name, tunnel->debug);
1465 break; 1464 break;
1466 1465
1467 default: 1466 default:
@@ -1483,32 +1482,32 @@ static int pppol2tp_session_getsockopt(struct sock *sk,
1483 switch (optname) { 1482 switch (optname) {
1484 case PPPOL2TP_SO_RECVSEQ: 1483 case PPPOL2TP_SO_RECVSEQ:
1485 *val = session->recv_seq; 1484 *val = session->recv_seq;
1486 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1485 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1487 "%s: get recv_seq=%d\n", session->name, *val); 1486 "%s: get recv_seq=%d\n", session->name, *val);
1488 break; 1487 break;
1489 1488
1490 case PPPOL2TP_SO_SENDSEQ: 1489 case PPPOL2TP_SO_SENDSEQ:
1491 *val = session->send_seq; 1490 *val = session->send_seq;
1492 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1491 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1493 "%s: get send_seq=%d\n", session->name, *val); 1492 "%s: get send_seq=%d\n", session->name, *val);
1494 break; 1493 break;
1495 1494
1496 case PPPOL2TP_SO_LNSMODE: 1495 case PPPOL2TP_SO_LNSMODE:
1497 *val = session->lns_mode; 1496 *val = session->lns_mode;
1498 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1497 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1499 "%s: get lns_mode=%d\n", session->name, *val); 1498 "%s: get lns_mode=%d\n", session->name, *val);
1500 break; 1499 break;
1501 1500
1502 case PPPOL2TP_SO_DEBUG: 1501 case PPPOL2TP_SO_DEBUG:
1503 *val = session->debug; 1502 *val = session->debug;
1504 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1503 l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get debug=%d\n",
1505 "%s: get debug=%d\n", session->name, *val); 1504 session->name, *val);
1506 break; 1505 break;
1507 1506
1508 case PPPOL2TP_SO_REORDERTO: 1507 case PPPOL2TP_SO_REORDERTO:
1509 *val = (int) jiffies_to_msecs(session->reorder_timeout); 1508 *val = (int) jiffies_to_msecs(session->reorder_timeout);
1510 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO, 1509 l2tp_info(session, PPPOL2TP_MSG_CONTROL,
1511 "%s: get reorder_timeout=%d\n", session->name, *val); 1510 "%s: get reorder_timeout=%d\n", session->name, *val);
1512 break; 1511 break;
1513 1512
1514 default: 1513 default:
@@ -1871,8 +1870,7 @@ static int __init pppol2tp_init(void)
1871 goto out_unregister_pppox; 1870 goto out_unregister_pppox;
1872#endif 1871#endif
1873 1872
1874 printk(KERN_INFO "PPPoL2TP kernel driver, %s\n", 1873 pr_info("PPPoL2TP kernel driver, %s\n", PPPOL2TP_DRV_VERSION);
1875 PPPOL2TP_DRV_VERSION);
1876 1874
1877out: 1875out:
1878 return err; 1876 return err;