This series include 4 setup patches (1-4) to allow ULP layer and sockmap refcounting to support another ULP type. There is one small change (5 lines!) on the TCP side in patch 4. This adds a flag so that the ULP layer can inform the TCP stack not to mark the frags as shared. When the ULP layer "owns" the frags and 'gives' them to the TCP stack we know there can be no additional updates from user side to the data.
Patch 4 is the bulk of the work. This adds a new program type BPF_PROG_TYPE_SK_MSG, a sockmap program attach type BPF_SK_MSG_VERDICT and a new ULP layer (TCP_ULP_BPF) to allow BPF prgrams to be run on sendmsg/sendfile system calls and inspect data. For now only TCP is supported when sockmap is extended other protos can be added. See the patch description for a lengthy description of the details. After this patch users can now attach BPF policy and monitoring programs to socket send hooks. Finally patches 6/7 and 7/7 add tests to test_maps and the verifier in selftests/bpf so we get some automated coverage. One open question I have is if we should move the samples/sockmap program into selftests/bpf and start running it to get even more coverage on the automated side. We can push this as an independent patch set. --- John Fastabend (7): net: add a UID to use for ULP socket assignment sock: make static tls function alloc_sg generic sock helper sockmap: convert refcnt to an atomic refcnt net: do_tcp_sendpages flag to avoid SKBTX_SHARED_FRAG bpf: create tcp_bpf_ulp allowing BPF to monitor socket TX/RX data bpf: add map tests for BPF_PROG_TYPE_SK_MSG bpf: add verifier tests for BPF_PROG_TYPE_SK_MSG include/linux/bpf.h | 1 include/linux/bpf_types.h | 1 include/linux/filter.h | 10 include/linux/socket.h | 1 include/net/sock.h | 4 include/net/tcp.h | 7 include/uapi/linux/bpf.h | 28 + kernel/bpf/sockmap.c | 504 +++++++++++++++++++- kernel/bpf/syscall.c | 14 - kernel/bpf/verifier.c | 5 net/core/filter.c | 106 ++++ net/core/sock.c | 56 ++ net/ipv4/tcp.c | 4 net/ipv4/tcp_ulp.c | 51 ++ net/tls/tls_main.c | 1 net/tls/tls_sw.c | 69 --- tools/include/uapi/linux/bpf.h | 16 + tools/testing/selftests/bpf/Makefile | 3 tools/testing/selftests/bpf/bpf_helpers.h | 2 tools/testing/selftests/bpf/sockmap_parse_prog.c | 15 + tools/testing/selftests/bpf/sockmap_verdict_prog.c | 7 tools/testing/selftests/bpf/test_maps.c | 54 ++ tools/testing/selftests/bpf/test_verifier.c | 54 ++ 23 files changed, 913 insertions(+), 100 deletions(-) -- Signature