MPTCP Linux Development
 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 v7 06/11] mptcp: drop info of userspace_pm_remove_id_zero_address
Date: Mon, 6 Jan 2025 10:48:20 +0100	[thread overview]
Message-ID: <72e4b271-3d16-419a-a4ba-94fb027deac2@kernel.org> (raw)
In-Reply-To: <ee4732a33038d9d16df114dd278278112219c5ca.1736150983.git.tanggeliang@kylinos.cn>



On 06/01/2025 09:16, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The only use of 'info' parameter of userspace_pm_remove_id_zero_address()
> is to set an error message into it.

Can you add:

Plus, this helper will only fail when it cannot find any subflows with a
local address ID 0.

(Because if there were different types of errors, you could not drop
'info').

> 
> This patch drops this parameter and sets the error message where this
> function is called in mptcp_pm_nl_remove_doit().
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  net/mptcp/pm_userspace.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index 0f703e06d771..a6580942e628 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -259,8 +259,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)
>  	return err;
>  }
>  
> -static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk,
> -						     struct genl_info *info)
> +static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk)
>  {
>  	struct mptcp_rm_list list = { .nr = 0 };
>  	struct mptcp_subflow_context *subflow;
> @@ -275,10 +274,8 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk,
>  			break;
>  		}
>  	}
> -	if (!has_id_0) {
> -		GENL_SET_ERR_MSG(info, "address with id 0 not found");
> +	if (!has_id_0)
>  		goto remove_err;
> -	}
>  
>  	list.ids[list.nr++] = 0;
>  
> @@ -336,7 +333,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
>  	sk = (struct sock *)msk;
>  
>  	if (id_val == 0) {
> -		err = mptcp_userspace_pm_remove_id_zero_address(msk, info);
> +		err = mptcp_userspace_pm_remove_id_zero_address(msk);
>  		goto out;
>  	}
>  
> @@ -345,7 +342,6 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
>  	spin_lock_bh(&msk->pm.lock);
>  	match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val);
>  	if (!match) {
> -		GENL_SET_ERR_MSG(info, "address with specified id not found");
>  		spin_unlock_bh(&msk->pm.lock);
>  		release_sock(sk);
>  		goto out;
> @@ -362,6 +358,11 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
>  
>  	err = 0;
>  out:
> +	if (err)
> +		GENL_SET_ERR_MSG_FMT(info,

Can you not use NL_SET_ERR_MSG_ATTR_FMT() here?

> +				     "address with id %u not found",
> +				     id_val);

Detail: in fact, I don't think it is needed to specify the ID in the
error message to send to the userspace: the ID has been specified by the
userspace, it knows what it has set. Up to you.

> +
>  	sock_put(sk);
>  	return err;
>  }

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


  reply	other threads:[~2025-01-06  9:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06  8:16 [PATCH mptcp-next v7 00/11] mptcp: use GENL_REQ_ATTR_CHECK in userspace pm Geliang Tang
2025-01-06  8:16 ` [PATCH mptcp-next v7 01/11] mptcp: pm: more precise error messages Geliang Tang
2025-01-06  9:17   ` Matthieu Baerts
2025-01-06  8:16 ` [PATCH mptcp-next v7 02/11] mptcp: userspace pm set_flags id support Geliang Tang
2025-01-06  9:31   ` Matthieu Baerts
2025-01-06  8:16 ` [PATCH mptcp-next v7 03/11] mptcp: drop skb parameter of set_flags Geliang Tang
2025-01-06  8:16 ` [PATCH mptcp-next v7 04/11] mptcp: change rem type " Geliang Tang
2025-01-06  8:16 ` [PATCH mptcp-next v7 05/11] mptcp: add local & remote parameters for set_flags Geliang Tang
2025-01-06  9:39   ` Matthieu Baerts
2025-01-06 10:01     ` Matthieu Baerts
2025-01-06  8:16 ` [PATCH mptcp-next v7 06/11] mptcp: drop info of userspace_pm_remove_id_zero_address Geliang Tang
2025-01-06  9:48   ` Matthieu Baerts [this message]
2025-01-06  8:16 ` [PATCH mptcp-next v7 07/11] mptcp: pm: use NL_SET_ERR_MSG_ATTR when possible Geliang Tang
2025-01-06  9:04   ` Matthieu Baerts
2025-01-06  8:16 ` [PATCH mptcp-next v7 08/11] mptcp: pm: improve error messages Geliang Tang
2025-01-06  9:55   ` Matthieu Baerts
2025-01-06  8:16 ` [PATCH mptcp-next v7 09/11] mptcp: pm: userspace: use GENL_REQ_ATTR_CHECK Geliang Tang
2025-01-06  8:16 ` [PATCH mptcp-next v7 10/11] mptcp: pm: remove duplicated error messages Geliang Tang
2025-01-06  8:16 ` [PATCH mptcp-next v7 11/11] mptcp: pm: mark missing address attributes Geliang Tang
2025-01-06  9:20 ` [PATCH mptcp-next v7 00/11] mptcp: use GENL_REQ_ATTR_CHECK in userspace pm 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=72e4b271-3d16-419a-a4ba-94fb027deac2@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox