kernel_optimize_test/include
Martin KaFai Lau dbafd7ddd6 bpf: Add bpf_get_listener_sock(struct bpf_sock *sk) helper
Add a new helper "struct bpf_sock *bpf_get_listener_sock(struct bpf_sock *sk)"
which returns a bpf_sock in TCP_LISTEN state.  It will trace back to
the listener sk from a request_sock if possible.  It returns NULL
for all other cases.

No reference is taken because the helper ensures the sk is
in SOCK_RCU_FREE (where the TCP_LISTEN sock should be in).
Hence, bpf_sk_release() is unnecessary and the verifier does not
allow bpf_sk_release(listen_sk) to be called either.

The following is also allowed because the bpf_prog is run under
rcu_read_lock():

	sk = bpf_sk_lookup_tcp();
	/* if (!sk) { ... } */
	listen_sk = bpf_get_listener_sock(sk);
	/* if (!listen_sk) { ... } */
	bpf_sk_release(sk);
	src_port = listen_sk->src_port; /* Allowed */

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2019-03-13 12:04:35 -07:00
..
acpi
asm-generic get rid of legacy 'get_ds()' function 2019-03-04 10:50:14 -08:00
clocksource
crypto
drm
dt-bindings Here's the main MIPS pull request for v5.1: 2019-03-05 11:28:25 -08:00
keys
kvm
linux bpf: Fix bpf_tcp_sock and bpf_sk_fullsock issue related to bpf_sk_release 2019-03-13 12:04:35 -07:00
math-emu
media
memory
misc
net net: keep refcount warning in reqsk_free() 2019-03-09 19:51:44 -08:00
pcmcia
ras
rdma
scsi
soc
sound
target
trace rxrpc: Fix client call connect/disconnect race 2019-03-08 11:26:16 -08:00
uapi bpf: Add bpf_get_listener_sock(struct bpf_sock *sk) helper 2019-03-13 12:04:35 -07:00
video
xen