All of lore.kernel.org
 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 v17 6/8] mptcp: add last_snd write access
Date: Fri, 29 Apr 2022 17:22:33 -0700 (PDT)	[thread overview]
Message-ID: <b954e32b-f0e3-4725-b755-66e5831adcee@linux.intel.com> (raw)
In-Reply-To: <60a9490aa49e64c1db357ad2096d321d7c54713a.1651123078.git.geliang.tang@suse.com>

On Thu, 28 Apr 2022, Geliang Tang wrote:

> This patch exports the member last_snd of struct mptcp_sock in
> bpf_mptcp_helpers.h, and adds BPF write access to it.
>

I still think we should stay away from giving the BPF functions write 
access to the msk unless it's really necessary.

In this case, both of the example schedulers write identical values to 
msk->last_snd and data->sock. Will they ever be different? Seems better to 
keep it simple for the BPF code and have the get_subflow wrappers handle 
assigning to msk->last_snd if a BPF function was called, and let the 
built-in scheduler assign last_snd itself.

- Mat

> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> net/mptcp/bpf.c                                 | 15 ++++++++++++---
> tools/testing/selftests/bpf/bpf_mptcp_helpers.h |  1 +
> 2 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c
> index a085c72fe695..300493f9a2b6 100644
> --- a/net/mptcp/bpf.c
> +++ b/net/mptcp/bpf.c
> @@ -18,8 +18,8 @@
> #ifdef CONFIG_BPF_JIT
> extern struct bpf_struct_ops bpf_mptcp_sched_ops;
> extern struct btf *btf_vmlinux;
> -static const struct btf_type *mptcp_sched_type __read_mostly;
> -static u32 mptcp_sched_id;
> +static const struct btf_type *mptcp_sock_type, *mptcp_sched_type __read_mostly;
> +static u32 mptcp_sock_id, mptcp_sched_id;
>
> static u32 optional_ops[] = {
> 	offsetof(struct mptcp_sched_ops, init),
> @@ -47,12 +47,15 @@ static int bpf_mptcp_sched_btf_struct_access(struct bpf_verifier_log *log,
> 		return btf_struct_access(log, btf, t, off, size, atype,
> 					 next_btf_id, flag);
>
> -	if (t != mptcp_sched_type) {
> +	if (t != mptcp_sock_type && t != mptcp_sched_type) {
> 		bpf_log(log, "only access to mptcp_sched is supported\n");
> 		return -EACCES;
> 	}
>
> 	switch (off) {
> +	case offsetof(struct mptcp_sock, last_snd):
> +		end = offsetofend(struct mptcp_sock, last_snd);
> +		break;
> 	case offsetof(struct mptcp_sched_data, sock):
> 		end = offsetofend(struct mptcp_sched_data, sock);
> 		break;
> @@ -145,6 +148,12 @@ static int bpf_mptcp_sched_init(struct btf *btf)
> {
> 	s32 type_id;
>
> +	type_id = btf_find_by_name_kind(btf, "mptcp_sock", BTF_KIND_STRUCT);
> +	if (type_id < 0)
> +		return -EINVAL;
> +	mptcp_sock_id = type_id;
> +	mptcp_sock_type = btf_type_by_id(btf, mptcp_sock_id);
> +
> 	type_id = btf_find_by_name_kind(btf, "mptcp_sched_data",
> 					BTF_KIND_STRUCT);
> 	if (type_id < 0)
> diff --git a/tools/testing/selftests/bpf/bpf_mptcp_helpers.h b/tools/testing/selftests/bpf/bpf_mptcp_helpers.h
> index a0b83fbe8133..79a16636400b 100644
> --- a/tools/testing/selftests/bpf/bpf_mptcp_helpers.h
> +++ b/tools/testing/selftests/bpf/bpf_mptcp_helpers.h
> @@ -27,6 +27,7 @@ struct mptcp_sched_ops {
> struct mptcp_sock {
> 	struct inet_connection_sock	sk;
>
> +	struct sock	*last_snd;
> 	__u32		token;
> 	struct sock	*first;
> 	struct mptcp_sched_ops *sched;
> -- 
> 2.34.1
>
>
>

--
Mat Martineau
Intel

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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28  5:23 [PATCH mptcp-next v17 0/8] BPF packet scheduler Geliang Tang
2022-04-28  5:23 ` [PATCH mptcp-next v17 1/8] mptcp: add struct mptcp_sched_ops Geliang Tang
2022-04-28  5:23 ` [PATCH mptcp-next v17 2/8] mptcp: add a new sysctl scheduler Geliang Tang
2022-04-28  5:23 ` [PATCH mptcp-next v17 3/8] mptcp: add sched in mptcp_sock Geliang Tang
2022-04-28  5:23 ` [PATCH mptcp-next v17 4/8] mptcp: add get_subflow wrappers Geliang Tang
2022-04-30  0:03   ` Mat Martineau
2022-04-28  5:23 ` [PATCH mptcp-next v17 5/8] mptcp: add bpf_mptcp_sched_ops Geliang Tang
2022-04-28  5:23 ` [PATCH mptcp-next v17 6/8] mptcp: add last_snd write access Geliang Tang
2022-04-30  0:22   ` Mat Martineau [this message]
2022-04-28  5:23 ` [PATCH mptcp-next v17 7/8] selftests: bpf: add bpf_first scheduler Geliang Tang
2022-04-28  5:23 ` [PATCH mptcp-next v17 8/8] selftests: bpf: add bpf_first test Geliang Tang
2022-04-28  6:52   ` selftests: bpf: add bpf_first test: Tests Results MPTCP CI

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=b954e32b-f0e3-4725-b755-66e5831adcee@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 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.