Skip to content

Commit 1292336

Browse files
tomparkindavem330
authored andcommitted
l2tp: don't log data frames
l2tp had logging to trace data frame receipt and transmission, including code to dump packet contents. This was originally intended to aid debugging of core l2tp packet handling, but is of limited use now that code is stable. Signed-off-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1aecbf1 commit 1292336

5 files changed

Lines changed: 6 additions & 101 deletions

File tree

‎net/l2tp/l2tp_core.c‎

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
660660
int length)
661661
{
662662
struct l2tp_tunnel *tunnel = session->tunnel;
663-
u32 ns = 0, nr = 0;
664663
int offset;
665664

666665
/* Parse and check optional cookie */
@@ -686,32 +685,21 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
686685
L2TP_SKB_CB(skb)->has_seq = 0;
687686
if (tunnel->version == L2TP_HDR_VER_2) {
688687
if (hdrflags & L2TP_HDRFLAG_S) {
689-
ns = ntohs(*(__be16 *)ptr);
690-
ptr += 2;
691-
nr = ntohs(*(__be16 *)ptr);
692-
ptr += 2;
693-
694688
/* Store L2TP info in the skb */
695-
L2TP_SKB_CB(skb)->ns = ns;
689+
L2TP_SKB_CB(skb)->ns = ntohs(*(__be16 *)ptr);
696690
L2TP_SKB_CB(skb)->has_seq = 1;
691+
ptr += 2;
692+
/* Skip past nr in the header */
693+
ptr += 2;
697694

698-
l2tp_dbg(session, L2TP_MSG_SEQ,
699-
"%s: recv data ns=%u, nr=%u, session nr=%u\n",
700-
session->name, ns, nr, session->nr);
701695
}
702696
} else if (session->l2specific_type == L2TP_L2SPECTYPE_DEFAULT) {
703697
u32 l2h = ntohl(*(__be32 *)ptr);
704698

705699
if (l2h & 0x40000000) {
706-
ns = l2h & 0x00ffffff;
707-
708700
/* Store L2TP info in the skb */
709-
L2TP_SKB_CB(skb)->ns = ns;
701+
L2TP_SKB_CB(skb)->ns = l2h & 0x00ffffff;
710702
L2TP_SKB_CB(skb)->has_seq = 1;
711-
712-
l2tp_dbg(session, L2TP_MSG_SEQ,
713-
"%s: recv data ns=%u, session nr=%u\n",
714-
session->name, ns, session->nr);
715703
}
716704
ptr += 4;
717705
}
@@ -853,16 +841,6 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
853841
goto error;
854842
}
855843

856-
/* Trace packet contents, if enabled */
857-
if (tunnel->debug & L2TP_MSG_DATA) {
858-
length = min(32u, skb->len);
859-
if (!pskb_may_pull(skb, length))
860-
goto error;
861-
862-
pr_debug("%s: recv\n", tunnel->name);
863-
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, skb->data, length);
864-
}
865-
866844
/* Point to L2TP header */
867845
optr = skb->data;
868846
ptr = skb->data;
@@ -883,12 +861,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
883861
length = skb->len;
884862

885863
/* If type is control packet, it is handled by userspace. */
886-
if (hdrflags & L2TP_HDRFLAG_T) {
887-
l2tp_dbg(tunnel, L2TP_MSG_DATA,
888-
"%s: recv control packet, len=%d\n",
889-
tunnel->name, length);
864+
if (hdrflags & L2TP_HDRFLAG_T)
890865
goto error;
891-
}
892866

893867
/* Skip flags */
894868
ptr += 2;
@@ -953,9 +927,6 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
953927
if (!tunnel)
954928
goto pass_up;
955929

956-
l2tp_dbg(tunnel, L2TP_MSG_DATA, "%s: received %d bytes\n",
957-
tunnel->name, skb->len);
958-
959930
if (l2tp_udp_recv_core(tunnel, skb))
960931
goto pass_up;
961932

@@ -1049,23 +1020,6 @@ static void l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
10491020
unsigned int len = skb->len;
10501021
int error;
10511022

