]> www.infradead.org Git - users/jedix/linux-maple.git/commit
libbpf: Support link-based cgroup attach with options
authorYonghong Song <yonghong.song@linux.dev>
Fri, 6 Jun 2025 16:31:46 +0000 (09:31 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 9 Jun 2025 23:28:30 +0000 (16:28 -0700)
commit1d6711667cb358fd2971c760a67b4fe843179d15
treef7dc2d20bd3ecc79a3df962ff5dc6d819a443b44
parent1209339844601ec1766f4ff430673fbcfe42bb51
libbpf: Support link-based cgroup attach with options

Currently libbpf supports bpf_program__attach_cgroup() with signature:
  LIBBPF_API struct bpf_link *
  bpf_program__attach_cgroup(const struct bpf_program *prog, int cgroup_fd);

To support mprog style attachment, additionsl fields like flags,
relative_{fd,id} and expected_revision are needed.

Add a new API:
  LIBBPF_API struct bpf_link *
  bpf_program__attach_cgroup_opts(const struct bpf_program *prog, int cgroup_fd,
                                  const struct bpf_cgroup_opts *opts);
where bpf_cgroup_opts contains all above needed fields.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250606163146.2429212-1-yonghong.song@linux.dev
tools/lib/bpf/bpf.c
tools/lib/bpf/bpf.h
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.h
tools/lib/bpf/libbpf.map