bpf: support cloning sk storage on accept()
Status from this message: Applied, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest4 patches 1 replyApplied
- v34 patches 4 repliesSuperseded
- v24 patches 9 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 3 patches | 10 replies | Superseded |
Changes in v4 from the cover letter
* drop 'goto err' in bpf_sk_storage_clone (Yonghong Song)
* add comment about race with bpf_sk_storage_map_free to the bpf_sk_storage_clone side as well (Daniel Borkmann)
Patches in v4 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | bpf: export bpf_map_inc_not_zeroinclude/ kernel/ | +15 | 0 replies | |
| 2/4 | bpf: support cloning sk storage on accept()include/ include/ net/ +1 more | +120 | 0 replies | |
| 3/4 | bpf: sync bpf.h to tools/tools/ | +3 | 0 replies | |
| 4/4 | selftests/bpf: add sockopt clone/inheritance testtools/ tools/ tools/ +1 more | +353 | 0 replies |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by.
| Patch | Martin KaFai Lau | Yonghong Song |
|---|---|---|
| 1/4 | A-b | A-b |
| 2/4 | A-b | A-b |
| 3/4 | A-b | A-b |
| 4/4 | A-b | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf-next v4 0/4] bpf: support cloning sk storage on accept()
Currently there is no way to propagate sk storage from the listener socket to a newly accepted one. Consider the following use case:
fd = socket();
setsockopt(fd, SOL_IP, IP_TOS,...);
/* ^^^ setsockopt BPF program triggers here and saves something
* into sk storage of the listener.
*/
listen(fd, ...);
while (client = accept(fd)) {
/* At this point all association between listener
* socket and newly accepted one is gone. New
* socket will not have any sk storage attached.
*/
}Let's add new BPF_F_CLONE flag that can be specified when creating a socket storage map. This new flag indicates that map contents should be cloned when the socket is cloned.
v4:
* drop 'goto err' in bpf_sk_storage_clone (Yonghong Song)
* add comment about race with bpf_sk_storage_map_free to the bpf_sk_storage_clone side as well (Daniel Borkmann)
v3:
* make sure BPF_F_NO_PREALLOC is always present when creating a map (Martin KaFai Lau)
* don't call bpf_sk_storage_free explicitly, rely on sk_free_unlock_clone to do the cleanup (Martin KaFai Lau)
v2:
* remove spinlocks around selem_link_map/sk (Martin KaFai Lau)
* BPF_F_CLONE on a map, not selem (Martin KaFai Lau)
* hold a map while cloning (Martin KaFai Lau)
* use BTF maps in selftests (Yonghong Song)
* do proper cleanup selftests; don't call close(-1) (Yonghong Song)
* export bpf_map_inc_not_zero
Stanislav Fomichev (4):
bpf: export bpf_map_inc_not_zero
bpf: support cloning sk storage on accept()
bpf: sync bpf.h to tools/
selftests/bpf: add sockopt clone/inheritance test
include/linux/bpf.h | 2 + include/net/bpf_sk_storage.h | 10 + include/uapi/linux/bpf.h | 3 + kernel/bpf/syscall.c | 16 +- net/core/bpf_sk_storage.c | 104 ++++++- net/core/sock.c | 9 +- tools/include/uapi/linux/bpf.h | 3 + tools/testing/selftests/bpf/.gitignore | 1 + tools/testing/selftests/bpf/Makefile | 3 +- .../selftests/bpf/progs/sockopt_inherit.c | 97 +++++++ .../selftests/bpf/test_sockopt_inherit.c | 253 ++++++++++++++++++ 11 files changed, 491 insertions(+), 10 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/sockopt_inherit.c create mode 100644 tools/testing/selftests/bpf/test_sockopt_inherit.c
Signature · 1 line
2.23.0.rc1.153.gdeed80330f-goog