MPTCP Linux Development
 help / color / mirror / Atom feed
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Geliang Tang <geliang.tang@suse.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v9 1/3] mptcp: add subflows array in mptcp_sched_data
Date: Fri, 29 Apr 2022 17:30:23 -0700 (PDT)	[thread overview]
Message-ID: <27dd2036-b1e0-95bb-19c5-6b8519a44f81@linux.intel.com> (raw)
In-Reply-To: <c1e8b41ce01678189c1b5d51719df3c75ba881dd.1651243739.git.geliang.tang@suse.com>

On Fri, 29 Apr 2022, Geliang Tang wrote:

> This patch adds a subflow pointers array in struct mptcp_sched_data. Set
> the array before invoking get_subflow(), then get it in get_subflow() in
> the BPF contexts.
>
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> include/net/mptcp.h                             |  3 +++
> net/mptcp/protocol.h                            | 16 ++++++++++++++++
> tools/testing/selftests/bpf/bpf_mptcp_helpers.h |  3 +++
> 3 files changed, 22 insertions(+)
>
> diff --git a/include/net/mptcp.h b/include/net/mptcp.h
> index bea7608d72d3..1a48e31f3ac7 100644
> --- a/include/net/mptcp.h
> +++ b/include/net/mptcp.h
> @@ -96,10 +96,13 @@ struct mptcp_out_options {
> };
>
> #define MPTCP_SCHED_NAME_MAX	16
> +#define MPTCP_SUBFLOWS_MAX	8
>
> struct mptcp_sched_data {
> 	struct sock	*sock;
> 	bool		call_again;
> +	u8		subflows;
> +	struct mptcp_subflow_context *array[MPTCP_SUBFLOWS_MAX];
> };
>
> struct mptcp_sched_ops {
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 0da2a91ad197..95a65582f1e8 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -993,7 +993,9 @@ struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk);
>
> static inline struct sock *mptcp_sched_get_send(struct mptcp_sock *msk)
> {
> +	struct mptcp_subflow_context *subflow;
> 	struct mptcp_sched_data data;
> +	int i = 0;
>
> 	sock_owned_by_me((struct sock *)msk);
>
> @@ -1007,14 +1009,22 @@ static inline struct sock *mptcp_sched_get_send(struct mptcp_sock *msk)
> 	if (!msk->sched)
> 		return mptcp_subflow_get_send(msk);
>
> +	mptcp_for_each_subflow(msk, subflow)
> +		data.array[i++] = subflow;
> +	data.subflows = i;

As I mentioned in a previous patch, a helper function here would be good.

> 	msk->sched->get_subflow(msk, false, &data);
> +	for (i = 0; i < MPTCP_SUBFLOWS_MAX; i++)
> +		data.array[i++] = NULL;
> +	data.subflows = 0;

Why zero out this data on the stack if BPF does not have write access to 
it?

- Mat

>
> 	return data.sock;
> }
>
> static inline struct sock *mptcp_sched_get_retrans(struct mptcp_sock *msk)
> {
> +	struct mptcp_subflow_context *subflow;
> 	struct mptcp_sched_data data;
> +	int i = 0;
>
> 	sock_owned_by_me((const struct sock *)msk);
>
> @@ -1025,7 +1035,13 @@ static inline struct sock *mptcp_sched_get_retrans(struct mptcp_sock *msk)
> 	if (!msk->sched)
> 		return mptcp_subflow_get_retrans(msk);
>
> +	mptcp_for_each_subflow(msk, subflow)
> +		data.array[i++] = subflow;
> +	data.subflows = i;
> 	msk->sched->get_subflow(msk, true, &data);
> +	for (i = 0; i < MPTCP_SUBFLOWS_MAX; i++)
> +		data.array[i++] = NULL;
> +	data.subflows = 0;
>
> 	return data.sock;
> }
> diff --git a/tools/testing/selftests/bpf/bpf_mptcp_helpers.h b/tools/testing/selftests/bpf/bpf_mptcp_helpers.h
> index ee07caf978b3..1fe3d0a97429 100644
> --- a/tools/testing/selftests/bpf/bpf_mptcp_helpers.h
> +++ b/tools/testing/selftests/bpf/bpf_mptcp_helpers.h
> @@ -7,10 +7,13 @@
> #include "bpf_tcp_helpers.h"
>
> #define MPTCP_SCHED_NAME_MAX	16
> +#define MPTCP_SUBFLOWS_MAX	8
>
> struct mptcp_sched_data {
> 	struct sock	*sock;
> 	bool		call_again;
> +	__u8		subflows;
> +	struct mptcp_subflow_context *array[MPTCP_SUBFLOWS_MAX];
> };
>
> struct mptcp_sched_ops {
> -- 
> 2.34.1
>
>
>

--
Mat Martineau
Intel

  reply	other threads:[~2022-04-30  0:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29 14:51 [PATCH mptcp-next v9 0/3] BPF round-robin scheduler Geliang Tang
2022-04-29 14:51 ` [PATCH mptcp-next v9 1/3] mptcp: add subflows array in mptcp_sched_data Geliang Tang
2022-04-30  0:30   ` Mat Martineau [this message]
2022-04-29 14:51 ` [PATCH mptcp-next v9 2/3] selftests: bpf: add bpf_rr scheduler Geliang Tang
2022-04-30  0:28   ` Mat Martineau
2022-04-29 14:51 ` [PATCH mptcp-next v9 3/3] selftests: bpf: add bpf_rr test Geliang Tang

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=27dd2036-b1e0-95bb-19c5-6b8519a44f81@linux.intel.com \
    --to=mathew.j.martineau@linux.intel.com \
    --cc=geliang.tang@suse.com \
    --cc=mptcp@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox