Skip to content

Commit b3aaf3c

Browse files
edumazetkuba-moo
authored andcommitted
udp: expand SKB_DROP_REASON_UDP_CSUM use
SKB_DROP_REASON_UDP_CSUM can be used in four locations when dropping a packet because of a wrong UDP checksum. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/20250307102002.2095238-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 248f657 commit b3aaf3c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

net/ipv4/udp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ static struct sk_buff *__first_packet_length(struct sock *sk,
18481848
atomic_inc(&sk->sk_drops);
18491849
__skb_unlink(skb, rcvq);
18501850
*total += skb->truesize;
1851-
kfree_skb(skb);
1851+
kfree_skb_reason(skb, SKB_DROP_REASON_UDP_CSUM);
18521852
} else {
18531853
udp_skb_csum_unnecessary_set(skb);
18541854
break;
@@ -2002,7 +2002,7 @@ int udp_read_skb(struct sock *sk, skb_read_actor_t recv_actor)
20022002
__UDP_INC_STATS(net, UDP_MIB_CSUMERRORS, is_udplite);
20032003
__UDP_INC_STATS(net, UDP_MIB_INERRORS, is_udplite);
20042004
atomic_inc(&sk->sk_drops);
2005-
kfree_skb(skb);
2005+
kfree_skb_reason(skb, SKB_DROP_REASON_UDP_CSUM);
20062006
goto try_again;
20072007
}
20082008

@@ -2117,7 +2117,7 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags,
21172117
UDP_INC_STATS(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
21182118
UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
21192119
}
2120-
kfree_skb(skb);
2120+
kfree_skb_reason(skb, SKB_DROP_REASON_UDP_CSUM);
21212121

21222122
/* starting over for a new packet, but check if we need to yield */
21232123
cond_resched();

net/ipv6/udp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
586586
SNMP_INC_STATS(mib, UDP_MIB_CSUMERRORS);
587587
SNMP_INC_STATS(mib, UDP_MIB_INERRORS);
588588
}
589-
kfree_skb(skb);
589+
kfree_skb_reason(skb, SKB_DROP_REASON_UDP_CSUM);
590590

591591
/* starting over for a new packet, but check if we need to yield */
592592
cond_resched();

0 commit comments

Comments
 (0)