Skip to content

bpf: Support replacing cgroup-bpf program in MULTI mode

Andrey Ignatov bpf 4 versions – Applied

Status from this message: Applied, Thanks

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest6 patches 6 repliesApplied
  2. v36 patches 11 repliesSuperseded
  3. v26 patches 9 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v15 patches7 repliesSuperseded

Changes in v4 from the cover letter

- use OPTS_VALID and OPTS_GET to handle bpf_prog_attach_opts.

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/6bpf: Simplify __cgroup_bpf_attachkernel/bpf/cgroup.c+23 -391 reply
2/6bpf: Remove unused new_flags in hierarchy_allows_attach()kernel/bpf/cgroup.c+2 -30 replies
3/6bpf: Support replacing cgroup-bpf program in MULTI modeinclude/linux/bpf-cgroup.h include/uapi/linux/bpf.h kernel/bpf/cgroup.c +3 more+54 -91 reply
4/6libbpf: Introduce bpf_prog_attach_xattrtools/lib/bpf/bpf.c tools/lib/bpf/bpf.h tools/lib/bpf/libbpf.map+28 -11 reply
5/6selftests/bpf: Convert test_cgroup_attach to prog_teststools/testing/selftests/bpf/.gitignore tools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/prog_tests/cgroup_attach_autodetach.c +3 more+498 -5741 reply
6/6selftests/bpf: Test BPF_F_REPLACE in cgroup_attach_multitools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c+50 -31 reply

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchMartin KaFai LauAndrii Nakryiko
1/6A-b A-b
2/6A-b
3/6A-b A-b
4/6A-b
5/6A-b
6/6A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 bpf-next 0/6] bpf: Support replacing cgroup-bpf program in MULTI mode

v3->v4:
- use OPTS_VALID and OPTS_GET to handle bpf_prog_attach_opts.

v2->v3:
- rely on DECLARE_LIBBPF_OPTS from libbpf_common.h;
- separate "required" and "optional" arguments in bpf_prog_attach_xattr;
- convert test_cgroup_attach to prog_tests;
- move the new selftest to prog_tests/cgroup_attach_multi.

v1->v2:
- move DECLARE_LIBBPF_OPTS from libbpf.h to bpf.h (patch 4);
- switch new libbpf API to OPTS framework;
- switch selftest to libbpf OPTS framework.

This patch set adds support for replacing cgroup-bpf programs attached with BPF_F_ALLOW_MULTI flag so that any program in a list can be updated to a new version without service interruption and order of programs can be preserved.

Please see patch 3 for details on the use-case and API changes.

Other patches:
Patch 1 is preliminary refactoring of __cgroup_bpf_attach to simplify it. Patch 2 is minor cleanup of hierarchy_allows_attach.
Patch 4 extends libbpf API to support new set of attach attributes. Patch 5 converts test_cgroup_attach to prog_tests.
Patch 6 adds selftest coverage for the new API.

Andrey Ignatov (6):
bpf: Simplify __cgroup_bpf_attach
bpf: Remove unused new_flags in hierarchy_allows_attach()
bpf: Support replacing cgroup-bpf program in MULTI mode
libbpf: Introduce bpf_prog_attach_xattr selftests/bpf: Convert test_cgroup_attach to prog_tests selftests/bpf: Test BPF_F_REPLACE in cgroup_attach_multi

 include/linux/bpf-cgroup.h                    |   4 +-
 include/uapi/linux/bpf.h                      |  10 +
 kernel/bpf/cgroup.c                           |  97 +--
 kernel/bpf/syscall.c                          |   4 +-
 kernel/cgroup/cgroup.c                        |   5 +-
 tools/include/uapi/linux/bpf.h                |  10 +
 tools/lib/bpf/bpf.c                           |  17 +-
 tools/lib/bpf/bpf.h                           |  11 +
 tools/lib/bpf/libbpf.map                      |   1 +
 tools/testing/selftests/bpf/.gitignore        |   1 -
 tools/testing/selftests/bpf/Makefile          |   3 +-
 .../bpf/prog_tests/cgroup_attach_autodetach.c | 111 ++++
 .../bpf/prog_tests/cgroup_attach_multi.c      | 285 +++++++++
 .../bpf/prog_tests/cgroup_attach_override.c   | 148 +++++
 .../selftests/bpf/test_cgroup_attach.c        | 571 ------------------
 15 files changed, 652 insertions(+), 626 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/cgroup_attach_autodetach.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/cgroup_attach_override.c
 delete mode 100644 tools/testing/selftests/bpf/test_cgroup_attach.c
Signature · 1 line
2.17.1