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>
Showing
- include/linux/filter.h 1 addition, 1 deletioninclude/linux/filter.h
- include/net/tcp.h 5 additions, 0 deletionsinclude/net/tcp.h
- kernel/bpf/sockmap.c 9 additions, 10 deletionskernel/bpf/sockmap.c
- net/core/filter.c 15 additions, 14 deletionsnet/core/filter.c
- samples/sockmap/sockmap_kern.c 1 addition, 1 deletionsamples/sockmap/sockmap_kern.c
- tools/include/uapi/linux/bpf.h 2 additions, 1 deletiontools/include/uapi/linux/bpf.h
- tools/testing/selftests/bpf/bpf_helpers.h 1 addition, 1 deletiontools/testing/selftests/bpf/bpf_helpers.h
- tools/testing/selftests/bpf/sockmap_verdict_prog.c 2 additions, 2 deletionstools/testing/selftests/bpf/sockmap_verdict_prog.c
Loading
Please register or sign in to comment