mbox series

[bpf-next,0/3] add TCP_BPF_SOCK_OPS_CB_FLAGS to bpf_*sockopt()

Message ID 20240802152929.2695863-1-alan.maguire@oracle.com (mailing list archive)
Headers show
Series add TCP_BPF_SOCK_OPS_CB_FLAGS to bpf_*sockopt() | expand

Message

Alan Maguire Aug. 2, 2024, 3:29 p.m. UTC
As previously discussed here [1], long-lived sockets can miss
a chance to set additional callbacks if a sock ops program
was not attached early in their lifetime.  Adding support
to bpf_setsockopt() to set callback flags (and bpf_getsockopt()
to retrieve them) provides other opportunities to enable callbacks,
either directly via a cgroup/setsockopt intercepted setsockopt()
or via a socket iterator.

Patch 1 adds bpf_[get|set]sockopt() support; patch 2 adds testing
for it via sockops and cgroup/setsockopt programs and patch 3
extends the existing bpf_iter_setsockopt test to cover setting
sock ops flags via bpf_setsockopt() in iterator context.

[1] https://lore.kernel.org/bpf/f42f157b-6e52-dd4d-3d97-9b86c84c0b00@oracle.com/

Alan Maguire (3):
  bpf/bpf_get,set_sockopt: add option to set TCP-BPF sock ops flags
  selftests/bpf: add tests for TCP_BPF_SOCK_OPS_CB_FLAGS
  selftests/bpf: modify bpf_iter_setsockopt to test
    TCP_BPF_SOCK_OPS_CB_FLAGS

 include/uapi/linux/bpf.h                      |  3 +-
 net/core/filter.c                             | 16 ++++
 tools/include/uapi/linux/bpf.h                |  3 +-
 .../bpf/prog_tests/bpf_iter_setsockopt.c      | 83 +++++++++++++------
 .../selftests/bpf/prog_tests/setget_sockopt.c | 11 +++
 .../selftests/bpf/progs/bpf_iter_setsockopt.c | 76 ++++++++++++++---
 .../selftests/bpf/progs/setget_sockopt.c      | 37 ++++++++-
 7 files changed, 188 insertions(+), 41 deletions(-)