All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kalpan Jani" <kalpan.jani@mpiricsoftware.com>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v7 2/2] selftests: mptcp: bpf: exercise the subflow avoid flag across rounds
Date: Mon, 23 Nov 2026 12:52:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-229270@kernel.org> (raw)
In-Reply-To: <20261123123730.3265284-3-kalpan.jani@mpiricsoftware.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests: mptcp: bpf: bpf_avoid_get_send() returns 0 with no
  subflow scheduled
--

commit e0591a67aaa7c65d7522308b6dae0bf53d4fc54f
Author: Kalpan Jani <kalpan.jani@mpiricsoftware.com>

selftests: mptcp: bpf: exercise the subflow avoid flag across rounds

This commit adds a BPF struct_ops scheduler selftest that exercises
mptcp_subflow_set_avoid() across send rounds using per-msk socket storage.

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

> diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c
> new file mode 100644
> index 0000000000000..8276ceb0e5397
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_avoid.c
> @@ -0,0 +1,87 @@
[ ... ]
> +SEC("struct_ops")
> +int BPF_PROG(bpf_avoid_get_send, struct mptcp_sock *msk)
> +{
> +	struct mptcp_subflow_context *subflow;
> +	struct mptcp_subflow_context *first = NULL;
> +	struct mptcp_avoid_storage *ptr;
> +
> +	ptr = bpf_sk_storage_get(&mptcp_avoid_map, msk, 0,
> +				 BPF_LOCAL_STORAGE_GET_F_CREATE);
> +	if (!ptr)
> +		return -1;
> +
> +	/*
> +	 * Wait until a second subflow exists before marking it avoided.
> +	 * This keeps the state unset until there is actually a subflow
> +	 * to exercise.
> +	 */
> +	bpf_for_each(mptcp_subflow, subflow, (struct sock *)msk) {
> +		if (!first) {
> +			first = subflow;
> +			continue;
> +		}
> +
> +		if (!ptr->avoid_marked) {
> +			mptcp_subflow_set_avoid(subflow, true);
> +			ptr->avoid_marked = true;
> +			continue;
> +		}
> +
> +		if (subflow->avoid)
> +			continue;
> +
> +		if (mptcp_subflow_active(subflow)) {
> +			mptcp_subflow_set_scheduled(subflow, true);
> +			return 0;
> +		}
> +	}
> +
> +	if (first && mptcp_subflow_active(first) && !first->avoid)
> +		mptcp_subflow_set_scheduled(first, true);
> +
> +	return 0;
> +}

[Severity: Medium]
Can bpf_avoid_get_send() return 0 without scheduling any subflow when
first is NULL, avoided, or temporarily inactive?

In __mptcp_subflow_push_pending(), a 0 return from mptcp_sched_get_send()
when no subflow has subflow->scheduled set leaves keep_pushing true, so
the while (mptcp_send_head(sk) && keep_pushing) loop spins indefinitely
under mptcp_data_lock(sk):

net/mptcp/protocol.c:__mptcp_subflow_push_pending() {
    ...
		if (mptcp_sched_get_send(msk))
			goto out;

		if (READ_ONCE(subflow->scheduled)) {
			mptcp_subflow_set_scheduled(subflow, false);
			ret = __subflow_push_pending(sk, ssk, &info);
			if (ret <= 0)
				keep_pushing = false;
			else
				copied += ret;
		}

		mptcp_for_each_subflow(msk, subflow) {
			if (READ_ONCE(subflow->scheduled)) {
				xmit_ssk = mptcp_subflow_tcp_sock(subflow);
				if (xmit_ssk != ssk) {
					mptcp_subflow_delegate(subflow,
							       MPTCP_DELEGATE_SEND);
					keep_pushing = false;
				}
			}
		}
    ...
}

Returning 0 inside the if (first && ...) branch and -1 when no subflow is
scheduled would match the other BPF schedulers.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123123730.3265284-1-kalpan.jani@mpiricsoftware.com?part=2

  reply	other threads:[~2026-11-23 12:52 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
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 [this message]
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=sashiko-outbox-229270@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kalpan.jani@mpiricsoftware.com \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.