From: Matthieu Baerts <matttbe@kernel.org>
To: Geliang Tang <geliang@kernel.org>, mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH mptcp-next v5 1/9] mptcp: pm: use addr entry for get_local_id
Date: Fri, 21 Feb 2025 18:23:08 +0100 [thread overview]
Message-ID: <0cc8475a-248e-4a07-93db-7381199c4eaa@kernel.org> (raw)
In-Reply-To: <aebbbe7e861ff37a7f5225e8cccda396c56011ea.1740019794.git.tanggeliang@kylinos.cn>
Hi Geliang,
On 20/02/2025 03:57, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> The following code in mptcp_userspace_pm_get_local_id() that assigns "skc"
> to "new_entry" is not allowed in BPF if we use the same code to implement
> the get_local_id() interface of a BFP path manager:
>
> memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry));
> new_entry.addr = *skc;
> new_entry.addr.id = 0;
> new_entry.flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
>
> To solve the issue, this patch moves this assignment to "new_entry" forward
> to mptcp_pm_get_local_id(), and then passing "new_entry" as a parameter to
> both mptcp_pm_nl_get_local_id() and mptcp_userspace_pm_get_local_id().
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> net/mptcp/pm.c | 11 ++++++++---
> net/mptcp/pm_netlink.c | 9 ++++-----
> net/mptcp/pm_userspace.c | 17 ++++++-----------
> net/mptcp/protocol.h | 6 ++++--
> 4 files changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
> index 16cacce6c10f..94620ab172b7 100644
> --- a/net/mptcp/pm.c
> +++ b/net/mptcp/pm.c
> @@ -403,20 +403,25 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
>
> int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
> {
> - struct mptcp_addr_info skc_local;
> + struct mptcp_pm_addr_entry skc_local;
> struct mptcp_addr_info msk_local;
>
> if (WARN_ON_ONCE(!msk))
> return -1;
>
> + memset(&skc_local, 0, sizeof(struct mptcp_pm_addr_entry));
Detail: do we need memset? Can you not initialise it to 0 instead?
struct mptcp_pm_addr_entry skc_local = { 0 };
> +
> /* The 0 ID mapping is defined by the first subflow, copied into the msk
> * addr
> */
> mptcp_local_address((struct sock_common *)msk, &msk_local);
> - mptcp_local_address((struct sock_common *)skc, &skc_local);
> - if (mptcp_addresses_equal(&msk_local, &skc_local, false))
> + mptcp_local_address((struct sock_common *)skc, &skc_local.addr);
> + if (mptcp_addresses_equal(&msk_local, &skc_local.addr, false))
> return 0;
>
> + skc_local.addr.id = 0;
> + skc_local.flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
> +
> if (mptcp_pm_is_userspace(msk))
> return mptcp_userspace_pm_get_local_id(msk, &skc_local);
> return mptcp_pm_nl_get_local_id(msk, &skc_local);
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index d4328443d844..0a0fe890c53d 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
(...)
> @@ -1159,11 +1160,9 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc
> if (!entry)
> return -ENOMEM;
>
> - entry->addr = *skc;
> - entry->addr.id = 0;
> + *entry = *skc;
> entry->addr.port = 0;
> entry->ifindex = 0;
> - entry->flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
> entry->lsk = NULL;
Small detail: is it still needed to reset all these info (except the
port number)?
If I'm not mistaken, now all the "entry" should be set to 0, no?
> ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true);
> if (ret < 0)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2025-02-21 17:23 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 2:57 [PATCH mptcp-next v5 0/9] BPF path manager, part 4 Geliang Tang
2025-02-20 2:57 ` [PATCH mptcp-next v5 1/9] mptcp: pm: use addr entry for get_local_id Geliang Tang
2025-02-21 17:23 ` Matthieu Baerts [this message]
2025-02-20 2:57 ` [PATCH mptcp-next v5 2/9] mptcp: pm: add struct mptcp_pm_param Geliang Tang
2025-02-21 17:23 ` Matthieu Baerts
2025-02-20 2:57 ` [PATCH mptcp-next v5 3/9] mptcp: pm: pass pm_param to get_local_id Geliang Tang
2025-02-20 2:57 ` [PATCH mptcp-next v5 4/9] mptcp: pm: define struct mptcp_pm_ops Geliang Tang
2025-02-21 17:23 ` Matthieu Baerts
2025-02-24 6:54 ` Geliang Tang
2025-02-24 8:26 ` Matthieu Baerts
2025-02-24 9:11 ` Geliang Tang
2025-02-24 10:24 ` Matthieu Baerts
2025-02-20 2:57 ` [PATCH mptcp-next v5 5/9] mptcp: pm: in-kernel: register mptcp_netlink_pm Geliang Tang
2025-02-20 2:57 ` [PATCH mptcp-next v5 6/9] mptcp: pm: userspace: register mptcp_userspace_pm Geliang Tang
2025-02-20 2:57 ` [PATCH mptcp-next v5 7/9] mptcp: pm: initialize and release mptcp_pm_ops Geliang Tang
2025-02-20 2:57 ` [PATCH mptcp-next v5 8/9] mptcp: pm: drop get_local_id helpers Geliang Tang
2025-02-21 17:23 ` Matthieu Baerts
2025-02-20 2:57 ` [PATCH mptcp-next v5 9/9] mptcp: pm: drop is_backup helpers Geliang Tang
2025-02-20 4:12 ` [PATCH mptcp-next v5 0/9] BPF path manager, part 4 MPTCP CI
2025-02-21 17:23 ` Matthieu Baerts
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=0cc8475a-248e-4a07-93db-7381199c4eaa@kernel.org \
--to=matttbe@kernel.org \
--cc=geliang@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 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.