Skip to content

bpf: Allow opt-out from sk->sk_prot->memory_allocated.

Kuniyuki Iwashima bpf netdev 2 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. v2 Latest6 patches 3 repliesApplied 6/6
  2. v16 patches 12 repliesSuperseded

Changes in v2 from the cover letter

* Patch 2:
* Fill kdoc for skc_bypass_prot_mem
* Patch 6
* Fix server fd leak in tcp_create_sockets()
* Avoid close(0) in check_bypass()

Patches in v2 All 6 applied

#Subject and filesSizeRepliesApplied
1/6tcp: Save lock_sock() for memcg in inet_csk_accept().net/ipv4/af_inet.c net/ipv4/inet_connection_sock.c+22 -250 repliesApplied
2/6net: Allow opt-out from global protocol memory accounting.include/net/proto_memory.h include/net/sock.h include/net/tcp.h +5 more+48 -130 repliesApplied
3/6net: Introduce net.core.bypass_prot_mem sysctl.Documentation/admin-guide/sysctl/net.rst include/net/netns/core.h net/core/sock.c +1 more+23 -00 repliesApplied
4/6bpf: Support bpf_setsockopt() for BPF_CGROUP_INET_SOCK_CREATE.net/core/filter.c+48 -00 repliesApplied
5/6bpf: Introduce SK_BPF_BYPASS_PROT_MEM.include/uapi/linux/bpf.h net/core/filter.c tools/include/uapi/linux/bpf.h+34 -01 replyApplied
6/6selftest: bpf: Add test for sk->sk_bypass_prot_mem.tools/testing/selftests/bpf/prog_tests/sk_bypass_prot_mem.c tools/testing/selftests/bpf/progs/sk_bypass_prot_mem.c+393 -02 repliesApplied

Reviews trailers per patch

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

PatchShakeel ButtRoman GushchinEric Dumazet
1/6R-b A-b R-b
2/6R-b A-b R-b
3/6R-b A-b R-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. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 bpf-next/net 0/6] bpf: Allow opt-out from sk->sk_prot->memory_allocated.

This series allows opting out of the global per-protocol memory accounting if socket is configured as such by sysctl or BPF prog.

This series is the successor of the series below [0], but the changes now fall in net and bpf subsystems only.

I discussed with Roman Gushchin offlist, and he suggested not mixing two independent subsystems and it would be cleaner not to depend on memcg.

So, sk->sk_memcg and memcg code are no longer touched, and instead we use another hole near sk->sk_prot to store a flag for the pure net opt-out feature.

Overview of the series:

patch 1 is misc cleanup
patch 2 allows opt-out from sk->sk_prot->memory_allocated patch 3 introduces net.core.bypass_prot_mem
patch 4 & 5 supports flagging sk->sk_bypass_prot_mem via bpf_setsockopt() patch 6 is selftest

Thank you very much for all your help, Shakeel, Roman, Martin, and Eric!

[0]: https://lore.kernel.org/bpf/[email protected]/

Changes:
v2:
* Patch 2:
* Fill kdoc for skc_bypass_prot_mem
* Patch 6
* Fix server fd leak in tcp_create_sockets()
* Avoid close(0) in check_bypass()

v1: https://lore.kernel.org/bpf/[email protected]/

Kuniyuki Iwashima (6):
tcp: Save lock_sock() for memcg in inet_csk_accept().
net: Allow opt-out from global protocol memory accounting.
net: Introduce net.core.bypass_prot_mem sysctl.
bpf: Support bpf_setsockopt() for BPF_CGROUP_INET_SOCK_CREATE.
bpf: Introduce SK_BPF_BYPASS_PROT_MEM.
selftest: bpf: Add test for sk->sk_bypass_prot_mem.

 Documentation/admin-guide/sysctl/net.rst      |   8 +
 include/net/netns/core.h                      |   1 +
 include/net/proto_memory.h                    |   3 +
 include/net/sock.h                            |   3 +
 include/net/tcp.h                             |   3 +
 include/uapi/linux/bpf.h                      |   2 +
 net/core/filter.c                             |  79 +++++
 net/core/sock.c                               |  37 ++-
 net/core/sysctl_net_core.c                    |   9 +
 net/ipv4/af_inet.c                            |  22 ++
 net/ipv4/inet_connection_sock.c               |  25 --
 net/ipv4/tcp.c                                |   3 +-
 net/ipv4/tcp_output.c                         |   7 +-
 net/mptcp/protocol.c                          |   7 +-
 net/tls/tls_device.c                          |   3 +-
 tools/include/uapi/linux/bpf.h                |   1 +
 .../bpf/prog_tests/sk_bypass_prot_mem.c       | 289 ++++++++++++++++++
 .../selftests/bpf/progs/sk_bypass_prot_mem.c  | 104 +++++++
 18 files changed, 568 insertions(+), 38 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/sk_bypass_prot_mem.c
 create mode 100644 tools/testing/selftests/bpf/progs/sk_bypass_prot_mem.c
Signature · 1 line
2.51.0.788.g6d19910ace-goog