mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
UPSTREAM: net: Track socket refcounts in skb_steal_sock()
Refactor the UDP/TCP handlers slightly to allow skb_steal_sock() to make the determination of whether the socket is reference counted in the case where it is prefetched by earlier logic such as early_demux. Change-Id: I19305f2f853f5f310811fb63580e76653c207ae0 Signed-off-by: Joe Stringer <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
This commit is contained in:
parent
9974c2cee8
commit
f59a02f5cb
5 changed files with 21 additions and 10 deletions
|
|
@ -861,6 +861,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
|
|||
struct net *net = dev_net(skb->dev);
|
||||
struct udphdr *uh;
|
||||
struct sock *sk;
|
||||
bool refcounted;
|
||||
u32 ulen = 0;
|
||||
|
||||
if (!pskb_may_pull(skb, sizeof(struct udphdr)))
|
||||
|
|
@ -897,7 +898,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
|
|||
goto csum_error;
|
||||
|
||||
/* Check if the socket is already available, e.g. due to early demux */
|
||||
sk = skb_steal_sock(skb);
|
||||
sk = skb_steal_sock(skb, &refcounted);
|
||||
if (sk) {
|
||||
struct dst_entry *dst = skb_dst(skb);
|
||||
int ret;
|
||||
|
|
@ -906,12 +907,14 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
|
|||
udp6_sk_rx_dst_set(sk, dst);
|
||||
|
||||
if (!uh->check && !udp_sk(sk)->no_check6_rx) {
|
||||
sock_put(sk);
|
||||
if (refcounted)
|
||||
sock_put(sk);
|
||||
goto report_csum_error;
|
||||
}
|
||||
|
||||
ret = udp6_unicast_rcv_skb(sk, skb, uh);
|
||||
sock_put(sk);
|
||||
if (refcounted)
|
||||
sock_put(sk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue