linux-yocto/tools/include
Yonghong Song 555c0b713c bpf: Allow pre-ordering for bpf cgroup progs
[ Upstream commit 4b82b181a26cff8bf7adc3a85a88d121d92edeaf ]

Currently for bpf progs in a cgroup hierarchy, the effective prog array
is computed from bottom cgroup to upper cgroups (post-ordering). For
example, the following cgroup hierarchy
    root cgroup: p1, p2
        subcgroup: p3, p4
have BPF_F_ALLOW_MULTI for both cgroup levels.
The effective cgroup array ordering looks like
    p3 p4 p1 p2
and at run time, progs will execute based on that order.

But in some cases, it is desirable to have root prog executes earlier than
children progs (pre-ordering). For example,
  - prog p1 intends to collect original pkt dest addresses.
  - prog p3 will modify original pkt dest addresses to a proxy address for
    security reason.
The end result is that prog p1 gets proxy address which is not what it
wants. Putting p1 to every child cgroup is not desirable either as it
will duplicate itself in many child cgroups. And this is exactly a use case
we are encountering in Meta.

To fix this issue, let us introduce a flag BPF_F_PREORDER. If the flag
is specified at attachment time, the prog has higher priority and the
ordering with that flag will be from top to bottom (pre-ordering).
For example, in the above example,
    root cgroup: p1, p2
        subcgroup: p3, p4
Let us say p2 and p4 are marked with BPF_F_PREORDER. The final
effective array ordering will be
    p2 p4 p3 p1

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20250224230116.283071-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-05-29 11:02:17 +02:00
..
asm RISC-V Patches for the 6.12 Merge Window, Part 1 2024-09-24 10:59:17 -07:00
asm-generic move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
generated selftests: vDSO: don't include generated headers for chacha test 2024-09-13 17:28:36 +02:00
io_uring selftests/net: Extract uring helpers to be reusable 2023-10-19 16:42:03 -06:00
linux tools headers: Update the linux/unaligned.h copy with the kernel sources 2024-10-28 12:34:28 -03:00
nolibc tools/nolibc: s390: include std.h 2024-12-05 14:02:46 +01:00
perf KVM: selftests: aarch64: Update tools copy of arm_pmuv3.h 2023-12-12 09:46:22 +00:00
tools tools include: add dis-asm-compat.h to handle version differences 2022-08-01 15:29:49 -03:00
trace/events
uapi bpf: Allow pre-ordering for bpf cgroup progs 2025-05-29 11:02:17 +02:00
vdso tools headers: Update the linux/unaligned.h copy with the kernel sources 2024-10-28 12:34:28 -03:00