Skip to content

Commit 71b59bf

Browse files
qsnklassert
authored andcommitted
espintcp: count packets dropped in espintcp_rcv
Currently, espintcp_rcv drops packets silently, which makes debugging issues difficult. Count packets as either XfrmInHdrError (when the packet was too short or contained invalid data) or XfrmInError (for other issues). Signed-off-by: Sabrina Dubroca <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent fadd1a6 commit 71b59bf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/xfrm/espintcp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ static void handle_nonesp(struct espintcp_ctx *ctx, struct sk_buff *skb,
1515
{
1616
if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf ||
1717
!sk_rmem_schedule(sk, skb, skb->truesize)) {
18+
XFRM_INC_STATS(sock_net(sk), LINUX_MIB_XFRMINERROR);
1819
kfree_skb(skb);
1920
return;
2021
}
@@ -59,6 +60,7 @@ static void espintcp_rcv(struct strparser *strp, struct sk_buff *skb)
5960

6061
err = skb_copy_bits(skb, rxm->offset + 2, &data, 1);
6162
if (err < 0) {
63+
XFRM_INC_STATS(sock_net(strp->sk), LINUX_MIB_XFRMINHDRERROR);
6264
kfree_skb(skb);
6365
return;
6466
}
@@ -71,24 +73,28 @@ static void espintcp_rcv(struct strparser *strp, struct sk_buff *skb)
7173

7274
/* drop other short messages */
7375
if (unlikely(len <= sizeof(nonesp_marker))) {
76+
XFRM_INC_STATS(sock_net(strp->sk), LINUX_MIB_XFRMINHDRERROR);
7477
kfree_skb(skb);
7578
return;
7679
}
7780

7881
err = skb_copy_bits(skb, rxm->offset + 2, &nonesp_marker,
7982
sizeof(nonesp_marker));
8083
if (err < 0) {
84+
XFRM_INC_STATS(sock_net(strp->sk), LINUX_MIB_XFRMINHDRERROR);
8185
kfree_skb(skb);
8286
return;
8387
}
8488

8589
/* remove header, leave non-ESP marker/SPI */
8690
if (!__pskb_pull(skb, rxm->offset + 2)) {
91+
XFRM_INC_STATS(sock_net(strp->sk), LINUX_MIB_XFRMINERROR);
8792
kfree_skb(skb);
8893
return;
8994
}
9095

9196
if (pskb_trim(skb, rxm->full_len - 2) != 0) {
97+
XFRM_INC_STATS(sock_net(strp->sk), LINUX_MIB_XFRMINERROR);
9298
kfree_skb(skb);
9399
return;
94100
}

0 commit comments

Comments
 (0)