diff options
| author | Alexei Starovoitov <ast@kernel.org> | 2026-09-19 05:32:56 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-09-19 05:33:05 +0000 |
| commit | 011a2968cf491043ca0f5e1cbf7ee6298c4a1b28 (patch) | |
| tree | bbc1ee2dcf8c1310d05111d7a6a4045e01dd2ed0 /include/linux/debugobjects.h | |
| parent | 72a930db88c446bfd24dc06d9edecb66b266d734 (diff) | |
| parent | d7399d91417bc96b20862bea664dfd00821d9445 (diff) | |
Merge branch 'bpf-a-common-way-to-attach-struct_ops-to-a-cgroup'
Amery Hung says:
====================
bpf: A common way to attach struct_ops to a cgroup
I am continuing Martin's work to support attaching struct_ops to cgroup.
At LSF/MM/BPF 2025, Martin presented [1] the need for a new interface
to extend tcp_sock operations instead of adding more BPF_SOCK_OPS_*CB
enum values. The need for predictable ordering when attaching struct_ops
to a cgroup was also briefly discussed.
At LSF/MM/BPF 2026, additional use cases were raised, in particular
OOM and memcg use cases that also need to attach struct_ops to a
cgroup.
BPF already has a common bpf_link-based API for attaching different
BPF program types to a cgroup. It provides common attach, detach,
update, ordering, and query semantics across those program types.
This series extends the same model to struct_ops. Conceptually,
struct_ops is a group of BPF programs, so using similar
attachment/detachment/update/query APIs and ordering semantics for
cgroup attachment keeps the interface consistent with existing cgroup
BPF links.
This series uses a new struct bpf_tcp_ops as the first user. The
struct_ops mirrors the TCP-related sockops hooks except
BPF_SOCK_OPS_NEEDS_ECN and BPF_SOCK_OPS_BASE_RTT, which are
intentionally left out.
The selftests cover attach, query, update, ordering, before/after
placement, retval chaining, the header option hooks, and inheritance
across a multi-level cgroup hierarchy.
The map_free_pre_rcu addition in patch 2 is not very ideal; it will
need some thought too.
[1] page 13: https://drive.google.com/file/d/1wjKZth6T0llLJ_ONPAL_6Q_jbxbAjByp/view?usp=sharing
Changelog
v3 -> v4
- Rebase onto the latest bpf-next
- Add Reviewed-by tags from Emil
- Fix minor styling issues
- Patch 9: Consolidate per-attach-type struct_ops metadata, document
the RCU lifetime, simplify map-link auto-detach, factor out the
struct_ops list-entry check, and validate that detached links exist
- Patch 12: Keep the legacy WRITE_HDR_OPT callback gated by its
opt-in flag, initialize bpf_opt_len for tcp_current_mss(), use
ARG_MEM_SIZE for header-option buffers, and clean up comments
v2 -> v3
- Patch 3: Remove redundant bpf_struct_ops_kdata_map_id (Sashiko)
- Patch 11: Reject sleepable programs (Sashiko)
- Patch 12: Silence warning when casting ctx to arg pointer
- Patch 13: Fix incorrect libbpf API addition (Andrii)
- Patch 14: Fix selftest cgroup cleanup (Sashiko)
- Patch 15: Use network_helpers.c
RFC v1 -> v2
- Fix UAF of cfi_stubs
- Fix retval: use bpf_tramp_run_ctx instead of bpf_cg_run_ctx and
expose bpf_get_retval() to bpf_tcp_ops
- Add selftests
- struct_ops cgroup attachment
- Test bpf_get_retval()
- Test before/after order
- Test cgroup hierarchy and inheritance
- Test TCP header option hooks and helpers
- Move bpf_tcp_ops out of legacy BPF_SOCK_OPS_TEST_FLAG guard
- Complete bpf_tcp_ops (make it comparable to legacy sockops tcp)
---
====================
Link: https://patch.msgid.link/20260917200542.3689605-1-ameryhung@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux/debugobjects.h')
0 files changed, 0 insertions, 0 deletions
