Skip to content

libbpf: Add support for dynamic program attach target

Eelco Chaudron bpf netdev 5 versions – Applied

Status from this message: Applied, Thanks

Get series with b4
b4 am 158220517358.127661.1514720920408191215.stgit@xdp-tutorial

Versions newest first · linked by author and title

  1. v5 Latest3 patches 2 repliesApplied
  2. v43 patches 7 repliesSuperseded
  3. v31 patch 2 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v21 patch7 repliesSuperseded
v11 patch10 repliesSuperseded

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/3libbpf: Bump libpf current version to v0.0.8tools/lib/bpf/libbpf.map+3 -00 replies
2/3libbpf: Add support for dynamic program attach targettools/lib/bpf/libbpf.c tools/lib/bpf/libbpf.h tools/lib/bpf/libbpf.map+36 -40 replies
3/3selftests/bpf: update xdp_bpf2bpf test to use new set_attach_target APItools/testing/selftests/bpf/prog_tests/xdp_bpf2bpf.c tools/testing/selftests/bpf/progs/test_xdp_bpf2bpf.c+15 -51 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchToke Høiland-JørgensenAndrii Nakryiko
SeriesA-b
1/3A-b
2/3A-b A-b
3/3A-b A-b

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

Read the v5 thread

Cover letter [PATCH bpf-next v5 0/3] libbpf: Add support for dynamic program attach target

Currently when you want to attach a trace program to a bpf program the section name needs to match the tracepoint/function semantics.

However the addition of the bpf_program__set_attach_target() API allows you to specify the tracepoint/function dynamically.

The call flow would look something like this:

  xdp_fd = bpf_prog_get_fd_by_id(id);
  trace_obj = bpf_object__open_file("func.o", NULL);
  prog = bpf_object__find_program_by_title(trace_obj,
                                           "fentry/myfunc");
  bpf_program__set_expected_attach_type(prog, BPF_TRACE_FENTRY);
  bpf_program__set_attach_target(prog, xdp_fd,
                                 "xdpfilt_blk_all");
  bpf_object__load(trace_obj)

v1 -> v2: Remove requirement for attach type hint in API
v2 -> v3: Moved common warning to __find_vmlinux_btf_id, requested by Andrii
Updated the xdp_bpf2bpf test to use this new API
v3 -> v4: Split up patch, update libbpf.map version
v4 -> v5: Fix return code, and prog assignment in test case