All of lore.kernel.org
 help / color / mirror / Atom feed
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 v10 09/12] mptcp: sysctl: map path_manager to pm_type
Date: Tue, 11 Mar 2025 00:19:30 +0100	[thread overview]
Message-ID: <d3133a7a-110d-49a7-93eb-b49c49c765bc@kernel.org> (raw)
In-Reply-To: <a38a4f3b6cc2ac7082401a22bc33eb0d844f0b37.1741258415.git.tanggeliang@kylinos.cn>

Hi Geliang,

On 06/03/2025 12:01, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> This patch maps the newly added path manager sysctl "path_manager"
> to the old one "pm_type".
> 
> 	path_manager   pm_type
> 
> 	"kernel"    -> MPTCP_PM_TYPE_KERNEL
> 	"userspace" -> MPTCP_PM_TYPE_USERSPACE
> 	others      -> __MPTCP_PM_TYPE_NR
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  net/mptcp/ctrl.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
> index 1f405be6bc00..6a35e6bb0a63 100644
> --- a/net/mptcp/ctrl.c
> +++ b/net/mptcp/ctrl.c
> @@ -200,6 +200,9 @@ static int mptcp_set_path_manager(char *path_manager, const char *name)
>  static int proc_path_manager(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,
> +						   path_manager);
>  	char (*path_manager)[MPTCP_PM_NAME_MAX] = ctl->data;
>  	char pm_name[MPTCP_PM_NAME_MAX];
>  	const struct ctl_table tbl = {
> @@ -211,8 +214,16 @@ static int proc_path_manager(const struct ctl_table *ctl, int write,
>  	strscpy(pm_name, *path_manager, MPTCP_PM_NAME_MAX);
>  
>  	ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
> -	if (write && ret == 0)
> +	if (write && ret == 0) {
> +		u8 pm_type = __MPTCP_PM_TYPE_NR;
> +
> +		if (strncmp(pm_name, "kernel", MPTCP_PM_NAME_MAX) == 0)
> +			pm_type = MPTCP_PM_TYPE_KERNEL;
> +		else if (strncmp(pm_name, "userspace", MPTCP_PM_NAME_MAX) == 0)
> +			pm_type = MPTCP_PM_TYPE_USERSPACE;
> +		pernet->pm_type = pm_type;

This should be done after mptcp_set_path_manager(), and if there were no
errors (ret == 0), because if the name is not valid, the path-manager
will not be modified, so pm_type should not be modified as well.

BTW, did you check that setting "pm_type = __MPTCP_PM_TYPE_NR" is OK?
Can we display 2, but not allow to set 2 for pm_type here? In other
words, please check that this is OK with your modifications:

  # sysctl net.mptcp.pm_type=2
  sysctl: setting key "net.mptcp.pm_type": Invalid argument
  # sysctl -q net.mptcp.path_manager = "$BPF_PM"
  # sysctl -n net.mptcp.pm_type
  2

>  		ret = mptcp_set_path_manager(*path_manager, pm_name);
> +	}
>  
>  	return ret;
>  }
Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


  reply	other threads:[~2025-03-10 23:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06 11:01 [PATCH mptcp-next v10 00/12] BPF path manager, part 5 Geliang Tang
2025-03-06 11:01 ` [PATCH mptcp-next v10 01/12] mptcp: pm: define struct mptcp_pm_ops Geliang Tang
2025-03-06 11:01 ` [PATCH mptcp-next v10 02/12] mptcp: pm: register in-kernel and userspace PM Geliang Tang
2025-03-06 11:01 ` [PATCH mptcp-next v10 03/12] mptcp: sysctl: set path manager by name Geliang Tang
2025-03-06 11:01 ` [PATCH mptcp-next v10 04/12] mptcp: add struct_group in mptcp_pm_data Geliang Tang
2025-03-10 23:17   ` Matthieu Baerts
2025-03-11  4:24     ` Geliang Tang
2025-03-11  8:53       ` Matthieu Baerts
2025-03-06 11:01 ` [PATCH mptcp-next v10 05/12] mptcp: pm: init and release mptcp_pm_ops Geliang Tang
2025-03-10 23:18   ` Matthieu Baerts
2025-03-06 11:01 ` [PATCH mptcp-next v10 06/12] mptcp: pm: add get_local_id() interface Geliang Tang
2025-03-06 11:01 ` [PATCH mptcp-next v10 07/12] mptcp: pm: add get_priority() interface Geliang Tang
2025-03-06 11:01 ` [PATCH mptcp-next v10 08/12] mptcp: pm: validate mandatory ops Geliang Tang
2025-03-10 23:18   ` Matthieu Baerts
2025-03-06 11:01 ` [PATCH mptcp-next v10 09/12] mptcp: sysctl: map path_manager to pm_type Geliang Tang
2025-03-10 23:19   ` Matthieu Baerts [this message]
2025-03-11  4:29     ` Geliang Tang
2025-03-06 11:01 ` [PATCH mptcp-next v10 10/12] mptcp: sysctl: map pm_type to path_manager Geliang Tang
2025-03-10 23:19   ` Matthieu Baerts
2025-03-06 11:01 ` [PATCH mptcp-next v10 11/12] mptcp: sysctl: add available_path_managers Geliang Tang
2025-03-06 11:01 ` [PATCH mptcp-next v10 12/12] selftests: mptcp: add path_manager sysctl tests Geliang Tang
2025-03-10 23:25   ` Matthieu Baerts
2025-03-11  6:54     ` Geliang Tang
2025-03-06 12:05 ` BPF path manager, part 5 MPTCP CI
2025-03-10 23:16 ` [PATCH mptcp-next v10 00/12] " 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=d3133a7a-110d-49a7-93eb-b49c49c765bc@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.