]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: avoid preempt enable/disable in sockmap using tcp_skb_cb region
authorJohn Fastabend <john.fastabend@gmail.com>
Wed, 18 Oct 2017 14:10:36 +0000 (07:10 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Oct 2017 12:01:29 +0000 (13:01 +0100)
commita696335d16198e128b16dcc1285940a8a2e72861
tree27084757c315fdf13c682c3d6c57922ed5f8447c
parent47e4e6013be2c6b6a4fdccef40dab14e11b74972
bpf: avoid preempt enable/disable in sockmap using tcp_skb_cb region

SK_SKB BPF programs are run from the socket/tcp context but early in
the stack before much of the TCP metadata is needed in tcp_skb_cb. So
we can use some unused fields to place BPF metadata needed for SK_SKB
programs when implementing the redirect function.

This allows us to drop the preempt disable logic. It does however
require an API change so sk_redirect_map() has been updated to
additionally provide ctx_ptr to skb. Note, we do however continue to
disable/enable preemption around actual BPF program running to account
for map updates.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/filter.h
include/net/tcp.h
kernel/bpf/sockmap.c
net/core/filter.c
samples/sockmap/sockmap_kern.c
tools/include/uapi/linux/bpf.h
tools/testing/selftests/bpf/bpf_helpers.h
tools/testing/selftests/bpf/sockmap_verdict_prog.c