From nobody Mon Feb 9 16:51:29 2026 Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97BAA12E64 for ; Fri, 8 Dec 2023 10:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="k/rytOv+" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702030038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=crIFouS/5YIX1nEDP0AYR3Ew550C2j8bD1xbu7b/TIg=; b=k/rytOv+Qa1MELFabOuUbzvXMzCl+p4aXF8sp1sS3MtoRlrJYNo6LDiDkXunKIiFC22MnW igS8pHVzUBlyZ8/LdaYDhRN/q5cvLhnL3yLaPUmVYgrb7SR0ztMb2agfrKtdE/qn35+sBl KFJlQDRTkMeLRjCfPuBG7M9NQW+hHzA= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v14 11/25] mptcp: use set_id flag when appending addr Date: Fri, 8 Dec 2023 18:07:24 +0800 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" This patch uses 'set_id' flag when appending new addr, adds a new parameter 'set_id' for mptcp_pm_nl_append_new_local_addr() in pm_netlink and mptcp_userspace_pm_append_new_local_addr() in pm_userspace. Pass the flag 'set_id', which was set when parsing the address, into these append new local address functions. If this flag is set, do not alloc new address ID from id_bitmap, just keep the userspace set address ID. Fixes: e5ed101a6028 ("mptcp: userspace pm allow creating id 0 subflow") Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 11 ++++++----- net/mptcp/pm_userspace.c | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 6cf93ff508c6..7edbe935c139 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -855,7 +855,8 @@ static void __mptcp_pm_release_addr_entry(struct mptcp_= pm_addr_entry *entry) } =20 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 set_id) { struct mptcp_pm_addr_entry *cur, *del_entry =3D NULL; unsigned int addr_max; @@ -903,7 +904,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_= nl_pernet *pernet, } } =20 - if (!entry->addr.id) { + if (!entry->addr.id && !set_id) { find_next: entry->addr.id =3D find_next_zero_bit(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, @@ -914,7 +915,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_= nl_pernet *pernet, } } =20 - if (!entry->addr.id) + if (!entry->addr.id && !set_id) goto out; =20 __set_bit(entry->addr.id, pernet->id_bitmap); @@ -1044,7 +1045,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, = struct mptcp_addr_info *skc entry->ifindex =3D 0; entry->flags =3D MPTCP_PM_ADDR_FLAG_IMPLICIT; entry->lsk =3D NULL; - ret =3D mptcp_pm_nl_append_new_local_addr(pernet, entry); + ret =3D mptcp_pm_nl_append_new_local_addr(pernet, entry, false); if (ret < 0) kfree(entry); =20 @@ -1284,7 +1285,7 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, st= ruct genl_info *info) goto out_free; } } - ret =3D mptcp_pm_nl_append_new_local_addr(pernet, entry); + ret =3D mptcp_pm_nl_append_new_local_addr(pernet, entry, set_id); if (ret < 0) { GENL_SET_ERR_MSG_FMT(info, "too many addresses or duplicate one: %d", re= t); goto out_free; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 3d4258d2e269..c9dc25fa8540 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -38,7 +38,8 @@ mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *m= sk, unsigned int id) } =20 static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, - struct mptcp_pm_addr_entry *entry) + struct mptcp_pm_addr_entry *entry, + bool set_id) { struct pm_nl_pernet *pernet =3D pm_nl_get_pernet_from_msk(msk); struct mptcp_pm_addr_entry *match =3D NULL; @@ -51,7 +52,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struc= t mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { addr_match =3D mptcp_addresses_equal(&e->addr, &entry->addr, true); - if (addr_match && entry->addr.id =3D=3D 0) + if (addr_match && entry->addr.id =3D=3D 0 && !set_id) entry->addr.id =3D e->addr.id; id_match =3D (e->addr.id =3D=3D entry->addr.id); if (addr_match && id_match) { @@ -73,7 +74,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struc= t mptcp_sock *msk, } =20 *e =3D *entry; - if (!e->addr.id) + if (!e->addr.id && !set_id) e->addr.id =3D find_next_zero_bit(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, 1); @@ -147,7 +148,7 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *= msk, if (new_entry.addr.port =3D=3D msk_sport) new_entry.addr.port =3D 0; =20 - return mptcp_userspace_pm_append_new_local_addr(msk, &new_entry); + return mptcp_userspace_pm_append_new_local_addr(msk, &new_entry, false); } =20 int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) @@ -193,7 +194,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, stru= ct genl_info *info) goto announce_err; } =20 - err =3D mptcp_userspace_pm_append_new_local_addr(msk, &addr_val); + err =3D mptcp_userspace_pm_append_new_local_addr(msk, &addr_val, set_id); if (err < 0) { GENL_SET_ERR_MSG(info, "did not match address and id"); goto announce_err; @@ -374,7 +375,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb= , struct genl_info *info) goto create_err; } =20 - err =3D mptcp_userspace_pm_append_new_local_addr(msk, &local); + err =3D mptcp_userspace_pm_append_new_local_addr(msk, &local, set_id); if (err < 0) { GENL_SET_ERR_MSG(info, "did not match address and id"); goto create_err; --=20 2.35.3