All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
	MPTCP Linux <mptcp@lists.linux.dev>
Subject: Re: [PATCH mptcp-net v3 3/8] mptcp: pm: userspace: ID0 is not part of local_addr_used
Date: Mon, 21 Sep 2026 18:37:41 +0800	[thread overview]
Message-ID: <6c672ec640f12ec6d3e4592b89dd91a955ab0581.camel@kernel.org> (raw)
In-Reply-To: <20260807-mptcp-pm-userspace-id0-case-v3-3-de9088549924@kernel.org>

Hi Matt,

On Fri, 2026-08-07 at 10:41 +0200, Matthieu Baerts (NGI0) wrote:
> The PM's local_addr_used counter doesn't take into account the ID0,
> similar to what is done with the in-kernel PM.
> 
> When deleting a local address, only decrement the counter if it is
> not
> linked to the (initial) ID0. Similarly, do not increment it when
> re-adding the exact same entry.
> 
> Fixes: 77e4b94a3de6 ("mptcp: update userspace pm infos")
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---
> v3:
>  - split from patch 1.
>  - do the same check when incrementing it to avoid a "leak".
> (Sashiko)
>  - use a new dedicated helper, clearer.
> ---
>  net/mptcp/pm_userspace.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index 3f1471ec3fc7..27fed3519d39 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -27,6 +27,12 @@ void
> mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk)
>  	}
>  }
>  
> +static bool
> +is_init_id0(struct mptcp_pm_addr_entry *entry)

nit: The function is quite short, so no line wrapping is needed.

Thanks,
-Geliang

> +{
> +	return entry->addr.id == 0 && entry->addr.port == 0;
> +}
> +
>  static struct mptcp_pm_addr_entry *
>  mptcp_userspace_pm_lookup_addr(struct mptcp_sock *msk,
>  			       const struct mptcp_addr_info *addr)
> @@ -95,7 +101,9 @@ static int
> mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
>  							MPTCP_PM_MAX
> _ADDR_ID + 1,
>  							1);
>  		list_add_tail_rcu(&e->list, &msk-
> >pm.userspace_pm_local_addr_list);
> -		msk->pm.local_addr_used++;
> +		/* Just to avoid this counter not to decrease when
> deleted */
> +		if (!is_init_id0(e))
> +			msk->pm.local_addr_used++;
>  		ret = e->addr.id;
>  	} else if (addr_match && id_match) {
>  		ret = entry->addr.id;
> @@ -121,12 +129,15 @@ static int
> mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk,
>  	if (!entry)
>  		return -EINVAL;
>  
> +	/* The initial address ID doesn't increment local_addr_used
> */
> +	if (!is_init_id0(entry))
> +		msk->pm.local_addr_used--;
> +
>  	/* TODO: a refcount is needed because the entry can
>  	 * be used multiple times (e.g. fullmesh mode).
>  	 */
>  	list_del_rcu(&entry->list);
>  	sock_kfree_s(sk, entry, sizeof(*entry));
> -	msk->pm.local_addr_used--;
>  	return 0;
>  }
>  

  reply	other threads:[~2026-09-21 10:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  8:41 [PATCH mptcp-net v3 0/8] mptcp: pm: userspace: properly deal with the ID0 case Matthieu Baerts (NGI0)
2026-08-07  8:41 ` [PATCH mptcp-net v3 1/8] mptcp: pm: userspace: properly handle " Matthieu Baerts (NGI0)
2026-08-07  8:41 ` [PATCH mptcp-net v3 2/8] mptcp: pm: userspace: lookup: match port in priority Matthieu Baerts (NGI0)
2026-08-19  7:23   ` Geliang Tang
2026-08-19  7:56     ` Matthieu Baerts
2026-08-30  4:43       ` Geliang Tang
2026-08-30 21:00         ` Matthieu Baerts
2026-09-21 10:20           ` Geliang Tang
2026-08-07  8:41 ` [PATCH mptcp-net v3 3/8] mptcp: pm: userspace: ID0 is not part of local_addr_used Matthieu Baerts (NGI0)
2026-09-21 10:37   ` Geliang Tang [this message]
2026-08-07  8:41 ` [PATCH mptcp-net v3 4/8] mptcp: pm: userspace: allow announcing ID0 addr Matthieu Baerts (NGI0)
2026-08-07  8:41 ` [PATCH mptcp-net v3 5/8] mptcp: pm: userspace: no ID0 exception for RM_ADDR Matthieu Baerts (NGI0)
2026-08-07  8:41 ` [PATCH mptcp-net v3 6/8] mptcp: pm: userspace: don't dump initial ID0 Matthieu Baerts (NGI0)
2026-08-07  8:41 ` [PATCH mptcp-net v3 7/8] selftests: mptcp: join: new ID0 subflow from the right IP Matthieu Baerts (NGI0)
2026-08-07  8:41 ` [PATCH mptcp-net v3 8/8] mptcp: pm: restrict in-kernel worker actions to this PM Matthieu Baerts (NGI0)
2026-08-07  9:43 ` [PATCH mptcp-net v3 0/8] mptcp: pm: userspace: properly deal with the ID0 case MPTCP CI
2026-08-07 11:36 ` 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=6c672ec640f12ec6d3e4592b89dd91a955ab0581.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    /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.