From: "Jörn-Thorben Hinz" <jthinz@mailbox.tu-berlin.de>
To: Martin KaFai Lau <kafai@fb.com>
Cc: <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next v2 2/2] bpf: Require only one of cong_avoid() and cong_control() from a TCP CC
Date: Tue, 14 Jun 2022 12:52:11 +0200 [thread overview]
Message-ID: <a246494232612c20e2a6952e3dd0a2d9fbbabf21.camel@mailbox.tu-berlin.de> (raw)
In-Reply-To: <20220613171703.xoetc7dlr4qkss43@kafai-mbp>
On Mon, 2022-06-13 at 10:17 -0700, Martin KaFai Lau wrote:
> On Thu, Jun 09, 2022 at 10:47:02PM +0200, Jörn-Thorben Hinz wrote:
> > Remove the check for required and optional functions in a struct
> > tcp_congestion_ops from bpf_tcp_ca.c. Rely on
> > tcp_register_congestion_control() to reject a BPF CC that does not
> > implement all required functions, as it will do for a non-BPF CC.
> >
> > When a CC implements tcp_congestion_ops.cong_control(), the
> > alternate
> > cong_avoid() is not in use in the TCP stack. Previously, a BPF CC
> > was
> > still forced to implement cong_avoid() as a no-op since it was
> > non-optional in bpf_tcp_ca.c.
> >
> > Signed-off-by: Jörn-Thorben Hinz <jthinz@mailbox.tu-berlin.de>
> > ---
> > net/ipv4/bpf_tcp_ca.c | 32 --------------------------------
> > 1 file changed, 32 deletions(-)
> >
> > diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c
> > index 1f5c53ede4e5..39b64f317499 100644
> > --- a/net/ipv4/bpf_tcp_ca.c
> > +++ b/net/ipv4/bpf_tcp_ca.c
> > @@ -14,18 +14,6 @@
> > /* "extern" is to avoid sparse warning. It is only used in
> > bpf_struct_ops.c. */
> > extern struct bpf_struct_ops bpf_tcp_congestion_ops;
> >
> > -static u32 optional_ops[] = {
> > - offsetof(struct tcp_congestion_ops, init),
> > - offsetof(struct tcp_congestion_ops, release),
> > - offsetof(struct tcp_congestion_ops, set_state),
> > - offsetof(struct tcp_congestion_ops, cwnd_event),
> > - offsetof(struct tcp_congestion_ops, in_ack_event),
> > - offsetof(struct tcp_congestion_ops, pkts_acked),
> > - offsetof(struct tcp_congestion_ops, min_tso_segs),
> > - offsetof(struct tcp_congestion_ops, sndbuf_expand),
> > - offsetof(struct tcp_congestion_ops, cong_control),
> > -};
> > -
> > static u32 unsupported_ops[] = {
> > offsetof(struct tcp_congestion_ops, get_info),
> > };
> > @@ -51,18 +39,6 @@ static int bpf_tcp_ca_init(struct btf *btf)
> > return 0;
> > }
> >
> > -static bool is_optional(u32 member_offset)
> > -{
> > - unsigned int i;
> > -
> > - for (i = 0; i < ARRAY_SIZE(optional_ops); i++) {
> > - if (member_offset == optional_ops[i])
> > - return true;
> > - }
> > -
> > - return false;
> > -}
> > -
> > static bool is_unsupported(u32 member_offset)
> > {
> > unsigned int i;
> > @@ -268,14 +244,6 @@ static int bpf_tcp_ca_init_member(const struct
> > btf_type *t,
> > return 1;
> > }
> >
> > - if (!btf_type_resolve_func_ptr(btf_vmlinux, member->type,
> > NULL))
> > - return 0;
> > -
> > - /* Ensure bpf_prog is provided for compulsory func ptr */
> > - prog_fd = (int)(*(unsigned long *)(udata + moff));
> > - if (!prog_fd && !is_optional(moff) &&
> > !is_unsupported(moff))
> !is_unsupported() is still needed.
I don’t think it is necessary here.
There is also bpf_tcp_ca_check_member(), which also and only tests for
is_unsupported(). And check_member() will be called even earlier than
init_member() when loading a struct_ops. This deleted is_unsupported()
call should have been there only to test for missing but required &&
supported functions.
I added a test in v3 to make sure the check for the unsupported
get_info() (still) works.
Please correct me, if I misread/misfollowed the code paths!
>
> and remove 'int prog_fd' as reported by the test bot.
Of course, sorry about that … Oversight on my side.
>
> Test is still needed. You can copy the simpler "bpf_dctcp"
> to another tcp_congestion_ops. Write+read the sk_packing
> and also use .cong_control instead of .cong_avoid. I think rs-
> >acked_sacked
> is the 'delivered' and the 'ack' is not used.
Added tests in v3 of the patch series. I’m open for further feedback.
prev parent reply other threads:[~2022-06-14 10:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-08 17:48 [PATCH bpf-next 0/2] Align BPF TCP CCs implementing cong_control() with non-BPF CCs Jörn-Thorben Hinz
2022-06-08 17:48 ` [PATCH bpf-next 1/2] bpf: Allow a TCP CC to write sk_pacing_rate and sk_pacing_status Jörn-Thorben Hinz
2022-06-08 17:48 ` [PATCH bpf-next 2/2] bpf: Require only one of cong_avoid() and cong_control() from a TCP CC Jörn-Thorben Hinz
2022-06-08 18:33 ` Martin KaFai Lau
2022-06-09 8:55 ` Jörn-Thorben Hinz
2022-06-09 18:55 ` Martin KaFai Lau
2022-06-14 10:51 ` Jörn-Thorben Hinz
2022-06-09 20:47 ` [PATCH bpf-next v2 0/2] Align BPF TCP CCs implementing cong_control() with non-BPF CCs Jörn-Thorben Hinz
2022-06-09 20:47 ` [PATCH bpf-next v2 1/2] bpf: Allow a TCP CC to write sk_pacing_rate and sk_pacing_status Jörn-Thorben Hinz
2022-06-09 20:47 ` [PATCH bpf-next v2 2/2] bpf: Require only one of cong_avoid() and cong_control() from a TCP CC Jörn-Thorben Hinz
2022-06-10 0:52 ` kernel test robot
2022-06-10 13:26 ` kernel test robot
2022-06-13 17:17 ` Martin KaFai Lau
2022-06-14 10:52 ` Jörn-Thorben Hinz [this message]
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=a246494232612c20e2a6952e3dd0a2d9fbbabf21.camel@mailbox.tu-berlin.de \
--to=jthinz@mailbox.tu-berlin.de \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@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;
as well as URLs for NNTP newsgroup(s).