All of lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kalpan.jani@mpiricsoftware.com
Cc: mptcp@lists.linux.dev, shardul.b@mpiricsoftware.com,
	janak@mpiric.us, kalpanjani009@gmail.com, pabeni@redhat.com,
	kuba@kernel.org
Subject: Re: [PATCH mptcp-next v7 1/2] mptcp: sched: add subflow avoid flag for BPF schedulers
Date: Wed, 25 Nov 2026 01:31:17 +0000	[thread overview]
Message-ID: <179557027703.3133.4249741891623868683@kernel.org> (raw)
In-Reply-To: <20261123123730.3265284-2-kalpan.jani@mpiricsoftware.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] mptcp: sched: subflow avoid flag is unused by MPTCP core
- [Low] The commit message says "only mptcp_subflow_set_avoid() writes it
  ... so only a BPF scheduler can change its value".
- [Low] The new kfunc mptcp_subflow_set_avoid() (net/mptcp/sched.c)
  stores a BPF-supplied `bool avoid` with `WRITE_ONCE(subflow->avoid,…

--

mptcp: sched: add subflow avoid flag for BPF schedulers

This patch adds an "avoid" bool to struct mptcp_subflow_context. BPF
struct_ops schedulers set it through a new mptcp_subflow_set_avoid()
kfunc. The flag is also exported to userspace through MPTCP diag as
MPTCP_SUBFLOW_FLAG_AVOID.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/349

> Add a scheduler-owned "avoid" bool to mptcp_subflow_context:
>
>  - only mptcp_subflow_set_avoid() writes it. It is exposed to BPF
>    struct_ops schedulers as a kfunc with the same registration and
>    filter as mptcp_subflow_set_scheduled(), so only a BPF scheduler
>    can change its value;

[Severity: Low]
Is this description accurate? The new field is declared inside
struct_group(reset, ...) in struct mptcp_subflow_context. That means
mptcp_subflow_ctx_reset() also clears it:

net/mptcp/protocol.h:mptcp_subflow_ctx_reset() {
	memset(&subflow->reset, 0, sizeof(subflow->reset));
	...
}

The core reaches this from two places. One is
__mptcp_close_ssk()->__mptcp_subflow_disconnect(), which includes
msk->first being reset for reuse. The other is the error path of
mptcp_connect().

Resetting the flag together with the rest of the subflow context is
probably the intended behaviour. Could the commit message, or the field
comment, say that avoid is cleared on subflow context reset, so BPF
scheduler authors know the core can clear it?

[ ... ]

> diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
> index 1e59072d478c9..0ce59eb093df6 100644
> --- a/net/mptcp/sched.c
> +++ b/net/mptcp/sched.c
> @@ -165,6 +165,12 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
>  	WRITE_ONCE(subflow->scheduled, scheduled);
>  }
>
> +__bpf_kfunc void mptcp_subflow_set_avoid(struct mptcp_subflow_context *subflow,
> +					 bool avoid)
> +{
> +	WRITE_ONCE(subflow->avoid, avoid);

[Severity: Medium]
This version drops the avoid checks from mptcp_subflow_get_send() and
mptcp_subflow_get_retrans(). Does anything in the MPTCP core still read
subflow->avoid?

As far as I can see, the only reader left is subflow_get_info() in
diag.c. The only writer is mptcp_subflow_set_avoid(), and
bpf_mptcp_common_kfunc_filter() limits that kfunc to
bpf_mptcp_sched_ops struct_ops programs. So the field ends up as one
byte of per-subflow scratch storage owned by the BPF scheduler. The
core never acts on it in the send, retransmission, stale or
mptcp_subflow_active() paths.

The selftest in patch 2 shows the same thing. bpf_avoid_get_send()
sets the flag with mptcp_subflow_set_avoid() and then reads it back in
its own get_send callback to decide whether to call
mptcp_subflow_set_scheduled(). A BPF scheduler can already keep this
kind of per-subflow state in a BPF map without any kernel change.

This matters because the patch also adds MPTCP_SUBFLOW_FLAG_AVOID to
include/uapi/linux/mptcp.h. Once released, that bit is uAPI, but its
meaning depends entirely on whichever BPF scheduler is loaded. The
kernel itself attaches no semantics to it.

Earlier review of this series asked for a working scenario that the
scheduled bit cannot already cover, with the core actually making use
of the new state. Is a follow-up planned where the core honours avoid
in code that runs regardless of which scheduler is attached? If not,
would it be better to drop the field, the kfunc and the uAPI bit, and
keep this state inside the BPF scheduler?

[Severity: Low]
Can a BPF scheduler store a non-canonical bool here?

The verifier classifies a bool kfunc parameter as a plain ARG_SCALAR in
get_kfunc_arg_type(), and the ARG_SCALAR case applies no range check. A
struct_ops scheduler could therefore pass a value such as 2 in R2, using
raw BPF instructions or an extern declared with an int parameter. That
byte would then be written into the _Bool field unchanged.

Any user can later reach the read side through the MPTCP inet_diag dump:

net/mptcp/diag.c:subflow_get_info() {
	...
	if (READ_ONCE(sf->avoid))
		flags |= MPTCP_SUBFLOW_FLAG_AVOID;
	...
}

Loading a _Bool that holds a value other than 0 or 1 is undefined
behaviour. CONFIG_UBSAN_BOOL would report it, and depending on codegen
it could put unexpected bits into MPTCP_SUBFLOW_ATTR_FLAGS.

Would storing !!avoid here avoid this? mptcp_subflow_set_scheduled() has
the same pattern, but this patch adds a new instance and exposes the
value to userspace.

> +}
> +
>  int mptcp_sched_get_send(struct mptcp_sock *msk)
>  {
>  	struct mptcp_subflow_context *subflow;

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123123730.3265284-1-kalpan.jani%40mpiricsoftware.com

  parent reply	other threads:[~2026-11-25  1:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 12:37 [PATCH mptcp-next v7 0/2] mptcp: add scheduler-owned subflow avoid flag Kalpan Jani
2026-11-23 12:37 ` [PATCH mptcp-next v7 1/2] mptcp: sched: add subflow avoid flag for BPF schedulers Kalpan Jani
2026-11-23 12:47   ` sashiko-bot
2026-11-25  1:31   ` netdev-bot+sashiko [this message]
2026-11-23 12:37 ` [PATCH mptcp-next v7 2/2] selftests: mptcp: bpf: exercise the subflow avoid flag across rounds Kalpan Jani
2026-11-23 12:52   ` sashiko-bot
2026-11-25  1:31   ` netdev-bot+sashiko

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=179557027703.3133.4249741891623868683@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=janak@mpiric.us \
    --cc=kalpan.jani@mpiricsoftware.com \
    --cc=kalpanjani009@gmail.com \
    --cc=kuba@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --cc=shardul.b@mpiricsoftware.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.