1052-
/* Debug */
1053-
if (session->send_seq)
1054-
l2tp_dbg(session, L2TP_MSG_DATA, "%s: send %zd bytes, ns=%u\n",
1055-
session->name, data_len, session->ns - 1);
1056-
else
1057-
l2tp_dbg(session, L2TP_MSG_DATA, "%s: send %zd bytes\n",
1058-
session->name, data_len);
1059-
1060-
if (session->debug & L2TP_MSG_DATA) {
1061-
int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
1062-
unsigned char *datap = skb->data + uhlen;
1063-
1064-
pr_debug("%s: xmit\n", session->name);
1065-
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
1066-
datap, min_t(size_t, 32, len - uhlen));
1067-
}
1068-
10691023
/* Queue the packet to IP for output */
10701024
skb->ignore_df = 1;
10711025
skb_dst_drop(skb);

‎net/l2tp/l2tp_eth.c‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,6 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
128128
struct net_device *dev;
129129
struct l2tp_eth *priv;
130130

131-
if (session->debug & L2TP_MSG_DATA) {
132-
unsigned int length;
133-
134-
length = min(32u, skb->len);
135-
if (!pskb_may_pull(skb, length))
136-
goto error;
137-
138-
pr_debug("%s: eth recv\n", session->name);
139-
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, skb->data, length);
140-
}
141-
142131
if (!pskb_may_pull(skb, ETH_HLEN))
143132
goto error;
144133

‎net/l2tp/l2tp_ip.c‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ static int l2tp_ip_recv(struct sk_buff *skb)
118118
struct l2tp_session *session;
119119
struct l2tp_tunnel *tunnel = NULL;
120120
struct iphdr *iph;
121-
int length;
122121

123122
if (!pskb_may_pull(skb, 4))
124123
goto discard;
@@ -147,20 +146,6 @@ static int l2tp_ip_recv(struct sk_buff *skb)
147146
if (!tunnel)
148147
goto discard_sess;
149148

150-
/* Trace packet contents, if enabled */
151-
if (tunnel->debug & L2TP_MSG_DATA) {
152-
length = min(32u, skb->len);
153-
if (!pskb_may_pull(skb, length))
154-
goto discard_sess;
155-
156-
/* Point to L2TP header */
157-
optr = skb->data;
158-
ptr = skb->data;
159-
ptr += 4;
160-
pr_debug("%s: ip recv\n", tunnel->name);
161-
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
162-
}
163-
164149
if (l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr))
165150
goto discard_sess;
166151

‎net/l2tp/l2tp_ip6.c‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
131131
struct l2tp_session *session;
132132
struct l2tp_tunnel *tunnel = NULL;
133133
struct ipv6hdr *iph;
134-
int length;
135134

136135
if (!pskb_may_pull(skb, 4))
137136
goto discard;
@@ -160,20 +159,6 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
160159
if (!tunnel)
161160
goto discard_sess;
162161

163-
/* Trace packet contents, if enabled */
164-
if (tunnel->debug & L2TP_MSG_DATA) {
165-
length = min(32u, skb->len);
166-
if (!pskb_may_pull(skb, length))
167-
goto discard_sess;
168-
169-
/* Point to L2TP header */
170-
optr = skb->data;
171-
ptr = skb->data;
172-
ptr += 4;
173-
pr_debug("%s: ip recv\n", tunnel->name);
174-
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
175-
}
176-
177162
if (l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr))
178163
goto discard_sess;
179164

‎net/l2tp/l2tp_ppp.c‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,9 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
237237
if (sk->sk_state & PPPOX_BOUND) {
238238
struct pppox_sock *po;
239239

240-
l2tp_dbg(session, L2TP_MSG_DATA,
241-
"%s: recv %d byte data frame, passing to ppp\n",
242-
session->name, data_len);
243-
244240
po = pppox_sk(sk);
245241
ppp_input(&po->chan, skb);
246242
} else {
247-
l2tp_dbg(session, L2TP_MSG_DATA,
248-
"%s: recv %d byte data frame, passing to L2TP socket\n",
249-
session->name, data_len);
250-
251243
if (sock_queue_rcv_skb(sk, skb) < 0) {
252244
atomic_long_inc(&session->stats.rx_errors);
253245
kfree_skb(skb);

0 commit comments

Comments
 (0)