From: Martin KaFai Lau <kafai@fb.com>
To: <bpf@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>,
<netdev@vger.kernel.org>
Subject: [PATCH v2 bpf-next 0/4] bpf: tcp: Allow bpf-tcp-cc to call bpf_(get|set)sockopt
Date: Tue, 24 Aug 2021 10:30:00 -0700 [thread overview]
Message-ID: <20210824173000.3976470-1-kafai@fb.com> (raw)
This set allows the bpf-tcp-cc to call bpf_setsockopt. One use
case is to allow a bpf-tcp-cc switching to another cc during init().
For example, when the tcp flow is not ecn ready, the bpf_dctcp
can switch to another cc by calling setsockopt(TCP_CONGESTION).
bpf_getsockopt() is also added to have a symmetrical API, so
less usage surprise.
v2:
- Not allow switching to kernel's tcp_cdg because it is the only
kernel tcp-cc that stores a pointer to icsk_ca_priv.
Please see the commit log in patch 1 for details.
Test is added in patch 4 to check switching to tcp_cdg.
- Refactor the logic finding the offset of a func ptr
in the "struct tcp_congestion_ops" to prog_ops_moff()
in patch 1.
- bpf_setsockopt() has been disabled in release() since v1 (please
see commit log in patch 1 for reason). bpf_getsockopt() is
also disabled together in release() in v2 to avoid usage surprise
because both of them are usually expected to be available together.
bpf-tcp-cc can already use PTR_TO_BTF_ID to read from tcp_sock.
Martin KaFai Lau (4):
bpf: tcp: Allow bpf-tcp-cc to call bpf_(get|set)sockopt
bpf: selftests: Add sk_state to bpf_tcp_helpers.h
bpf: selftests: Add connect_to_fd_opts to network_helpers
bpf: selftests: Add dctcp fallback test
kernel/bpf/bpf_struct_ops.c | 22 +++-
net/core/filter.c | 6 +
net/ipv4/bpf_tcp_ca.c | 41 ++++++-
tools/testing/selftests/bpf/bpf_tcp_helpers.h | 1 +
tools/testing/selftests/bpf/network_helpers.c | 23 +++-
tools/testing/selftests/bpf/network_helpers.h | 6 +
.../selftests/bpf/prog_tests/bpf_tcp_ca.c | 106 ++++++++++++++----
.../selftests/bpf/prog_tests/kfunc_call.c | 2 +-
tools/testing/selftests/bpf/progs/bpf_dctcp.c | 25 +++++
.../selftests/bpf/progs/bpf_dctcp_release.c | 26 +++++
.../bpf/progs/kfunc_call_test_subprog.c | 4 +-
11 files changed, 230 insertions(+), 32 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/bpf_dctcp_release.c
--
2.30.2
next reply other threads:[~2021-08-24 17:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 17:30 Martin KaFai Lau [this message]
2021-08-24 17:30 ` [PATCH v2 bpf-next 1/4] bpf: tcp: Allow bpf-tcp-cc to call bpf_(get|set)sockopt Martin KaFai Lau
2021-08-24 17:30 ` [PATCH v2 bpf-next 2/4] bpf: selftests: Add sk_state to bpf_tcp_helpers.h Martin KaFai Lau
2021-08-24 17:30 ` [PATCH v2 bpf-next 3/4] bpf: selftests: Add connect_to_fd_opts to network_helpers Martin KaFai Lau
2021-08-24 17:30 ` [PATCH v2 bpf-next 4/4] bpf: selftests: Add dctcp fallback test Martin KaFai Lau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210824173000.3976470-1-kafai@fb.com \
--to=kafai@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox