MPTCP Linux Development
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: Matthieu Baerts <matttbe@kernel.org>, mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH mptcp-next v2 23/36] mptcp: drop struct mptcp_pm_local
Date: Thu, 07 Nov 2024 15:29:05 +0800	[thread overview]
Message-ID: <a77c02db831525e2e1ec5371aaea4b9869441c0b.camel@kernel.org> (raw)
In-Reply-To: <4661b240-9a9c-47c2-9dc0-362d22baad83@kernel.org>

Hi Matt,

On Mon, 2024-11-04 at 20:08 +0100, Matthieu Baerts wrote:
> Hi Geliang,
> 
> On 22/10/2024 11:14, Geliang Tang wrote:
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> > 
> > The following code in mptcp_pm_nl_subflow_create_doit() that
> > assigns struct
> > mptcp_pm_addr_entry "entry" to the local struct mptcp_pm_local
> > variable
> > "local" is not allowed in BPF if we use the same code to implement
> > the
> > subflow_create() interface of a BFP path manager:
> > 
> > 	struct mptcp_pm_local local;
> > 
> > 	local.addr = entry.addr;
> > 	local.flags = entry.flags;
> > 	local.ifindex = entry.ifindex;
> 
> Here as well, I'm not sure to understand the issue. Is it because you
> cannot allocate this structure locally with BPF? No alternatives?

Here "struct mptcp_pm_local local" is a "scalar", when passing it to
__mptcp_subflow_connect(), this error occurs:

# ; err = __mptcp_subflow_connect(sk, &local, remote); @
mptcp_bpf_userspace_pm.c:242
# 53: (bf) r1 = r6                      ; R1_w=trusted_ptr_mptcp_sock()
R6=trusted_ptr_mptcp_sock()
# 54: (bf) r3 = r8                      ;
R3_w=trusted_ptr_mptcp_addr_info() R8=trusted_ptr_mptcp_addr_info()
# 55: (85) call __mptcp_subflow_connect#34404
# max struct nesting depth exceeded
# arg#1 pointer type STRUCT mptcp_pm_local must point to scalar, or
struct with scalar

Also, assigning an address to an address like this is not allowed in
BPF:

	local.addr = entry.addr;

> 
> > We should avoid this type of assignment from struct
> > mptcp_pm_addr_entry to
> > struct mptcp_pm_local.
> > 
> > In fact, there is no need to add a dedicated address entry type for
> > local
> > address entry. All its fields are the same as struct
> > mptcp_pm_addr_entry,
> > except that it lacks a "lsk" for the listening socket. So we can
> > use struct
> > mptcp_pm_addr_entry directly. This makes the path manager code
> > simpler.
> 
> There was a need for this structure, see this discussion:
> 
> 
> https://lore.kernel.org/mptcp/587e096f-0e76-40fd-9220-6d8dd2930838@redhat.com/
> 
> and the changelog in v5:
> 
> 
> https://lore.kernel.org/mptcp/20240726-mptcp-pm-avail-v5-13-fb1117ddeef6@kernel.org/
> 
> In short ...
> 
> > 
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > ---
> >  net/mptcp/pm_netlink.c   | 22 ++++++++--------------
> >  net/mptcp/pm_userspace.c |  7 +------
> >  net/mptcp/protocol.h     |  8 +-------
> >  net/mptcp/subflow.c      |  2 +-
> >  4 files changed, 11 insertions(+), 28 deletions(-)
> > 
> > diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> > index 287e715bcf68..15f97e7af182 100644
> > --- a/net/mptcp/pm_netlink.c
> > +++ b/net/mptcp/pm_netlink.c
> 
> (...)
> 
> > @@ -721,7 +715,7 @@ static unsigned int
> > fill_local_addresses_vec(struct mptcp_sock *msk,
> >  
> >  static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
> >  {
> > -	struct mptcp_pm_local locals[MPTCP_PM_ADDR_MAX];
> > +	struct mptcp_pm_addr_entry locals[MPTCP_PM_ADDR_MAX];
> 
> ... we don't want that: that's reserving too much memory, and we
> don't
> need half of it.

Thanks for your information.

> 
> *If* it is really needed to change it for BPF (I'm surprised there
> are
> no alternatives), then maybe we can change the signature of
> __mptcp_subflow_connect(), but not change the code here.
> 
> In this case, only one "struct mptcp_pm_addr_entry" will be needed,
> and
> the "struct mptcp_pm_local" can be defined in this pm_netlink.c file
> if
> it is only used here.
> 
> But please mention that in the commit message.

I updated it in v3 as you suggested.

Thanks,
-Geliang

> 
> >  	struct sock *sk = (struct sock *)msk;
> >  	unsigned int add_addr_accept_max;
> >  	struct mptcp_addr_info remote;
> (...)
> 
> Cheers,
> Matt


  reply	other threads:[~2024-11-07  7:29 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-22  9:14 [PATCH mptcp-next v2 00/36] BPF path manager Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 01/36] mptcp: drop else in mptcp_pm_addr_families_match Geliang Tang
2024-10-22 17:01   ` Matthieu Baerts
2024-10-23  9:53     ` Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 02/36] mptcp: use __lookup_addr in pm_netlink Geliang Tang
2024-10-22 17:09   ` Matthieu Baerts
2024-10-23  9:59     ` Geliang Tang
2024-10-23 10:03       ` Matthieu Baerts
2024-10-23 10:06         ` Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 03/36] mptcp: add mptcp_for_each_address macros Geliang Tang
2024-10-30 18:20   ` Matthieu Baerts
2024-10-31  7:55     ` Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 04/36] mptcp: use sock_kfree_s instead of kfree Geliang Tang
2024-10-30 18:21   ` Matthieu Baerts
2024-10-31  7:43     ` Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 05/36] mptcp: add lookup_addr for userspace pm Geliang Tang
2024-10-30 18:21   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 06/36] mptcp: add mptcp_userspace_pm_get_sock helper Geliang Tang
2024-10-30 18:23   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 07/36] mptcp: make three pm wrappers static Geliang Tang
2024-10-30 18:31   ` Matthieu Baerts
2024-10-31  7:58     ` Geliang Tang
2024-10-31 16:33       ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 08/36] mptcp: drop skb parameter of get_addr Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 09/36] mptcp: add id parameter for get_addr Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 10/36] mptcp: add addr " Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 11/36] mptcp: reuse sending nlmsg code in get_addr Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 12/36] mptcp: change info of get_addr as const Geliang Tang
2024-10-31 18:41   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 13/36] mptcp: add struct mptcp_id_bitmap Geliang Tang
2024-10-31 18:45   ` Matthieu Baerts
2024-11-04  9:12     ` Geliang Tang
2024-11-04 10:16       ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 14/36] mptcp: refactor dump_addr with id bitmap Geliang Tang
2024-11-04 17:18   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 15/36] mptcp: refactor dump_addr with get_addr Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 16/36] mptcp: reuse sending nlmsg code in dump_addr Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 17/36] mptcp: update local address flags when setting it Geliang Tang
2024-11-04 18:20   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 18/36] mptcp: change rem type of set_flags Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 19/36] mptcp: drop skb parameter " Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 20/36] mptcp: add loc and rem for set_flags Geliang Tang
2024-11-04 18:36   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 21/36] mptcp: update address type of get_local_id Geliang Tang
2024-11-04 18:48   ` Matthieu Baerts
2024-11-07  7:35     ` Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 22/36] mptcp: change is_backup interfaces as get_flags Geliang Tang
2024-11-04 18:55   ` Matthieu Baerts
2025-01-14  9:27     ` Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 23/36] mptcp: drop struct mptcp_pm_local Geliang Tang
2024-11-04 19:08   ` Matthieu Baerts
2024-11-07  7:29     ` Geliang Tang [this message]
2024-11-07 10:00       ` Matthieu Baerts
2024-11-07 10:19         ` Geliang Tang
2024-11-10  4:32           ` Geliang Tang
2024-11-27  6:17             ` Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 24/36] mptcp: drop struct mptcp_pm_add_entry Geliang Tang
2024-11-04 19:13   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 25/36] mptcp: change local type of subflow_destroy Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 26/36] mptcp: hold pm lock when deleting entry Geliang Tang
2024-11-04 19:17   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 27/36] mptcp: rename mptcp_pm_remove_addrs Geliang Tang
2024-11-04 19:24   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 28/36] mptcp: drop free_list for deleting entries Geliang Tang
2024-11-04 19:27   ` Matthieu Baerts
2024-10-22  9:14 ` [PATCH mptcp-next v2 29/36] mptcp: define struct mptcp_pm_ops Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 30/36] mptcp: implement userspace pm interfaces Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 31/36] mptcp: register default userspace pm Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 32/36] bpf: Add mptcp path manager struct_ops Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 33/36] bpf: Register mptcp struct_ops kfunc set Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 34/36] Squash to "bpf: Export mptcp packet scheduler helpers" Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 35/36] selftests/bpf: Add mptcp userspace pm subtest Geliang Tang
2024-10-22  9:14 ` [PATCH mptcp-next v2 36/36] selftests/bpf: Add mptcp bpf path manager subtest Geliang Tang
2024-10-22 10:12 ` [PATCH mptcp-next v2 00/36] BPF path manager MPTCP CI
2024-10-22 10:24 ` MPTCP CI
2024-11-04 19:31 ` Matthieu Baerts
2024-11-05 10:12   ` 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=a77c02db831525e2e1ec5371aaea4b9869441c0b.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=tanggeliang@kylinos.cn \
    /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