Skip to content

Commit fc0cc92

Browse files
Yan Zhaidavem330
authored andcommitted
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>
1 parent 46a02aa commit fc0cc92

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
@@ -2074,7 +2074,7 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
20742074
}
20752075
UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
20762076
trace_udp_fail_queue_rcv_skb(rc, sk, skb);
2077-
kfree_skb_reason(skb, drop_reason);
2077+
sk_skb_reason_drop(sk, skb, drop_reason);
20782078
return -1;
20792079
}
20802080

@@ -2196,7 +2196,7 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)
21962196
drop:
21972197
__UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
21982198
atomic_inc(&sk->sk_drops);
2199-
kfree_skb_reason(skb, drop_reason);
2199+
sk_skb_reason_drop(sk, skb, drop_reason);
22002200
return -1;
22012201
}
22022202

@@ -2383,7 +2383,7 @@ static int udp_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
23832383
int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
23842384
int proto)
23852385
{
2386-
struct sock *sk;
2386+
struct sock *sk = NULL;
23872387
struct udphdr *uh;
23882388
unsigned short ulen;
23892389
struct rtable *rt = skb_rtable(skb);
@@ -2460,7 +2460,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
24602460
* Hmm. We got an UDP packet to a port to which we
24612461
* don't wanna listen. Ignore it.
24622462
*/
2463-
kfree_skb_reason(skb, drop_reason);
2463+
sk_skb_reason_drop(sk, skb, drop_reason);
24642464
return 0;
24652465

24662466
short_packet:
@@ -2485,7 +2485,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
24852485
__UDP_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE);
24862486
drop:
24872487
__UDP_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE);
2488-
kfree_skb_reason(skb, drop_reason);
2488+
sk_skb_reason_drop(sk, skb, drop_reason);
24892489
return 0;
24902490
}
24912491

net/ipv6/udp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ static int __udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
673673
}
674674
UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
675675
trace_udp_fail_queue_rcv_skb(rc, sk, skb);
676-
kfree_skb_reason(skb, drop_reason);
676+
sk_skb_reason_drop(sk, skb, drop_reason);
677677
return -1;
678678
}
679679

@@ -776,7 +776,7 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)
776776
drop:
777777
__UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
778778
atomic_inc(&sk->sk_drops);
779-
kfree_skb_reason(skb, drop_reason);
779+
sk_skb_reason_drop(sk, skb, drop_reason);
780780
return -1;
781781
}
782782

@@ -940,8 +940,8 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
940940
enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
941941
const struct in6_addr *saddr, *daddr;
942942
struct net *net = dev_net(skb->dev);
943+
struct sock *sk = NULL;
943944
struct udphdr *uh;
944-
struct sock *sk;
945945
bool refcounted;
946946
u32 ulen = 0;
947947

@@ -1033,7 +1033,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
10331033
__UDP6_INC_STATS(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
10341034
icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
10351035

1036-
kfree_skb_reason(skb, reason);
1036+
sk_skb_reason_drop(sk, skb, reason);
10371037
return 0;
10381038

10391039
short_packet:
@@ -1054,7 +1054,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
10541054
__UDP6_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE);
10551055
discard:
10561056
__UDP6_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE);
1057-
kfree_skb_reason(skb, reason);
1057+
sk_skb_reason_drop(sk, skb, reason);
10581058
return 0;
10591059
}
10601060

0 commit comments

Comments
 (0)