From nobody Thu Dec 26 10:22:15 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1657A190468 for ; Wed, 6 Nov 2024 03:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730864616; cv=none; b=q/iuOK0vhW3GAkY/f3y6beXKKfg62zcvmH9guT+n3MRE7UDS/sSKR3O/X8jkGo8l/KJK0bnxS3AwBCZzhqMc3vh2um996TN46cFZifhGs9XMmEs7fj3VQW9Bn6YaysLadPFi+vEZ3A08PGCPEepIZv+CJTgcZO9GRpf5FtnxTRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730864616; c=relaxed/simple; bh=N0iQVGFr0n6Y2eeewebKd55V3PtFdIiYX974tyQcrPg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PvEguj6JzDKZqtDko+4veSJ9FjKvdTZtlXkGcNfu71PBxUR8A9efqO7V8hVsgcvLZVYhUtJpz7V9NWdhiTgXUHnL0t2asizXGXbieAEHhiUWaiLMgMlbUhjvtYdpD1gcGq78p9U+tSAQ4mguwyW9KgqrlUryAs7j2mN8/Wz6I3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RccLxNxq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RccLxNxq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F7B0C4CED3; Wed, 6 Nov 2024 03:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730864615; bh=N0iQVGFr0n6Y2eeewebKd55V3PtFdIiYX974tyQcrPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RccLxNxqrDJsI0O1/zofgJIKlnw01b+YmeQU9wp6XfmurPnNAavSkKoS92i8d54Mc j+J7KnHjdkxMRzg0Q5nvKueh0Exh63GuwsDbxXq+4WlrMwYZE5osfP+8PVhAUURgSz vPOJZoTnE02NcZoVLy7809frachoV6AJ1yJHwjmqEeigUp+q2pJytgxiieaGagEw9z axu0XT4VrUz/ch55QmJkkyuCahcBW/mDb+REPr9Cwxc49OBSXTVTXhMovfgSKY6KH5 tSYSQEF5SmXUr2s2fR5TvevCEf8EBpT/KpK/U7tDrfLuIXxy9EB/lxKBxunwgKcbNv Zla01DBHSLaKw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-net v2 1/2] mptcp: update local address flags when setting it Date: Wed, 6 Nov 2024 11:43:23 +0800 Message-ID: <7ffab520bd47404b5c79518efe07463db3da3448.1730864444.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.45.2 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang Just like in-kernel pm, when userspace pm does set_flags, it needs to send out MP_PRIO signal, and also modify the flags of the corresponding address entry in the local address list. This patch implements the missing logic. Traverse all address entries on userspace_pm_local_addr_list to find the local address entry, if bkup is true, set the flags of this entry with FLAG_BACKUP, otherwise, clear FLAG_BACKUP. Fixes: 892f396c8e68 ("mptcp: netlink: issue MP_PRIO signals from userspace = PMs") Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 56dfea9862b7..3f888bfe1462 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -560,6 +560,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, s= truct genl_info *info) struct nlattr *token =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *attr =3D info->attrs[MPTCP_PM_ATTR_ADDR]; struct net *net =3D sock_net(skb->sk); + struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; int ret =3D -EINVAL; struct sock *sk; @@ -601,6 +602,17 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, = struct genl_info *info) if (loc.flags & MPTCP_PM_ADDR_FLAG_BACKUP) bkup =3D 1; =20 + spin_lock_bh(&msk->pm.lock); + list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { + if (mptcp_addresses_equal(&entry->addr, &loc.addr, false)) { + if (bkup) + entry->flags |=3D MPTCP_PM_ADDR_FLAG_BACKUP; + else + entry->flags &=3D ~MPTCP_PM_ADDR_FLAG_BACKUP; + } + } + spin_unlock_bh(&msk->pm.lock); + lock_sock(sk); ret =3D mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup); release_sock(sk); --=20 2.45.2 From nobody Thu Dec 26 10:22:15 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8B406190468 for ; Wed, 6 Nov 2024 03:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730864617; cv=none; b=hYRRjjJRMj4x51HtxmmARmFyA8AlM/S/CtsvdMXHawgAixMyiQQqid0+9LZdv+PxI6dOySt3n2QrSdoqWf+Klg9/C/q/tS7ZVEhgfu0Mh+FNLrvbCizLGR+hCO9Gcxbn5mW3MJVIlz3zeXGamvXxyIYtNyjr37jWGzZMnimZZ1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730864617; c=relaxed/simple; bh=yvLMk9KcAMuec6YD64hAg1REJJFI0rivAp8JZLpHvEE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AsUA33DJGAqr/BUVYfscmwFJxisVKJIPOuTCjhUgAN50tqxLLyyYhMH2JLaXK7X+VFsML6BCRArWKzowS2GHuVKcFQNAkMJxK8iiRxLZAZjqzgqf2W5JmfRhNAcucIszdJNUj/qSZSWkJl0odadYu8db5dgZh8c01Kf99/mF8W8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UN9BCkt5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UN9BCkt5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36A85C4CECD; Wed, 6 Nov 2024 03:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730864617; bh=yvLMk9KcAMuec6YD64hAg1REJJFI0rivAp8JZLpHvEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UN9BCkt5CPyT8o3H6Q7KAH6/3ftAth8DDCUFJthctO08v2MaHyS+eQbiSZCiczbjv LWiToOAFaopCnCYw7D+iWhLUlAEd0rg+Nnqqx7TIKj2F64HFhE1N+5t2stfPX76vVQ jmItbh6qHgIviyM/w+gDBS13Lm3XhD6W/CGZW6cIKw6YZApj/EVXjlUq8+JndaJ29s cbdvenSBc+l4NxXF2RIXG1Rm3japhMWJkperSCoopfdxOt8HD+YRfxGEsHgbQXwQXR h4x87Td34cHREP3BtXxlGefJNV5+/c/eDWRuDqzPXMvw6PIAUB+jtSs5BSN/MqjuHj FyYQHmDId8fzw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-net v2 2/2] mptcp: hold pm lock when deleting entry Date: Wed, 6 Nov 2024 11:43:24 +0800 Message-ID: X-Mailer: git-send-email 2.45.2 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang When traversing userspace_pm_local_addr_list and deleting an entry from it in mptcp_pm_nl_remove_doit(), msk->pm.lock should be held. This patch holds this lock before mptcp_userspace_pm_lookup_addr_by_id() and releases it after list_move() in mptcp_pm_nl_remove_doit(). Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE") Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 3f888bfe1462..e35178f5205f 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -308,14 +308,17 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, stru= ct genl_info *info) =20 lock_sock(sk); =20 + spin_lock_bh(&msk->pm.lock); match =3D 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; } =20 list_move(&match->list, &free_list); + spin_unlock_bh(&msk->pm.lock); =20 mptcp_pm_remove_addrs(msk, &free_list); =20 --=20 2.45.2