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 v8 03/12] mptcp: sysctl: map pm_type to path_manager
Date: Wed, 5 Mar 2025 12:45:02 +0100 [thread overview]
Message-ID: <e9146447-a0b4-40c1-95f8-2d54dba0158d@kernel.org> (raw)
In-Reply-To: <4edb40bf773e65c00d4447f4795cec26f9a047a3.1741088339.git.tanggeliang@kylinos.cn>
Hi Geliang,
On 04/03/2025 12:40, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> This patch adds a new proc_handler "proc_pm_type" for "pm_type" to
> map old path manager sysctl "pm_type" to the newly added "path_manager".
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> net/mptcp/ctrl.c | 28 +++++++++++++++++++++++++++-
> 1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
> index d64e6b4f6d1d..d425fcbd036a 100644
> --- a/net/mptcp/ctrl.c
> +++ b/net/mptcp/ctrl.c
> @@ -217,6 +217,32 @@ static int proc_path_manager(const struct ctl_table *ctl, int write,
> return ret;
> }
>
> +static int proc_pm_type(const struct ctl_table *ctl, int write,
> + void *buffer, size_t *lenp, loff_t *ppos)
> +{
> + struct mptcp_pernet *pernet = container_of(ctl->data,
> + struct mptcp_pernet,
> + pm_type);
> + u8 pm_type = READ_ONCE(*(u8 *)ctl->data);
> + const struct ctl_table tbl = {
> + .maxlen = sizeof(pm_type),
> + .data = &pm_type,
> + };
> + int ret;
> +
> + ret = proc_dou8vec_minmax(&tbl, write, buffer, lenp, ppos);
I missed that in my previous review. Do you need tbl here? Can you not
use "ctl" here instead? If you need tbl, you will need to move the
"extra[12]" fields there I suppose, otherwise the limits will not be
checked, no?
In the proc_handler, a new ctl_table structure is needed when it is
required to have a way to prevent the writing of the data after having
called proc_do(...). Here, that's not the case: if the new value is
between 0 and mptcp_pm_type_max, we will always write ctl->data.
In other words, I think you can remove tlb, use ctl instead, and remove
the 'WRITE_ONCE(*(u8 *)ctl->data, pm_type)' here below.
> + if (write && ret == 0) {
> + char *path_manager = "kernel";
> +
> + if (pm_type == MPTCP_PM_TYPE_USERSPACE)
pm_type should be read here in the 'if' statement, after having
potentially be modified in proc_dou8vec_minmax(). Or use "buffer" directly.
> + path_manager = "userspace";
> + mptcp_set_path_manager(pernet->path_manager, path_manager);
> + WRITE_ONCE(*(u8 *)ctl->data, pm_type);
> + }
> +
> + return ret;
> +}
> +
> static struct ctl_table mptcp_sysctl_table[] = {
> {
> .procname = "enabled",
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2025-03-05 11:45 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 11:40 [PATCH mptcp-next v8 00/12] BPF path manager, part 5 Geliang Tang
2025-03-04 11:40 ` [PATCH mptcp-next v8 01/12] mptcp: pm: define struct mptcp_pm_ops Geliang Tang
2025-03-05 11:42 ` Matthieu Baerts
2025-03-04 11:40 ` [PATCH mptcp-next v8 02/12] mptcp: sysctl: new sysctl to set path manager by name Geliang Tang
2025-03-04 11:40 ` [PATCH mptcp-next v8 03/12] mptcp: sysctl: map pm_type to path_manager Geliang Tang
2025-03-05 11:45 ` Matthieu Baerts [this message]
2025-03-04 11:40 ` [PATCH mptcp-next v8 04/12] mptcp: sysctl: map path_manager to pm_type Geliang Tang
2025-03-05 11:48 ` Matthieu Baerts
2025-03-04 11:40 ` [PATCH mptcp-next v8 05/12] mptcp: sysctl: add available_path_managers Geliang Tang
2025-03-04 11:40 ` [PATCH mptcp-next v8 06/12] mptcp: pm: in-kernel: register mptcp_pm_kernel Geliang Tang
2025-03-05 1:35 ` Geliang Tang
2025-03-05 9:11 ` Matthieu Baerts
2025-03-05 9:14 ` Geliang Tang
2025-03-05 9:22 ` Matthieu Baerts
2025-03-05 9:29 ` Geliang Tang
2025-03-05 11:51 ` Matthieu Baerts
2025-03-06 11:09 ` Geliang Tang
2025-03-06 11:27 ` Matthieu Baerts
2025-03-04 11:40 ` [PATCH mptcp-next v8 07/12] mptcp: pm: userspace: register mptcp_pm_userspace Geliang Tang
2025-03-05 11:53 ` Matthieu Baerts
2025-03-04 11:40 ` [PATCH mptcp-next v8 08/12] mptcp: pm: initialize and release mptcp_pm_ops Geliang Tang
2025-03-05 11:57 ` Matthieu Baerts
2025-03-04 11:40 ` [PATCH mptcp-next v8 09/12] mptcp: pm: add get_local_id() interface Geliang Tang
2025-03-04 11:40 ` [PATCH mptcp-next v8 10/12] mptcp: pm: add get_priority() interface Geliang Tang
2025-03-04 11:40 ` [PATCH mptcp-next v8 11/12] selftests: mptcp: add pm_type mapping tests Geliang Tang
2025-03-05 11:58 ` Matthieu Baerts
2025-03-04 11:40 ` [PATCH mptcp-next v8 12/12] selftests: mptcp: add path_manager sysctl test Geliang Tang
2025-03-05 11:59 ` Matthieu Baerts
2025-03-05 11:41 ` [PATCH mptcp-next v8 00/12] BPF path manager, part 5 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=e9146447-a0b4-40c1-95f8-2d54dba0158d@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.