From nobody Mon Feb 9 15:26:38 2026 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (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 75697134A4 for ; Fri, 8 Dec 2023 10:07:15 +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="hx95sV5l" 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=1702030033; 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=RqqS0iQEoA3bV8e0aTeRjxNaDYguqGuxLUxyorre9w8=; b=hx95sV5lg44GFkdrUJuYdiyQiOIL6pYzM1ZS5y2tOafL/F14HuX67A82SvgzMWOy7shvM9 Aa2YxMBvXMNYSrhiI2R0U5dM8vB2F+xVnzHVD4z3/d5kmUVgswj6bdnnsTPyPPlbSIZ592 oTK3OzOq9822i1uVdrrkA2ROUHlFDEE= From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v14 06/25] mptcp: dump addrs in userspace pm list Date: Fri, 8 Dec 2023 18:07:19 +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 adds a new function __userspace_pm_lookup_addr_by_id() to lookup the address entry by the given id in the userspace local addresses list. Invoke it when dumping addresses from netlink commands. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 9 +++++++-- net/mptcp/pm_userspace.c | 25 +++++++++++++++++++++++++ net/mptcp/protocol.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 1c85d711a86e..489a7723efc4 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1676,8 +1676,13 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, for (i =3D id; i < MPTCP_PM_MAX_ADDR_ID + 1; i++) { if (test_bit(i, pernet->id_bitmap)) { entry =3D __lookup_addr_by_id(pernet, i); - if (!entry) - break; + if (!entry) { + spin_unlock_bh(&pernet->lock); + entry =3D __userspace_pm_lookup_addr_by_id(net, i); + spin_lock_bh(&pernet->lock); + if (!entry) + break; + } =20 if (entry->addr.id <=3D id) continue; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 6999296cd5db..5e45e36ce1d3 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -549,3 +549,28 @@ int mptcp_userspace_pm_set_flags(struct net *net, stru= ct nlattr *token, sock_put(sk); return ret; } + +struct mptcp_pm_addr_entry * +__userspace_pm_lookup_addr_by_id(struct net *net, unsigned int id) +{ + struct mptcp_pm_addr_entry *entry =3D NULL; + long s_slot =3D 0, s_num =3D 0; + struct mptcp_sock *msk; + + while ((msk =3D mptcp_token_iter_next(net, &s_slot, &s_num)) !=3D NULL) { + struct sock *sk =3D (struct sock *)msk; + + if (mptcp_pm_is_userspace(msk)) { + lock_sock(sk); + spin_lock_bh(&msk->pm.lock); + entry =3D mptcp_userspace_pm_lookup_addr_by_id(msk, id); + spin_unlock_bh(&msk->pm.lock); + release_sock(sk); + } + + sock_put(sk); + cond_resched(); + } + + return entry; +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 8296bdf58f90..3ab4a4f1bf81 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1025,6 +1025,8 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, = unsigned int remaining, int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_inf= o *skc); int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_a= ddr_info *skc); +struct mptcp_pm_addr_entry * +__userspace_pm_lookup_addr_by_id(struct net *net, unsigned int id); =20 void __init mptcp_pm_nl_init(void); void mptcp_pm_nl_work(struct mptcp_sock *msk); --=20 2.35.3