bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 bpf-next 00/11] bpf: Enable bpf_skc_to_* sock casting helper to networking prog type
@ 2020-09-22  7:04 Martin KaFai Lau
  2020-09-22  7:04 ` [PATCH v3 bpf-next 01/11] bpf: Move the PTR_TO_BTF_ID check to check_reg_type() Martin KaFai Lau
                   ` (10 more replies)
  0 siblings, 11 replies; 27+ messages in thread
From: Martin KaFai Lau @ 2020-09-22  7:04 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, Lorenz Bauer, netdev

This set allows networking prog type to directly read fields from
the in-kernel socket type, e.g. "struct tcp_sock".

Patch 2 has the details on the use case.

v3:
- ARG_PTR_TO_SOCK_COMMON_OR_NULL was attempted in v2.  The _OR_NULL was
  needed because the PTR_TO_BTF_ID could be NULL but note that a could be NULL
  PTR_TO_BTF_ID is not a scalar NULL to the verifier.  "_OR_NULL" implicitly
  gives an expectation that the helper can take a scalar NULL which does
  not make sense in most (except one) helpers.  Passing scalar NULL
  should be rejected at the verification time.

  Thus, this patch uses ARG_PTR_TO_BTF_ID_SOCK_COMMON to specify that the
  helper can take both the btf-id ptr or the legacy PTR_TO_SOCK_COMMON but
  not scalar NULL.  It requires the func_proto to explicitly specify the
  arg_btf_id such that there is a very clear expectation that the helper
  can handle a NULL PTR_TO_BTF_ID.

v2:
- Add ARG_PTR_TO_SOCK_COMMON_OR_NULL (Lorenz)

Martin KaFai Lau (11):
  bpf: Move the PTR_TO_BTF_ID check to check_reg_type()
  bpf: Enable bpf_skc_to_* sock casting helper to networking prog type
  bpf: Change bpf_sk_release and bpf_sk_*cgroup_id to accept
    ARG_PTR_TO_BTF_ID_SOCK_COMMON
  bpf: Change bpf_sk_storage_*() to accept ARG_PTR_TO_BTF_ID_SOCK_COMMON
  bpf: Change bpf_tcp_*_syncookie to accept
    ARG_PTR_TO_BTF_ID_SOCK_COMMON
  bpf: Change bpf_sk_assign to accept ARG_PTR_TO_BTF_ID_SOCK_COMMON
  bpf: selftest: Add ref_tracking verifier test for bpf_skc casting
  bpf: selftest: Move sock_fields test into test_progs
  bpf: selftest: Adapt sock_fields test to use skel and global variables
  bpf: selftest: Use network_helpers in the sock_fields test
  bpf: selftest: Use bpf_skc_to_tcp_sock() in the sock_fields test

 include/linux/bpf.h                           |   1 +
 include/net/bpf_sk_storage.h                  |   2 -
 include/uapi/linux/bpf.h                      |   1 +
 kernel/bpf/bpf_lsm.c                          |   4 +-
 kernel/bpf/verifier.c                         |  93 ++--
 net/core/bpf_sk_storage.c                     |  31 +-
 net/core/filter.c                             | 112 ++--
 net/ipv4/bpf_tcp_ca.c                         |  23 +-
 tools/include/uapi/linux/bpf.h                |   1 +
 tools/testing/selftests/bpf/Makefile          |   2 +-
 .../selftests/bpf/prog_tests/sock_fields.c    | 361 +++++++++++++
 ..._sock_fields_kern.c => test_sock_fields.c} | 165 +++---
 .../testing/selftests/bpf/test_sock_fields.c  | 482 ------------------
 .../selftests/bpf/verifier/ref_tracking.c     |  47 ++
 14 files changed, 633 insertions(+), 692 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/sock_fields.c
 rename tools/testing/selftests/bpf/progs/{test_sock_fields_kern.c => test_sock_fields.c} (61%)
 delete mode 100644 tools/testing/selftests/bpf/test_sock_fields.c

-- 
2.24.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2020-09-25  1:23 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-22  7:04 [PATCH v3 bpf-next 00/11] bpf: Enable bpf_skc_to_* sock casting helper to networking prog type Martin KaFai Lau
2020-09-22  7:04 ` [PATCH v3 bpf-next 01/11] bpf: Move the PTR_TO_BTF_ID check to check_reg_type() Martin KaFai Lau
2020-09-22  9:56   ` Lorenz Bauer
2020-09-22 18:38     ` Martin KaFai Lau
2020-09-23  9:47       ` Lorenz Bauer
2020-09-23  4:45     ` Martin KaFai Lau
2020-09-22  7:04 ` [PATCH v3 bpf-next 02/11] bpf: Enable bpf_skc_to_* sock casting helper to networking prog type Martin KaFai Lau
2020-09-22  9:46   ` Lorenz Bauer
2020-09-22 18:26     ` Martin KaFai Lau
2020-09-23  9:27       ` Lorenz Bauer
2020-09-23 17:05         ` Martin KaFai Lau
2020-09-24  8:38           ` Lorenz Bauer
2020-09-25  1:22             ` Martin KaFai Lau
2020-09-22  7:04 ` [PATCH v3 bpf-next 03/11] bpf: Change bpf_sk_release and bpf_sk_*cgroup_id to accept ARG_PTR_TO_BTF_ID_SOCK_COMMON Martin KaFai Lau
2020-09-22  7:04 ` [PATCH v3 bpf-next 04/11] bpf: Change bpf_sk_storage_*() " Martin KaFai Lau
2020-09-22  9:17   ` Lorenz Bauer
2020-09-22  7:04 ` [PATCH v3 bpf-next 05/11] bpf: Change bpf_tcp_*_syncookie " Martin KaFai Lau
2020-09-22  9:18   ` Lorenz Bauer
2020-09-22  7:04 ` [PATCH v3 bpf-next 06/11] bpf: Change bpf_sk_assign " Martin KaFai Lau
2020-09-22  9:21   ` Lorenz Bauer
2020-09-22  7:04 ` [PATCH v3 bpf-next 07/11] bpf: selftest: Add ref_tracking verifier test for bpf_skc casting Martin KaFai Lau
2020-09-22  7:04 ` [PATCH v3 bpf-next 08/11] bpf: selftest: Move sock_fields test into test_progs Martin KaFai Lau
2020-09-23 21:22   ` Andrii Nakryiko
2020-09-22  7:05 ` [PATCH v3 bpf-next 09/11] bpf: selftest: Adapt sock_fields test to use skel and global variables Martin KaFai Lau
2020-09-22  7:05 ` [PATCH v3 bpf-next 10/11] bpf: selftest: Use network_helpers in the sock_fields test Martin KaFai Lau
2020-09-22  7:05 ` [PATCH v3 bpf-next 11/11] bpf: selftest: Use bpf_skc_to_tcp_sock() " Martin KaFai Lau
2020-09-22 20:16   ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).