mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-06 03:45:24 -04:00
UPSTREAM: bpf: sockmap: Simplify sock_map_init_proto
We can take advantage of the fact that both callers of sock_map_init_proto are holding a RCU read lock, and have verified that psock is valid. Change-Id: I012bf4f9541fdaad94b1f84e97c7dbf4abaf149f Signed-off-by: Lorenz Bauer <lmb@cloudflare.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20200309111243.6982-7-lmb@cloudflare.com Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
This commit is contained in:
parent
fcc0ffa7a3
commit
883d76baeb
1 changed files with 4 additions and 15 deletions
|
|
@ -180,28 +180,17 @@ static void sock_map_unref(struct sock *sk, void *link_raw)
|
|||
}
|
||||
}
|
||||
|
||||
static int sock_map_init_proto(struct sock *sk)
|
||||
static int sock_map_init_proto(struct sock *sk, struct sk_psock *psock)
|
||||
{
|
||||
struct sk_psock *psock;
|
||||
struct proto *prot;
|
||||
|
||||
sock_owned_by_me(sk);
|
||||
|
||||
rcu_read_lock();
|
||||
psock = sk_psock(sk);
|
||||
if (unlikely(!psock)) {
|
||||
rcu_read_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
prot = tcp_bpf_get_proto(sk, psock);
|
||||
if (IS_ERR(prot)) {
|
||||
rcu_read_unlock();
|
||||
if (IS_ERR(prot))
|
||||
return PTR_ERR(prot);
|
||||
}
|
||||
|
||||
sk_psock_update_proto(sk, psock, prot);
|
||||
rcu_read_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +269,7 @@ static int sock_map_link(struct bpf_map *map, struct sk_psock_progs *progs,
|
|||
if (msg_parser)
|
||||
psock_set_prog(&psock->progs.msg_parser, msg_parser);
|
||||
|
||||
ret = sock_map_init_proto(sk);
|
||||
ret = sock_map_init_proto(sk, psock);
|
||||
if (ret < 0)
|
||||
goto out_drop;
|
||||
|
||||
|
|
@ -328,7 +317,7 @@ static int sock_map_link_no_progs(struct bpf_map *map, struct sock *sk)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = sock_map_init_proto(sk);
|
||||
ret = sock_map_init_proto(sk, psock);
|
||||
if (ret < 0)
|
||||
sk_psock_put(sk, psock);
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in a new issue