MPTCP Linux Development
 help / color / mirror / Atom feed
From: Mat Martineau <martineau@kernel.org>
To: Geliang Tang <geliang@kernel.org>
Cc: mptcp@lists.linux.dev, Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH mptcp-net 2/4] mptcp: add needs_id for netlink appending addr
Date: Mon, 5 Feb 2024 17:28:49 -0800 (PST)	[thread overview]
Message-ID: <8d1fa3bc-b591-0820-82b0-61a3efa340ea@kernel.org> (raw)
In-Reply-To: <1d1970ac75aa9b924f1da17c3c89dcba96e5bb46.1706759413.git.tanggeliang@kylinos.cn>

On Thu, 1 Feb 2024, Geliang Tang wrote:

> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> Just the same as userspace PM, a new parameter needs_id is added for
> in-kernel PM mptcp_pm_nl_append_new_local_addr() too.
>
> Add a new helper mptcp_pm_has_addr_attr_id() to check whether an address
> ID is set from PM or not. It will be used in the next two commits.
>
> In mptcp_pm_nl_get_local_id(), needs_id is always true, but in
> mptcp_pm_nl_add_addr_doit(), pass mptcp_pm_has_addr_attr_id() to
> needs_it.
>
> Fixes: fd5a4c04e18 ("mptcp: add the address ID assignment bitmap")
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>

Reviewed-by: Mat Martineau <martineau@kernel.org>

> ---
> net/mptcp/pm_netlink.c | 24 +++++++++++++++++++-----
> 1 file changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index d9ad45959219..9367ab506908 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -901,7 +901,8 @@ static void __mptcp_pm_release_addr_entry(struct mptcp_pm_addr_entry *entry)
> }
>
> static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
> -					     struct mptcp_pm_addr_entry *entry)
> +					     struct mptcp_pm_addr_entry *entry,
> +					     bool needs_id)
> {
> 	struct mptcp_pm_addr_entry *cur, *del_entry = NULL;
> 	unsigned int addr_max;
> @@ -949,7 +950,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
> 		}
> 	}
>
> -	if (!entry->addr.id) {
> +	if (!entry->addr.id && needs_id) {
> find_next:
> 		entry->addr.id = find_next_zero_bit(pernet->id_bitmap,
> 						    MPTCP_PM_MAX_ADDR_ID + 1,
> @@ -960,7 +961,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
> 		}
> 	}
>
> -	if (!entry->addr.id)
> +	if (!entry->addr.id && needs_id)
> 		goto out;
>
> 	__set_bit(entry->addr.id, pernet->id_bitmap);
> @@ -1092,7 +1093,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc
> 	entry->ifindex = 0;
> 	entry->flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
> 	entry->lsk = NULL;
> -	ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
> +	ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true);
> 	if (ret < 0)
> 		kfree(entry);
>
> @@ -1285,6 +1286,18 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct net *net)
> 	return 0;
> }
>
> +static bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr,
> +				      struct genl_info *info)
> +{
> +	struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX + 1];
> +
> +	if (!nla_parse_nested_deprecated(tb, MPTCP_PM_ADDR_ATTR_MAX, attr,
> +					 mptcp_pm_address_nl_policy, info->extack) &&
> +	    tb[MPTCP_PM_ADDR_ATTR_ID])
> +		return true;
> +	return false;
> +}
> +
> int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
> {
> 	struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR];
> @@ -1326,7 +1339,8 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
> 			goto out_free;
> 		}
> 	}
> -	ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
> +	ret = mptcp_pm_nl_append_new_local_addr(pernet, entry,
> +						!mptcp_pm_has_addr_attr_id(attr, info));
> 	if (ret < 0) {
> 		GENL_SET_ERR_MSG_FMT(info, "too many addresses or duplicate one: %d", ret);
> 		goto out_free;
> -- 
> 2.40.1
>
>
>

  parent reply	other threads:[~2024-02-06  1:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01  3:51 [PATCH mptcp-net 0/4] fixes for userspace PM Geliang Tang
2024-02-01  3:51 ` [PATCH mptcp-net 1/4] mptcp: add needs_id for userspace appending addr Geliang Tang
2024-02-06  1:28   ` Mat Martineau
2024-02-01  3:51 ` [PATCH mptcp-net 2/4] mptcp: add needs_id for netlink " Geliang Tang
2024-02-01  5:35   ` Geliang Tang
2024-02-08  9:37     ` Matthieu Baerts
2024-02-06  1:28   ` Mat Martineau [this message]
2024-02-01  3:51 ` [PATCH mptcp-net 3/4] mptcp: map v4 address to v6 when destroying subflow Geliang Tang
2024-02-01  3:51 ` [PATCH mptcp-net 4/4] selftests: mptcp: rm subflow with v4/v4mapped addr Geliang Tang
2024-02-01  4:40   ` selftests: mptcp: rm subflow with v4/v4mapped addr: Tests Results MPTCP CI
2024-02-01  5:01   ` MPTCP CI
2024-02-06  1:40   ` [PATCH mptcp-net 4/4] selftests: mptcp: rm subflow with v4/v4mapped addr Mat Martineau
2024-02-06  5:47     ` Geliang Tang
2024-02-06  2:21   ` selftests: mptcp: rm subflow with v4/v4mapped addr: Tests Results MPTCP CI
2024-02-06  2:38   ` 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=8d1fa3bc-b591-0820-82b0-61a3efa340ea@kernel.org \
    --to=martineau@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