Skip to content

Commit 32669d8

Browse files
committed
udp: use sk_skb_reason_drop to free rx packets
JIRA: https://issues.redhat.com/browse/RHEL-48648 Upstream Status: net-next.git commit fc0cc92 Author: Yan Zhai <yan@cloudflare.com> Date: Mon Jun 17 11:09:24 2024 -0700 udp: use sk_skb_reason_drop to free rx packets Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving socket to the tracepoint. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/r/202406011751.NpVN0sSk-lkp@intel.com/ Signed-off-by: Yan Zhai <yan@cloudflare.com> Acked-by: Jesper Dangaard Brouer <hawk@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Antoine Tenart <atenart@redhat.com>
1 parent 3a0f9f0 commit 32669d8

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

net/ipv4/udp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
21132113
}
21142114
UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
21152115
trace_udp_fail_queue_rcv_skb(rc, sk, skb);
2116-
kfree_skb_reason(skb, drop_reason);
2116+
sk_skb_reason_drop(sk, skb, drop_reason);
21172117
return -1;
21182118
}
21192119

@@ -2233,7 +2233,7 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)
22332233
drop:
22342234
__UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
22352235
atomic_inc(&sk->sk_drops);
2236-
kfree_skb_reason(skb, drop_reason);
2236+
sk_skb_reason_drop(sk, skb, drop_reason);
22372237
return -1;
22382238
}
22392239

@@ -2420,7 +2420,7 @@ static int udp_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
24202420
int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
24212421
int proto)
24222422
{
2423-
struct sock *sk;
2423+
struct sock *sk = NULL;
24242424
struct udphdr *uh;
24252425
unsigned short ulen;
24262426
struct rtable *rt = skb_rtable(skb);
@@ -2493,7 +2493,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
24932493
* Hmm. We got an UDP packet to a port to which we
24942494
* don't wanna listen. Ignore it.
24952495
*/
2496-
kfree_skb_reason(skb, drop_reason);
2496+
sk_skb_reason_drop(sk, skb, drop_reason);
24972497
return 0;
24982498

24992499
short_packet:
@@ -2518,7 +2518,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
25182518
__UDP_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE);
25192519
drop:
25202520
__UDP_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE);
2521-
kfree_skb_reason(skb, drop_reason);
2521+
sk_skb_reason_drop(sk, skb, drop_reason);
25222522
return 0;
25232523
}
25242524

net/ipv6/udp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
686686
}
687687
UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
688688
trace_udp_fail_queue_rcv_skb(rc, sk, skb);
689-
kfree_skb_reason(skb, drop_reason);
689+
sk_skb_reason_drop(sk, skb, drop_reason);
690690
return -1;
691691
}
692692

@@ -785,7 +785,7 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)
785785
drop:
786786
__UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
787787
atomic_inc(&sk->sk_drops);
788-
kfree_skb_reason(skb, drop_reason);
788+
sk_skb_reason_drop(sk, skb, drop_reason);
789789
return -1;
790790
}
791791

@@ -952,8 +952,8 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
952952
enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
953953
const struct in6_addr *saddr, *daddr;
954954
struct net *net = dev_net(skb->dev);
955+
struct sock *sk = NULL;
955956
struct udphdr *uh;
956-
struct sock *sk;
957957
bool refcounted;
958958
u32 ulen = 0;
959959

@@ -1040,7 +1040,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
10401040
__UDP6_INC_STATS(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
10411041
icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
10421042

1043-
kfree_skb_reason(skb, reason);
1043+
sk_skb_reason_drop(sk, skb, reason);
10441044
return 0;
10451045

10461046
short_packet:
@@ -1061,7 +1061,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
10611061
__UDP6_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE);
10621062
discard:
10631063
__UDP6_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE);
1064-
kfree_skb_reason(skb, reason);
1064+
sk_skb_reason_drop(sk, skb, reason);
10651065
return 0;
10661066
}
10671067

0 commit comments

Comments
 (0)