Skip to content

bpf: Add bpf_link support for sk_msg and sk_skb progs

Yonghong Song bpf 6 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest5 patches 0 repliesApplied 5/5
  2. v65 patches 3 repliesSuperseded
  3. v55 patches 6 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v45 patches12 repliesSuperseded
v35 patches20 repliesSuperseded
v26 patches10 repliesSuperseded

Changes in v7 from the cover letter

- fix an missing-mutex_unlock error.

Patches in v7 All 5 applied

#Subject and filesSizeRepliesApplied
1/5bpf: Add bpf_link support for sk_msg and sk_skb progsinclude/linux/bpf.h include/linux/skmsg.h include/uapi/linux/bpf.h +3 more+271 -160 repliesApplied
2/5libbpf: Add bpf_link support for BPF_PROG_TYPE_SOCKMAPtools/lib/bpf/libbpf.c tools/lib/bpf/libbpf.h tools/lib/bpf/libbpf.map+10 -00 repliesApplied
3/5bpftool: Add link dump support for BPF_LINK_TYPE_SOCKMAPtools/bpf/bpftool/link.c+9 -00 repliesApplied
4/5selftests/bpf: Refactor out helper functions for a few teststools/testing/selftests/bpf/prog_tests/sockmap_basic.c tools/testing/selftests/bpf/progs/test_skmsg_load_helpers.c+30 -170 repliesApplied
5/5selftests/bpf: Add some tests with new bpf_program__attach_sockmap() APIstools/testing/selftests/bpf/prog_tests/sockmap_basic.c tools/testing/selftests/bpf/prog_tests/sockmap_listen.c tools/testing/selftests/bpf/progs/test_skmsg_load_helpers.c +2 more+206 -20 repliesApplied

Reviews trailers per patch

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

PatchJohn FastabendAndrii NakryikoEduard ZingermanQuentin Monnet
1/5R-b
2/5R-b A-b A-b
3/5R-b R-b
4/5R-b A-b
5/5R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v7 thread

Cover letter [PATCH bpf-next v7 0/5] bpf: Add bpf_link support for sk_msg and sk_skb progs

One of our internal services started to use sk_msg program and currently it used existing prog attach/detach2 as demonstrated in selftests. But attach/detach of all other bpf programs are based on bpf_link. Consistent attach/detach APIs for all programs will make things easy to undersand and less error prone. So this patch added bpf_link support for BPF_PROG_TYPE_SK_MSG. Based on comments from previous RFC patch, I added BPF_PROG_TYPE_SK_SKB support as well as both program types have similar treatment w.r.t. bpf_link handling.

For the patch series, patch 1 added kernel support. Patch 2 added libbpf support. Patch 3 added bpftool support and patches 4/5 added some new tests.

Changelogs:
v6 -> v7:
- fix an missing-mutex_unlock error.
v5 -> v6:
- resolve libbpf conflict due to recent upstream change.
- add a bpf_link_create() test.
- some code refactoring for better code quality.
v4 -> v5:
- increase scope of mutex protection in link_release.
- remove previous-leftover entry in libbpf.map.
- make some code changes for better understanding.
v3 -> v4:
- use a single mutex lock to protect both attach/detach/update and release/fill_info/show_fdinfo.
- simplify code for sock_map_link_lookup().
- fix a few bugs.
- add more tests.
v2 -> v3:
- consolidate link types of sk_msg and sk_skb to
a single link type BPF_PROG_TYPE_SOCKMAP.
- fix bpf_link lifecycle issue. in v2, after bpf_link is attached, a subsequent prog_attach could change that bpf_link. this patch makes bpf_link having correct behavior such that it won't go away facing other prog/link attach for the same map and the same attach type.

Yonghong Song (5):
bpf: Add bpf_link support for sk_msg and sk_skb progs
libbpf: Add bpf_link support for BPF_PROG_TYPE_SOCKMAP
bpftool: Add link dump support for BPF_LINK_TYPE_SOCKMAP selftests/bpf: Refactor out helper functions for a few tests selftests/bpf: Add some tests with new bpf_program__attach_sockmap()
APIs

 include/linux/bpf.h                           |   6 +
 include/linux/skmsg.h                         |   4 +
 include/uapi/linux/bpf.h                      |   5 +
 kernel/bpf/syscall.c                          |   4 +
 net/core/sock_map.c                           | 263 ++++++++++++++++--
 tools/bpf/bpftool/link.c                      |   9 +
 tools/include/uapi/linux/bpf.h                |   5 +
 tools/lib/bpf/libbpf.c                        |   7 +
 tools/lib/bpf/libbpf.h                        |   2 +
 tools/lib/bpf/libbpf.map                      |   1 +
 .../selftests/bpf/prog_tests/sockmap_basic.c  | 171 +++++++++++-
 .../selftests/bpf/prog_tests/sockmap_listen.c |  38 +++
 .../bpf/progs/test_skmsg_load_helpers.c       |  27 +-
 .../bpf/progs/test_sockmap_pass_prog.c        |  17 +-
 .../progs/test_sockmap_skb_verdict_attach.c   |   2 +-
 15 files changed, 526 insertions(+), 35 deletions(-)
Signature · 1 line
2.43.0