From patchwork Fri Jan 17 18:41:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943890 X-Patchwork-Delegate: kuba@kernel.org 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 B1ECB1DE4ED; Fri, 17 Jan 2025 18:41:52 +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=1737139312; cv=none; b=ui6s8cMJ6pSwA+pU2x1qutuwCeE791POJ+y+IDNho/zQ08jgvybqyHpIg8EStA2iwL7az/sek7BuczEpU0SqmfkeI6Y8MNGkFnalAnpKaCvb27nkTV27xfpFTsE5qmCSVqoXrSd+UgqfJUhh0ED23Tk1liCyLAXpDmlhQA5G2Bc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139312; c=relaxed/simple; bh=8G7twJP3JZxNmu7hReZPonWiPiIdhHNGTM+TQzqkMBQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SBv1rVLqIE0N0N0QsloD6GaGRIDMpvLjCdkVY1rkqzyE9n0N+o2pdy5MUkshnkND4L/WxFduhA1Pj/IHSGfifEYZS9dbRFp6g1W6L1iEVyGiOo22J7gLydJ+JPbXnCKGq8rWQPG2/ccJ2E28/+L9bke5qQqKWfB8yDsHW8HNBdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PnXqqILE; 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="PnXqqILE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1391EC4CEE4; Fri, 17 Jan 2025 18:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139312; bh=8G7twJP3JZxNmu7hReZPonWiPiIdhHNGTM+TQzqkMBQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PnXqqILEXzIgkznJVWgIfptKMztCNpIE4hj1XcWmG0tgN/N1Oiik5jfoBENILk8rP wxWozg7J8n+6TNYv87jeYkxDZnGat5C8DSzw4mhPKvP5BbtiqBS43lIHGyKDdhJ3OB 8Y4ghub8RUqKT2UyyjTPZ9qESlS7zKzf4lOIy8U35vVL5qvEutdtJsxrFMXN8mNgOY TIi2tlGcSvqBd588HXSuHS4HENmojvmrsMURH+uf9Mtgrh96YaWTDrV+K2IMW+Qeje 63VYQh1jdAigpoM5vKCDkUtlBCCVCUxHN6sE6C+N69v8h+pEmMf5etv1QPwNBW0vMD V3kJDy478/FYw== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:33 +0100 Subject: [PATCH net-next v2 01/15] mptcp: pm: drop info of userspace_pm_remove_id_zero_address Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-1-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2431; i=matttbe@kernel.org; h=from:subject:message-id; bh=SnxuSp6YUyRM6PZLIJsCP27P8V93DanF7P4jRs0o2fg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRqVHC9cNjLkYJaygiLnZZ/NjkubDiJtyv6q JwmblsnGDSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c2YvEACb4hbefs8H2jYFmpjkNRo1Tgcj1PocY8bdknFHc/TQxvxgsoZ0C2Qbbp9FERjuS/7snG0 2aRdnni/++e16H0LX8r8EF19ISoEOPfhjU451gUOhviFG8n5KftPMJ1O7LuRcTvuaOav0SvFNaF 64udLx9RwVvPO1AovOl9Rm90YpT4bTvdMwG1riYA1RAJV/aPywMJ+Lz/GRWkzvZ024XUcGzPpU9 0SeUY27rXeTiKt9gUkiruel5gcpObYzfFt1eEFvJD/9TK1FNMThfPYxzyutGi3OQw7M1lEV6y66 Yj6cJ/EC3awU/Y7rsr0Bw/4C9PN71So4nIyYoRJelZnHIPNkvVIzJSGyWLUIxhHLkkNOod+Fo0H mHaPZUK686fNCAu0KMmbTI8IzZvdKW6Ea51irdQAvmtMQAtgG4BSwucG6GN6zLZuz7NLN7huIX/ fRnLEocr+E54aCzflnNUbTPVMLoQQsNPlNUo5ls1uim975HyJU+6RwNP+L9/b2c/y4vBj/eu3kO Uq+g2TzvFcbUgyVHneQHp93KSX7o9SoNF6fzBL3GBedmyQEmgd+QVoBxpQcK2QVelWctvZ0y9Wq KpIUVnySzTqoMQblBmXkdMzhGYLQ4WWQ7KyjA28gWBAod+HtRxXVqgZhreBymQQ0Vp7+0jV8I0s G4jZ0M+sWPSoEgg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The only use of 'info' parameter of userspace_pm_remove_id_zero_address() is to set an error message into it. Plus, this helper will only fail when it cannot find any subflows with a local address ID 0. This patch drops this parameter and sets the error message where this function is called in mptcp_pm_nl_remove_doit(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index a3d477059b11c3a5618dbb6256434a8e55845995..4de38bc03ab8add367720262f353dd20cacac108 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -253,8 +253,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) return err; } -static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk, - struct genl_info *info) +static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk) { struct mptcp_rm_list list = { .nr = 0 }; struct mptcp_subflow_context *subflow; @@ -269,10 +268,8 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk, break; } } - if (!has_id_0) { - GENL_SET_ERR_MSG(info, "address with id 0 not found"); + if (!has_id_0) goto remove_err; - } list.ids[list.nr++] = 0; @@ -330,7 +327,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk; if (id_val == 0) { - err = mptcp_userspace_pm_remove_id_zero_address(msk, info); + err = mptcp_userspace_pm_remove_id_zero_address(msk); goto out; } @@ -339,7 +336,6 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) spin_lock_bh(&msk->pm.lock); match = 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; @@ -356,6 +352,11 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) err = 0; out: + if (err) + GENL_SET_ERR_MSG_FMT(info, + "address with id %u not found", + id_val); + sock_put(sk); return err; } From patchwork Fri Jan 17 18:41:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943891 X-Patchwork-Delegate: kuba@kernel.org 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 0ED301DED5B; Fri, 17 Jan 2025 18:41:55 +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=1737139315; cv=none; b=L0As+3Vu+sOB+Jnj8t82mxCRljQX08gGtJvoYjESpso+Fu6hs0BiH1sq+hgl8bnJa/NenCWxDGOkZjRs7M7I9pKVempavqEEaETuGYGEdzpmzYtqJS5bZiZBH898UdfnWfwK/QIpnuiNEAsxiZ30ZqFpU1a2EmbnED/sVhXBGIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139315; c=relaxed/simple; bh=B/7KR3jBwTwNArI5wXpFWpYyFwZ/q/RqH8P6VfvLqUs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c8FBu9j5dfulug3T9+POyzDttCRiMkLgVOz38WWM1oOJyskUEa+iU6JUQk79plKi1fAP+ezI+LWpNGGciUf7BR2gxSM+GyXm+HNOgnxRLrdLKpy388FADbwPXDsMrdTJypcDsZgvXTAE7T/QFeyOd+lUw0sytyVQ/3Ydp8rIgJg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qchWTjq3; 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="qchWTjq3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEA40C4CEE3; Fri, 17 Jan 2025 18:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139314; bh=B/7KR3jBwTwNArI5wXpFWpYyFwZ/q/RqH8P6VfvLqUs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qchWTjq35Lx59D3Xdpt352QjqNAaiYdHgrlquJmI1nbwN+he8id1k/hwEIxz/CeRI 1hQwhb1JtVccRxhFdQ2oOQFVAPr8w3oI3a9tI0wBaz9e53W3m1dnHsbpLn+wMsPr8o /RNoJxVAdJjChxjYxghBK8xHO/HWPOT/gcBAjNAgOXYuJorIEn/lceHHIFpziZnXm1 5FV9vdjRtE2RE2ijc0DDrfWLkTmpy6UVNvxjqrsAH7LJdFRUHnX1TgUrEfhvIgR/A1 DX9VhhOItqbYuXMjTFobvGxlgChHdRA/H0wO258m3XmrbsKAvoAnAaQhnpoyaCNYs4 55d8gJ1cmQdow== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:34 +0100 Subject: [PATCH net-next v2 02/15] mptcp: pm: userspace: flags: clearer msg if no remote addr Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-2-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1601; i=matttbe@kernel.org; h=from:subject:message-id; bh=B/7KR3jBwTwNArI5wXpFWpYyFwZ/q/RqH8P6VfvLqUs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRqMkeDFlGyFD9y1D25BUIA1PxmPY2+vyqoV f/Pnx+Mmn6JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c7Y9D/4kM4rXqFeBi/oCbJW6H4SS2s+wLC25GCp1/MHHKmmTd7vewD2Mq34uZrpbJsKfjoac5Uh B+Ex4FsxAg1ucssZeA4LJMX1BMw/E4F8FdVm4cgGAB75Z+p6mzpAieJt55CZdKfxDFrvqZ/JJh/ ppZJoMdh4V2OUIG8d9esB593dGAzpOysqvAZ2R7bX0vLU9Zm7N6aqFIW9vKp8WNvdv4jLf0CG68 +BRihNsbTv/HK7g2uhMGHUjHZZ3CdDnX5w4e+hxS/wHrXNLAKkoRhXGETrA3gN6F4e9Wf+drVOR cC5bNGaGuLqOQudUhXNrUcy1B5B0DfXAJe+oMaYkBkhen9bzWrmThfUTFyP7t/j4a077MYSI2mf 21GpHFvgJ59aP8FX6W0D5I36E45HB2rQ8Bd6xyG1LNE3kG4BZ2kpMoZJCsOIwWduuMlvNL5uJLc NnVSAFmS3hJXE401AKBKcF4Ch1sUsm/AICTTblCE79qpfUY4k1p+GqxytqetAYafqfLNnoC7L8R wwbOrYoXzsUDin101lyKjVoJnxpgN0q26YwGYz/1OGXgXrXpwbfP3n1o47365DjcWn0gL1tkYQB byJ8V1fEl9XwHhIkwzkBpy3frJKDpTTa9//3l+8U7+YD9yJ3h5sgRxj4TwFgMgEpRoKxevmSomP Di7k4+DqE0f972Q== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org Since its introduction in commit 892f396c8e68 ("mptcp: netlink: issue MP_PRIO signals from userspace PMs"), it was mandatory to specify the remote address, because of the 'if (rem->addr.family == AF_UNSPEC)' check done later one. In theory, this attribute can be optional, but it sounds better to be precise to avoid sending the MP_PRIO on the wrong subflow, e.g. if there are multiple subflows attached to the same local ID. This can be relaxed later on if there is a need to act on multiple subflows with one command. For the moment, the check to see if attr_rem is NULL can be removed, because mptcp_pm_parse_entry() will do this check as well, no need to do that differently here. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 4de38bc03ab8add367720262f353dd20cacac108..b6cf8ea1161ddc7f0f1662320aebfe720f55e722 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -580,11 +580,9 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) if (ret < 0) goto set_flags_err; - if (attr_rem) { - ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); - if (ret < 0) - goto set_flags_err; - } + ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); + if (ret < 0) + goto set_flags_err; if (loc.addr.family == AF_UNSPEC || rem.addr.family == AF_UNSPEC) { From patchwork Fri Jan 17 18:41:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943892 X-Patchwork-Delegate: kuba@kernel.org 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 148631DEFC2; Fri, 17 Jan 2025 18:41:57 +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=1737139318; cv=none; b=bb0LZdjmqDttj7UfukcLZDUwJOV7+sGMqLcl/Jl1jBfv9h84VRuAG5thtWIK/I+lFnGya6vvDAvtvGmpbMGQHdRXOTh+M51uMUSvYKpPE9TIZ2vOhq86R5qdsMWX4DFxcHaoc7D5p1wI55YPk3RnsezBO2x2aFmeALfwLMm9hhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139318; c=relaxed/simple; bh=ywVqaLMcTnS7/LX0E47JY1rOXoObiNL+nHvd4fAztMw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K8L1agZVUBKIyLJNM328wsp/ujbC+uLwk8b2RplAAnWrk1G04Y2Cs6zUTRrEvVLU/YA74BiaPs6Yzl6FBx3mMRyW7HAmI4HY3EN5sKB7Nz1lj6IbZL0JLhIcoKRpvTXgOu3CYRkz/y5/9PuatSg8f9Ads+GZJaapD+/8Nx/q3js= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=twSGKUme; 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="twSGKUme" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 524A1C4CEE0; Fri, 17 Jan 2025 18:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139317; bh=ywVqaLMcTnS7/LX0E47JY1rOXoObiNL+nHvd4fAztMw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=twSGKUmelVI3K77aOH0v9lfRjoc1y9mQ98YcgczFyFmDhZCT7M0k746vgPrGTYayg o7y24YIOaMRAgS6fIP52bCEVI5eVQIGkwPDlPaIJPezwB719dxEHbPkqyII2pqxh7U C5Wulc17pnMGcooziGdkVuhOedNtMAZ0lHTiY2YgradrzB9d6InrYoFToYKFnDWHry Lv0b4ch1Z6okWFrFv9Pe3eY5uMK3MCYOJDk61ByRIx8G1fWax8IPQTbCmBQZtLdAhw i+Zspuvqn57PbopuS/DbxDMfkG6hA01paSZtWhSMB/7r3QwL9XMSO3xYN+Ti1FC6ao AATrzxN6t+pCg== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:35 +0100 Subject: [PATCH net-next v2 03/15] mptcp: pm: more precise error messages Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-3-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2478; i=matttbe@kernel.org; h=from:subject:message-id; bh=ywVqaLMcTnS7/LX0E47JY1rOXoObiNL+nHvd4fAztMw=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRqkXF527JvDWAAbi+5e9zxEn18fVb1bhr0r b8rJ/ARe2GJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c7xpD/45l20LP+o2AA0gBYMSbbtO2sPQi+HVNKTqOCKGm5NvvWptiAvq34u/KBldvarqIzk0r+F TeEDzHwbhd40aGxgmeeu62DhlxoAwDMrUgjnx1wk92sOfqZR4wkIwIK0WpBFerom0m46ztpO39C DbpbEQDM9epNl4zYueVG1BslXXd+PSbc1rUWg27IsqUspbceIhHHiYQI13Ukxt6YcpuMjVvJl3P kX40RcZrqj2H2XlPGx4PgHLJ0XmU33B1iYo44pcEk0sVhB4Fv4Nu8KdYLKiuKG+nIUpFNzKM8js k7N2G+63RBv9UYX3Zg9u5KNf5RpccCXIQohAa35/TJEj0kYh4ZxSGYBEJ6rOgbHgSJXV+4aUgmf vq+/o8/mG5Qffni6giDWWZbOBizpteidWoafGWuK59ftn9ycu2SzaU7cC0VBMwCs9K+TO1sDWmJ qF7pgnt7FgknEWPke57hqiEKi937ijvr3BQLRi44W8f2Z38qdVq4Zp1+6csmpEXB++ao2yCO0kk e4i/FFqqnZ/VPCgPpVw+Wbw4p43is8TjlleiqoX1INOdt7OLdZtmz4tGJ5K4JWAxsj0XhHIKpm2 PwtaMFWr/zWp3MgeuXKwAhPhIIOFViWPKC/qej+DQvc6uyqCaeVg5FFHCEpRqqaVoLzDLL6rpoU n6wa1Xiyv7o3/sQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org Some errors reported by the userspace PM were vague: "this or that is invalid". It is easier for the userspace to know which part is wrong, instead of having to guess that. While at it, in mptcp_userspace_pm_set_flags() move the parsing after the check linked to the local attribute. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index b6cf8ea1161ddc7f0f1662320aebfe720f55e722..cdc83fabb7c2c45bc3d7c954a824c8f27bb85718 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -223,8 +223,14 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) goto announce_err; } - if (addr_val.addr.id == 0 || !(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { - GENL_SET_ERR_MSG(info, "invalid addr id or flags"); + if (addr_val.addr.id == 0) { + GENL_SET_ERR_MSG(info, "invalid addr id"); + err = -EINVAL; + goto announce_err; + } + + if (!(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { + GENL_SET_ERR_MSG(info, "invalid addr flags"); err = -EINVAL; goto announce_err; } @@ -531,8 +537,14 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info goto destroy_err; } - if (!addr_l.addr.port || !addr_r.port) { - GENL_SET_ERR_MSG(info, "missing local or remote port"); + if (!addr_l.addr.port) { + GENL_SET_ERR_MSG(info, "missing local port"); + err = -EINVAL; + goto destroy_err; + } + + if (!addr_r.port) { + GENL_SET_ERR_MSG(info, "missing remote port"); err = -EINVAL; goto destroy_err; } @@ -580,13 +592,18 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) if (ret < 0) goto set_flags_err; + if (loc.addr.family == AF_UNSPEC) { + GENL_SET_ERR_MSG(info, "invalid local address family"); + ret = -EINVAL; + goto set_flags_err; + } + ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); if (ret < 0) goto set_flags_err; - if (loc.addr.family == AF_UNSPEC || - rem.addr.family == AF_UNSPEC) { - GENL_SET_ERR_MSG(info, "invalid address families"); + if (rem.addr.family == AF_UNSPEC) { + GENL_SET_ERR_MSG(info, "invalid remote address family"); ret = -EINVAL; goto set_flags_err; } From patchwork Fri Jan 17 18:41:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943893 X-Patchwork-Delegate: kuba@kernel.org 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 A93921DF258; Fri, 17 Jan 2025 18:42:00 +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=1737139320; cv=none; b=Z17ffRCydIxjz+tnzKfjwqDyRTt6/mWZM8N4YG0tJdpwdXYpdPNFCbfUxJ9s7umj+YKzFTFGLMZWeDJM80MEjf7bjMH2iU7Qg5i0Fmaxrj9bLcZyOyL8zDGhvMAbaNJLKsWGKfA037SYdQx2VWjfp08BVRDJ1RehMKthcdLXVtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139320; c=relaxed/simple; bh=ziY1kNo4JB2WGFwqk/DGfw7wmfDoIoZ2o4P5q2wJOOo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lb/55RwOI4+jGWYBGvTbBnOHKP/1ZaxM8k6HIoloQARbOodHRo7bcXGKGY78yxUyhB+r96p5cd5DpIxlGRvYUSfUzOj1AoBQ102i4XfWy9GqcUki+QUM6BuViiK39LWsMiAXpiWRmjupvTs/6BH1pE1ZL1gZXxdLvMgX7BCdLZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RAr1fLdO; 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="RAr1fLdO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB1C1C4CEE4; Fri, 17 Jan 2025 18:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139320; bh=ziY1kNo4JB2WGFwqk/DGfw7wmfDoIoZ2o4P5q2wJOOo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RAr1fLdORxJPoLd9qryGigL21kL1wGG0tYHDQthYl2Wc7tg5a1MDU+jp/NGZqi6Wc irEnA/9Inl/nfPrEX7a6wySBs4w3EBCL1jsHkGYEGTsISUBLtNB4lGxB5JeLfcJu7o X0lVXO8CqEqKEdbTG0FA4haJGYRUvDNb3pDFLDAhv+9DT4FqaFRA1z2eAx7Gkja5yL tG8C2dIbwVqEdH0TSLhQKJwixfffqbwRKTs/pCIeEFEdkcKm0qw1EbgYxghczNnez7 n8n767Gx9W08g4Y9v2XrIfaOoLbhCMNdl40LgVZsT6fB8YpIHo96RiOkofqfodRXD9 XFlhC1L/HO0PA== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:36 +0100 Subject: [PATCH net-next v2 04/15] mptcp: pm: improve error messages Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-4-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3062; i=matttbe@kernel.org; h=from:subject:message-id; bh=ziY1kNo4JB2WGFwqk/DGfw7wmfDoIoZ2o4P5q2wJOOo=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRq9tjZ3h9eFYp9r28sxYxToJwvu16LhO7zb 4NIks9yhuSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c+qfD/4mvM/aWm6BAfgIZyoFsGOKSzh75EA3O6XzbFuz1xCWkRhLuooAq2dPvGztCqPttc+uN8A 6ludUeDPDBA1f6DIa5kKbNIiQXozUGRbxCy5cHoE3AhTN5U02m33xzfFLM01rRo0oouoyNMYHfG Lzjv695Ya9dqGHz8XxIFUjOZxXE/DFPkDiAXhcEkWtXb5IQPBl0zNYB3KcfZpSeajfqMxjqRSsm h9cA7DQDev0Hlc1GsralJWbioW4HPLhaH3/1lnnqaWkN2kX6R0IXpehn5YTnH0QmglHFFpCzwA+ g7w5FyvNX3RcFqYdPpEIAIP0pYiIgvyo62dmzB0NOWVJVlcKegrRLrMqZKkadr2jA4yusBuZI/N JN1/YlIh5exwcKqycd6w3oBThbn8Sbi1XNgno7+3+Vq/0y+RUeybHXuBHUp9I1eQ6qPVVLvkbtv wUCCvNsH6gLfzHMNEz0Qq9Li9lneugkLRzNCMfdpyrMqlz6k8dTXV3h3Soakc7+OVVhdkkS/lBd wtvgDrBIeknlgEI+XftBO0+wK4rUHbdDZ0XfGVTzoaXizyOhZLjaRdqnhb5OAePDKBcyFUehvKU N4XD0YDRi8i0BwTVT87tCsnJ3pTnyNW15GvUKeriToQBjHi0LIFoXb1eSnqr6x/bPTeOrspVFU+ RGF3EY90ZSGDKiw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org Some error messages were: - too generic: "missing input", "invalid request" - not precise enough: "limit greater than maximum" but what's the max? - missing: subflow not found, or connect error. This can be easily improved by being more precise, or adding new error messages. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 6 ++++-- net/mptcp/pm_userspace.c | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 98ac73938bd8196e196d5ee8c264784ba8d37645..a60217faf95debf870dd87ecf1afc1cde7c69bcf 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1875,7 +1875,9 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit) *limit = nla_get_u32(attr); if (*limit > MPTCP_PM_ADDR_MAX) { - GENL_SET_ERR_MSG(info, "limit greater than maximum"); + NL_SET_ERR_MSG_ATTR_FMT(info->extack, attr, + "limit greater than maximum (%u)", + MPTCP_PM_ADDR_MAX); return -EINVAL; } return 0; @@ -2003,7 +2005,7 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) if (addr.addr.family == AF_UNSPEC) { lookup_by_id = 1; if (!addr.addr.id) { - GENL_SET_ERR_MSG(info, "missing required inputs"); + GENL_SET_ERR_MSG(info, "missing address ID"); return -EOPNOTSUPP; } } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index cdc83fabb7c2c45bc3d7c954a824c8f27bb85718..e350d6cc23bf2e23c5f255ede51570d8596b4585 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -190,7 +190,7 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in } if (!mptcp_pm_is_userspace(msk)) { - GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected"); + GENL_SET_ERR_MSG(info, "userspace PM not selected"); sock_put((struct sock *)msk); return NULL; } @@ -428,6 +428,9 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) err = __mptcp_subflow_connect(sk, &local, &addr_r); release_sock(sk); + if (err) + GENL_SET_ERR_MSG_FMT(info, "connect error: %d", err); + spin_lock_bh(&msk->pm.lock); if (err) mptcp_userspace_pm_delete_local_addr(msk, &entry); @@ -552,6 +555,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info lock_sock(sk); ssk = mptcp_nl_find_ssk(msk, &addr_l.addr, &addr_r); if (!ssk) { + GENL_SET_ERR_MSG(info, "subflow not found"); err = -ESRCH; goto release_sock; } @@ -625,6 +629,10 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup); release_sock(sk); + /* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */ + if (ret < 0) + GENL_SET_ERR_MSG(info, "subflow not found"); + set_flags_err: sock_put(sk); return ret; From patchwork Fri Jan 17 18:41:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943894 X-Patchwork-Delegate: kuba@kernel.org 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 DDD3D1DF726; Fri, 17 Jan 2025 18:42:02 +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=1737139323; cv=none; b=TjfFtCXjAdOR+AKYVhtoJyd5/dc0YbZQJq3THxZ1soxD573zDOjpv0XItbiNn0B5zzZw7tSWDHrQ7RrhO3CQgcNdSG2GF75DECxA5han6MdzOqszI+8gEP4BWDQzTg3JKabOdBSdSrt1S6MnFfJO2A7KsaQmyEeLtmyEZ/jgmcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139323; c=relaxed/simple; bh=Lqek27knGwgehju7/g0u3Xuoe0fvOylfOxCOeXWYdF8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k/JN8NWFJ93jzfPyPuuD9QDlg+zintyQsJpPBlYGgpIdg4h/mHbuagw/evN0XzGs+IXyCutkuhmSjrTOdIOGRZVf1zPjTMLhbl+f+fSxuBxO+EWtyA44Jr3+DF60lqH0CUCmW2U+8zSQfI6ZbNHYCC3eyK8KD70gD1N8y2n3Kdg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qrANXPf6; 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="qrANXPf6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F12CC4CEDD; Fri, 17 Jan 2025 18:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139322; bh=Lqek27knGwgehju7/g0u3Xuoe0fvOylfOxCOeXWYdF8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qrANXPf6aZ6HuOcAiGDq/6EfAb49mIOImXML+E7BftbajaAlRge6mvXM5tUUFSp6n fkonnvyMgXEtqQl4H1yDZQrdYipjoc3Uo6DXLFXLJZ8x87b//N9dfXQ4mFaWRkwdeT ayQxTJ3nN7KmqKVaXCSVXmfZqk3kuX39AJJu+iy+maJTiCnDymHAWw8YcJ05MGRcrY 6F62v1978g4SsqTQA45s78WCWe4m5m+Jh9hTjX7Uq0B02R1j6Vsea6n7S01Rrnip05 EL+2q9QwPcvW5W+5gbY64PxO8QGjSyWrwYIgeUJcvJjrmnvEPCZPafMRUI/jFhpYl+ CJNzNPhJ4RvkQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:37 +0100 Subject: [PATCH net-next v2 05/15] mptcp: pm: userspace: use GENL_REQ_ATTR_CHECK Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-5-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6019; i=matttbe@kernel.org; h=from:subject:message-id; bh=lYcLaaLOXN2A3W5NX7QnQyADIBMohkFvf2lwLm//Ay4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRqTN721Na/78MrdcI8FO+HqXY5xiAk5J8iN W0ZVNKDFlSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c47LD/4/9IfRpbZM6Wh2U2DO3qT0WYUdeAhoguf/WhgV0l3Wxd4NWRm4f00BBvfyz/oPcYvkVcB YOyYOCDlskBf0pTcGlQHl06gDHKrnpUhv9GKojuVyZ7SVQsFjjSBxq78b0VPmt7zj8TUi9kwtBD PmRMFbhbX6UBnAdB2Zwux3OKdiwleSSMfRpxcnW53kTMS5gY5iNQfgfny5Lt+qQsecJiHUJnLHp dWxF+SK+LOFtIK1SNFcoxFceMEzuKyAREpdRlIbwIuwjl+kLfNP6Benxg9/a3uxZyajd214k77Z I6/mbZIRqh12FXikiETRDDxNPK/eXXasahbZ0THJ4fsKQt4UjWLpvlrlC/XyCliHEDcr5clq/I4 IzpYYGk4BRitaPAZnHLe7JrQ9JsnuLgV+0viutsnIX8yX9I9Bh4VhozC4rj/na5wjrsADjUqzFJ fZ1y17DVD20lJ8cZXS+LtehfZD9/ml9pswOgDFhi/q6G2FkhXt0z4zjAYA7bnwYrKHDtZ2C/bwE YJdWS1PeefLbumaZ4+W3zz6Fswy0j+xEpNaeC8/g7vZRihyrmQuBL9ajPbDyn6pY40Gjwh86GaW LD0FvdJEbo23IWsIDstuzyTPHislUnTY08g9BQSeUehCG8UtNbf/5FkN8KVptbBi2KcdGIc2TOd 335npVGUv94AxAQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang A more general way to check if MPTCP_PM_ATTR_* exists in 'info' is to use GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_*) instead of directly reading info->attrs[MPTCP_PM_ATTR_*] and then checking if it's NULL. So this patch uses GENL_REQ_ATTR_CHECK() for userspace PM in mptcp_pm_nl_announce_doit(), mptcp_pm_nl_remove_doit(), mptcp_pm_nl_subflow_create_doit(), mptcp_pm_nl_subflow_destroy_doit() and mptcp_userspace_pm_get_sock(). Suggested-by: Jakub Kicinski Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index e350d6cc23bf2e23c5f255ede51570d8596b4585..4cbd234e267017801423f00c4617de692c21c358 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -175,14 +175,13 @@ bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *info) { - struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; struct mptcp_sock *msk; + struct nlattr *token; - if (!token) { - GENL_SET_ERR_MSG(info, "missing required token"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_TOKEN)) return NULL; - } + token = info->attrs[MPTCP_PM_ATTR_TOKEN]; msk = mptcp_token_get_sock(genl_info_net(info), nla_get_u32(token)); if (!msk) { NL_SET_ERR_MSG_ATTR(info->extack, token, "invalid token"); @@ -200,16 +199,14 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *addr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry addr_val; struct mptcp_sock *msk; + struct nlattr *addr; int err = -EINVAL; struct sock *sk; - if (!addr) { - GENL_SET_ERR_MSG(info, "missing required address"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)) return err; - } msk = mptcp_userspace_pm_get_sock(info); if (!msk) @@ -217,6 +214,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk; + addr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(addr, info, true, &addr_val); if (err < 0) { GENL_SET_ERR_MSG(info, "error parsing local address"); @@ -312,18 +310,17 @@ void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk, int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID]; struct mptcp_pm_addr_entry *match; struct mptcp_sock *msk; + struct nlattr *id; int err = -EINVAL; struct sock *sk; u8 id_val; - if (!id) { - GENL_SET_ERR_MSG(info, "missing required ID"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_LOC_ID)) return err; - } + id = info->attrs[MPTCP_PM_ATTR_LOC_ID]; id_val = nla_get_u8(id); msk = mptcp_userspace_pm_get_sock(info); @@ -369,19 +366,17 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; - struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry entry = { 0 }; struct mptcp_addr_info addr_r; + struct nlattr *raddr, *laddr; struct mptcp_pm_local local; struct mptcp_sock *msk; int err = -EINVAL; struct sock *sk; - if (!laddr || !raddr) { - GENL_SET_ERR_MSG(info, "missing required address(es)"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR) || + GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) return err; - } msk = mptcp_userspace_pm_get_sock(info); if (!msk) @@ -389,6 +384,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk; + laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(laddr, info, true, &entry); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); @@ -402,6 +398,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) } entry.flags |= MPTCP_PM_ADDR_FLAG_SUBFLOW; + raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; err = mptcp_pm_parse_addr(raddr, info, &addr_r); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); @@ -493,18 +490,16 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk, int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; - struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry addr_l; struct mptcp_addr_info addr_r; + struct nlattr *raddr, *laddr; struct mptcp_sock *msk; struct sock *sk, *ssk; int err = -EINVAL; - if (!laddr || !raddr) { - GENL_SET_ERR_MSG(info, "missing required address(es)"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR) || + GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) return err; - } msk = mptcp_userspace_pm_get_sock(info); if (!msk) @@ -512,12 +507,14 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info sk = (struct sock *)msk; + laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(laddr, info, true, &addr_l); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); goto destroy_err; } + raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; err = mptcp_pm_parse_addr(raddr, info, &addr_r); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); From patchwork Fri Jan 17 18:41:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943895 X-Patchwork-Delegate: kuba@kernel.org 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 81EEF1B425C; Fri, 17 Jan 2025 18:42:05 +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=1737139325; cv=none; b=hXh9iBrGKUKkIsj1v/JRYLXzBoHjzHv32cMZh1XeYosderfvRHS3gUN6lqPyA1udMmZs2zNiPs66n3N/JvpOS+7j1ED8uUt3SukslA/TylCvmOBmfpbHJ1rS5YQt2mu9EUGpmEKHZVV//vBRX85Ptcnz0wwXQybeu/rPj77Ixg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139325; c=relaxed/simple; bh=B4EoGp6iIdIcXqT3mYInhSvXfXsv3hE73F8zcYqYI/k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=im8VZ4y8krelG3AAq/0qb0pQlVPPl4ab5ZU2s2lT5hHSdiFBMjOOUb4ZvEuuHAapdahSjkaVYkWwIcBt/Zc2Zd2IKvJ0SbOXeEVFL3Wygt3S2/PVaFbVVFYmkicN+4TueAdxzXQIAVP/Fz7OqC0yMkppEPmIru7MsV+V524k5yA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Twn9jh0J; 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="Twn9jh0J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35176C4CEDD; Fri, 17 Jan 2025 18:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139325; bh=B4EoGp6iIdIcXqT3mYInhSvXfXsv3hE73F8zcYqYI/k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Twn9jh0JNfLZhnnCpJZ5LLytognEGeyiviu6/QO/koRF3rwhXpHF/IxbwY2wbqR3/ d6cLg9t0YHHmyOcWMpAyFYnZj/6l1+HcK61olW9ICigG7gdxZPtCOoQg1gIPvX7Tra sSIUdaVPiwueNk0t9zXP7hPEYucLeAVgTXBH2qjZ70D/GGmoMmPIxFDxOeOtvvWy4p opzjOwYHTC6ZR+ENGzhjcjyI5P9z5RrEFfCldETxuVlsHsrDlJYgXuoz015IvNjpA1 p4qLekUjWbueSLji3Gl8Vhpx9htbSLoQincFI21pRjT4Dxn+0FtlRKsqhGkO4UHFv1 VMCLXGZ65SqSA== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:38 +0100 Subject: [PATCH net-next v2 06/15] mptcp: pm: remove duplicated error messages Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-6-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2694; i=matttbe@kernel.org; h=from:subject:message-id; bh=B4EoGp6iIdIcXqT3mYInhSvXfXsv3hE73F8zcYqYI/k=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRqJ5mQzCfhMQl3A3TFXuBqaa+1JlHSIfV9b FHvLzIOloCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c7cmEACaUk8u2VPvgp1TYEyyvLw+QPV4ldHyePbaOkPSbR6m8HBvvR1taMMz+4j9ydc9Q4E5vm6 o7HAIJ3L0Z+9b0uAAxdw8Zaog0pT8BDQZm98lOXSmg9gYto4dH5jE23RH2WymlWzvCdGUj5WF7A 9UmAQJoDssYG5ayyg3lQzbDwaqsy8JHQn/a0D+/u0pEstKcWOt9QbmsLz7Jh+vpSRAowI2+gkaM 2se3srmD+vBbEqgS5mdgsq9KUfg8qdPT5AM8Eh8sd6cHSbNoBkTtFrIez2LJc5djRMW2Eo+Xwfv pFowzng+tWtTS637gi5szMCUwohFN0Ea8TOSEx8yopA503LpFHDccErs6vg3kUQxjJTmdq8ogCP p4tLyecKG0bJpqzgT+1xGWdKrTUhaSbZ9sJ0KOt4X7ob3iBw7ohIeaW7bhcwb+6HV7s0WukB9i/ tbaQz/76Zr5msa7uJsncpiSLdibQiWW1mbdPdVlFazCR6TUQzL0hq8sBeRy7inMrNO8Fkp0ruIX Pvwj3QW4qLQP0j4MDtgUkYZFw3zgZ03Z5/vBsJa0I6FCDckReFEcNq1T5KDCRmqYz5ZwzUARdxZ bxXEfdjhg7iHHkLmkxOxz5fJNYaj9oS1+qEFw6piOpSq7JH1qBgipG+IdghnxQL1e5qRZciizX/ LRdNfQYg57PYO5w== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org mptcp_pm_parse_entry() and mptcp_pm_parse_addr() will already set a error message in case of parsing issue. Then, no need to override this error message with another less precise one: "error parsing address". Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 4cbd234e267017801423f00c4617de692c21c358..ab915716ed41830fb8690140071012218f5e3145 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -216,10 +216,8 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) addr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(addr, info, true, &addr_val); - if (err < 0) { - GENL_SET_ERR_MSG(info, "error parsing local address"); + if (err < 0) goto announce_err; - } if (addr_val.addr.id == 0) { GENL_SET_ERR_MSG(info, "invalid addr id"); @@ -386,10 +384,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(laddr, info, true, &entry); - if (err < 0) { - NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); + if (err < 0) goto create_err; - } if (entry.flags & MPTCP_PM_ADDR_FLAG_SIGNAL) { GENL_SET_ERR_MSG(info, "invalid addr flags"); @@ -400,10 +396,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; err = mptcp_pm_parse_addr(raddr, info, &addr_r); - if (err < 0) { - NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); + if (err < 0) goto create_err; - } if (!mptcp_pm_addr_families_match(sk, &entry.addr, &addr_r)) { GENL_SET_ERR_MSG(info, "families mismatch"); @@ -509,17 +503,13 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(laddr, info, true, &addr_l); - if (err < 0) { - NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); + if (err < 0) goto destroy_err; - } raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; err = mptcp_pm_parse_addr(raddr, info, &addr_r); - if (err < 0) { - NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); + if (err < 0) goto destroy_err; - } #if IS_ENABLED(CONFIG_MPTCP_IPV6) if (addr_l.addr.family == AF_INET && ipv6_addr_v4mapped(&addr_r.addr6)) { From patchwork Fri Jan 17 18:41:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943896 X-Patchwork-Delegate: kuba@kernel.org 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 869EC1DF98B; Fri, 17 Jan 2025 18:42:08 +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=1737139329; cv=none; b=Gd3ZtS7q4TgSxaw2ZD5AvvVei17UmKwNU9bmgW8lFuIzcrYk8KXfur9gs7pPgpsmtN557wt2zYUwWwlDezLdLDmlhUBFf+lwSP4AowtdxtbgPmcthYdNHc/XUjyyDE37E6MDYE/phZ8rkzqf65VOObjtSY2ZYAHgH63vm2owEbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139329; c=relaxed/simple; bh=NtTz4FvD4ReIufzfyx8mW8HEmn5ARaIOpdOhSGpc6hE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ikYgeM4sD+7uzalA2Dpcc/5/bxe3mEv0jsvr5XRYRZ/573fjJIVnA6g6DMQEkdWa9Cbit80xakKUzkosHjaN5ACTEDlpbKsvXI8aWNIzzwHhm7kjT018dfJDJJYiAlORokhEZrwE6hM5zisFebIkTA91Z5v1tBFVBdYAGqIWTnA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FmP8WJZq; 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="FmP8WJZq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDB76C4CEE2; Fri, 17 Jan 2025 18:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139328; bh=NtTz4FvD4ReIufzfyx8mW8HEmn5ARaIOpdOhSGpc6hE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FmP8WJZqMCyGfa5b24WdZV5AbDXKOiqdUGLEg9pSc/P2L1cl9u27kmQ+muivVXqmE 7Lm4joHDJMBaPa5GEdVzbhilGei+R9+VGTso2SOovMTpeF5wtYi4hw7jKXlCpRPTme Iwifc97SqQ6tknkyPCyc2x4itetIzeMSJp81vSuexwzJY7ANHWtpizePYL7hQ2iF6p pUXtit9yt170r2mNWZP7ry4tWpFv0MSNVIDTGSRsA5eVOMzbCKwN9Pv9MJDNxvRn0U M15Si4PGCSxhUkAICrSkk2AN+CYkdoCjeCM/9DehZF397G5jDSm2r5L6UJ4pogKKfv o8zB2Pp2ddHvA== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:39 +0100 Subject: [PATCH net-next v2 07/15] mptcp: pm: mark missing address attributes Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-7-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5806; i=matttbe@kernel.org; h=from:subject:message-id; bh=NtTz4FvD4ReIufzfyx8mW8HEmn5ARaIOpdOhSGpc6hE=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRqb4k1h4f0Hksg3dVa9OkNCWV6xaGkj4vMU dYUuUzF0paJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c1ZsEACXXeMGyvuGtY4J8/AR05OFz+7y+BlwasapQur3lUuctP+7J+s82nruxzPyjA7DYM5xZot seri1atppCqCcuJSglw99MzoMzegXetrqfyGAoxKrNDSJ+eau2UWu7MgDs+z3HubDDhf//GkJsD o9+ean1HaftOkOThE1gNuNyzSeBx09LXhNZ89HTj6HtgrAWrCBJMYTeZZt/z5nH9jjnBJTojZuG b+Hg+DSB8BiMveF3t0pLpmjK3/DFnWJiAl8pdci0fcpBiQmo2WeNTWWlatyvDBdDTXoTp9Kcqqj sHwPh0hzvr9VqlgAgbsVs2DzQ8tiOF7h7ZA3GSDamtI33NQgku1ZFPcJa23XXkY7timbqR+M2v8 ZO/7egTplGpEskSPeLWace/k/BeJtuXLzyspWLEL02aXURan1mR1N+CPQ9pZqGAzx9AilVt4DDs QgRc+ZsrhtrL+Jp9tEndxffy4yJG86u6ZRiKMZtYvL+27wFLbnjHj1D7tpdzzomDoh4P3bnj/DW l3ysifGealBmXAe4GQVB+woQGMBPbDR1GvDU7vv/gR2G/1hACNAOlYw/gCkMf4v1w4qUn8rZuOw swP7Z920ZIBoRrjsbki3J9MXpRJ0SvVjoFNHNNI0ThmqmTCbPccemCnnoyJR8+sH2vuQFdC1WRL cdBL5Qcqrjb9OBg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org mptcp_pm_parse_entry() will check if the given attribute is defined. If not, it will return a generic error: "missing address info". It might then not be clear for the userspace developer which attribute is missing, especially when the command takes multiple addresses. By using GENL_REQ_ATTR_CHECK(), the userspace will get a hint about which attribute is missing, making thing clearer. Note that this is what was already done for most of the other MPTCP NL commands, this patch simply adds the missing ones. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 24 ++++++++++++++++++++---- net/mptcp/pm_userspace.c | 15 ++++++++++++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index a60217faf95debf870dd87ecf1afc1cde7c69bcf..ab56630b1d9ce59af4603a5af37153d74c79dbb2 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1393,11 +1393,15 @@ static bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr, int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; + struct nlattr *attr; int ret; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return -EINVAL; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; ret = mptcp_pm_parse_entry(attr, info, true, &addr); if (ret < 0) return ret; @@ -1587,12 +1591,16 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; unsigned int addr_max; + struct nlattr *attr; int ret; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return -EINVAL; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) return ret; @@ -1764,13 +1772,17 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; struct sk_buff *msg; + struct nlattr *attr; void *reply; int ret; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return -EINVAL; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) return ret; @@ -1986,18 +1998,22 @@ static int mptcp_nl_set_flags(struct net *net, int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; - struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP | MPTCP_PM_ADDR_FLAG_FULLMESH; struct net *net = sock_net(skb->sk); struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; + struct nlattr *attr; u8 lookup_by_id = 0; u8 bkup = 0; int ret; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)) + return -EINVAL; + pernet = pm_nl_get_pernet(net); + attr = info->attrs[MPTCP_PM_ATTR_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) return ret; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index ab915716ed41830fb8690140071012218f5e3145..525dcb84353f946a24923a1345a6e4b20a60663b 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -565,20 +565,24 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; struct mptcp_pm_addr_entry rem = { .addr = { .family = AF_UNSPEC }, }; - struct nlattr *attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; - struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry *entry; + struct nlattr *attr, *attr_rem; struct mptcp_sock *msk; int ret = -EINVAL; struct sock *sk; u8 bkup = 0; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR) || + GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) + return ret; + msk = mptcp_userspace_pm_get_sock(info); if (!msk) return ret; sk = (struct sock *)msk; + attr = info->attrs[MPTCP_PM_ATTR_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &loc); if (ret < 0) goto set_flags_err; @@ -589,6 +593,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) goto set_flags_err; } + attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); if (ret < 0) goto set_flags_err; @@ -677,20 +682,24 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, int mptcp_userspace_pm_get_addr(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct mptcp_pm_addr_entry addr, *entry; struct mptcp_sock *msk; struct sk_buff *msg; + struct nlattr *attr; int ret = -EINVAL; struct sock *sk; void *reply; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return ret; + msk = mptcp_userspace_pm_get_sock(info); if (!msk) return ret; sk = (struct sock *)msk; + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) goto out; From patchwork Fri Jan 17 18:41:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943897 X-Patchwork-Delegate: kuba@kernel.org 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 2802A1DF989; Fri, 17 Jan 2025 18:42:10 +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=1737139331; cv=none; b=XALbKB8vRQBQnVZ1SONmjnKpCqTrdlvlp2g6BTL2P6xNk2JSOShmlWQm7k4FnHtl/UY1TXSgDvP0GiLfCdkw2WM3+hYR/KFcCPfZ1iaaFOCqW5qjyhQ5d6U8aV/NdCuijxIBgzFizaMgBLwFfFoGNY3LCMQ1cqe8OSYHWzp0DuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139331; c=relaxed/simple; bh=59FzKF1u2GGsoOoRmtQfpYMeM5tjI0LbHfzsM02NFM4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nCOeP152OTdcx5818P9lH5JxPMw5x38J4cIb7GErrJdph/W5inYyXe2wtrtuZPv9r5GwulzkQkJzW1lKs3kZapuhQjf8J7bhdTIjCSoETZUEcMcEoO7rQbYg1/p4LhW3AFHnCVNttL2DMfuNsJszoB8xFBU6tZxKLIPyLnETPks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eo96KSdy; 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="eo96KSdy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73849C4CEE3; Fri, 17 Jan 2025 18:42:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139330; bh=59FzKF1u2GGsoOoRmtQfpYMeM5tjI0LbHfzsM02NFM4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eo96KSdy3JITNt/3ImxzloOHuY45IGbe6tIdoHo/dU11TeSGZb5NpITlDYW1S35CG vcUJ+gtxPCImTNSdbzaR8ccn5r8In+Mtfsd/01SyOAdsEWv1rXn/TtKgUAfJVN2IvB 7+BV39nbn8C7FQA4iY12g1GDzqv/dzLyWk/UYFeVRJS7fj5Gse3GqxPwNYURnTki01 g0agRkaKuteH1V7bCgHhyryDtxarSoYU0MIBASnuEYXRAc4zLXK6Pb5IckchK3pK1R B+Mn7RADrRk59oMshvWfvAQ5H9NeB7z+kLcBW02FSOR15291kLS2L5sxG5fM1uz4Rk lxd2I/YIhMxug== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:40 +0100 Subject: [PATCH net-next v2 08/15] mptcp: pm: use NL_SET_ERR_MSG_ATTR when possible Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-8-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7479; i=matttbe@kernel.org; h=from:subject:message-id; bh=59FzKF1u2GGsoOoRmtQfpYMeM5tjI0LbHfzsM02NFM4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRq6NxHtq/Wmzx0pI+6XCRrSRRXIgUjJjPJ4 S4PSP4kNEKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c5sZD/4ycWuPWV4rLl/4f5dnrVNht1dvDtpbaFHnAZNkR4pb9ZpBi+6Ac5xDca0qAC59H+wDzqV P7nVhQ4PdW1SjKkpWDFs4hy+hiBw/fxZW6OX10xvo54oDU7FJ8Oc7fYs6PJ4QRerpD7iJLkgXsN +gI81NRqW7Ho9K3QRP1SMA182Lt4xdavXXF2KSTPwSgDVm9o1EH8D1Fj1R0QCoD8AiooqUGcr8i 7CTLbPWsH+9fMf/JAVii/AOoF48W5InuoO2e8Hnx6ODw5y5vVgPeQUqdQ7Y8FuLjSzs31OnLpZr w9ErBVJjBWMDgqAvNtVrtux8i+1lMIL1avW24zjPQpXDQjvlYeatP3gEQKE/WsGsB3UFNHlfrfL nD1Jl7liuRBU8unYyLstSr8QJHPCedTxmXaq/TpkGIQi3Wo9z4w3UV6H/VWih6Ij527Twg3TEZq RbV6WMLBTYlhOTmvFsSutQClCezHCjMjCP9OpfVSovPjiO5cSzVlOEN4lCc+eSuFw7U57eTxXcl HZIdQ7ZyKhg4ijcfD158tTfjOm9btd3fKYFUrktW0yYw8sD8WG5yyi+LWsq60Xq96Fmj1WxHpFw GAoN2OS3t9jvd2NEUQX6VdOLOluZaWGaTTOShL4wlqJ6+DLwN7Phxr5xaC9RInxKJAe3BouC27z H8MQFxJNrJWcDdQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org Instead of only returning a text message with GENL_SET_ERR_MSG(), NL_SET_ERR_MSG_ATTR() can help the userspace developers by also reporting which attribute is faulty. When the error is specific to an attribute, NL_SET_ERR_MSG_ATTR() is now used. The error messages have not been modified in this commit. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 20 ++++++++++++-------- net/mptcp/pm_userspace.c | 33 +++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index ab56630b1d9ce59af4603a5af37153d74c79dbb2..04ab3328c785e804322dbe4fc56da85a58b8e0ea 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1407,18 +1407,21 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) return ret; if (addr.addr.port && !address_use_port(&addr)) { - GENL_SET_ERR_MSG(info, "flags must have signal and not subflow when using port"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "flags must have signal and not subflow when using port"); return -EINVAL; } if (addr.flags & MPTCP_PM_ADDR_FLAG_SIGNAL && addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) { - GENL_SET_ERR_MSG(info, "flags mustn't have both signal and fullmesh"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "flags mustn't have both signal and fullmesh"); return -EINVAL; } if (addr.flags & MPTCP_PM_ADDR_FLAG_IMPLICIT) { - GENL_SET_ERR_MSG(info, "can't create IMPLICIT endpoint"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "can't create IMPLICIT endpoint"); return -EINVAL; } @@ -1616,7 +1619,7 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) spin_lock_bh(&pernet->lock); entry = __lookup_addr_by_id(pernet, addr.addr.id); if (!entry) { - GENL_SET_ERR_MSG(info, "address not found"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); spin_unlock_bh(&pernet->lock); return -EINVAL; } @@ -1802,7 +1805,7 @@ int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info) rcu_read_lock(); entry = __lookup_addr_by_id(pernet, addr.addr.id); if (!entry) { - GENL_SET_ERR_MSG(info, "address not found"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); ret = -EINVAL; goto unlock_fail; } @@ -2021,7 +2024,8 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) if (addr.addr.family == AF_UNSPEC) { lookup_by_id = 1; if (!addr.addr.id) { - GENL_SET_ERR_MSG(info, "missing address ID"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "missing address ID"); return -EOPNOTSUPP; } } @@ -2034,13 +2038,13 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) __lookup_addr(pernet, &addr.addr); if (!entry) { spin_unlock_bh(&pernet->lock); - GENL_SET_ERR_MSG(info, "address not found"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); return -EINVAL; } if ((addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { spin_unlock_bh(&pernet->lock); - GENL_SET_ERR_MSG(info, "invalid addr flags"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "invalid addr flags"); return -EINVAL; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 525dcb84353f946a24923a1345a6e4b20a60663b..8dddb16247363a11ba11bcb94c4557dd0cfd8745 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -189,7 +189,8 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in } if (!mptcp_pm_is_userspace(msk)) { - GENL_SET_ERR_MSG(info, "userspace PM not selected"); + NL_SET_ERR_MSG_ATTR(info->extack, token, + "userspace PM not selected"); sock_put((struct sock *)msk); return NULL; } @@ -220,20 +221,21 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) goto announce_err; if (addr_val.addr.id == 0) { - GENL_SET_ERR_MSG(info, "invalid addr id"); + NL_SET_ERR_MSG_ATTR(info->extack, addr, "invalid addr id"); err = -EINVAL; goto announce_err; } if (!(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { - GENL_SET_ERR_MSG(info, "invalid addr flags"); + NL_SET_ERR_MSG_ATTR(info->extack, addr, "invalid addr flags"); err = -EINVAL; goto announce_err; } err = mptcp_userspace_pm_append_new_local_addr(msk, &addr_val, false); if (err < 0) { - GENL_SET_ERR_MSG(info, "did not match address and id"); + NL_SET_ERR_MSG_ATTR(info->extack, addr, + "did not match address and id"); goto announce_err; } @@ -354,9 +356,9 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) err = 0; out: if (err) - GENL_SET_ERR_MSG_FMT(info, - "address with id %u not found", - id_val); + NL_SET_ERR_MSG_ATTR_FMT(info->extack, id, + "address with id %u not found", + id_val); sock_put(sk); return err; @@ -388,7 +390,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) goto create_err; if (entry.flags & MPTCP_PM_ADDR_FLAG_SIGNAL) { - GENL_SET_ERR_MSG(info, "invalid addr flags"); + NL_SET_ERR_MSG_ATTR(info->extack, laddr, "invalid addr flags"); err = -EINVAL; goto create_err; } @@ -407,7 +409,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) err = mptcp_userspace_pm_append_new_local_addr(msk, &entry, false); if (err < 0) { - GENL_SET_ERR_MSG(info, "did not match address and id"); + NL_SET_ERR_MSG_ATTR(info->extack, laddr, + "did not match address and id"); goto create_err; } @@ -528,13 +531,13 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info } if (!addr_l.addr.port) { - GENL_SET_ERR_MSG(info, "missing local port"); + NL_SET_ERR_MSG_ATTR(info->extack, laddr, "missing local port"); err = -EINVAL; goto destroy_err; } if (!addr_r.port) { - GENL_SET_ERR_MSG(info, "missing remote port"); + NL_SET_ERR_MSG_ATTR(info->extack, raddr, "missing remote port"); err = -EINVAL; goto destroy_err; } @@ -588,7 +591,8 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) goto set_flags_err; if (loc.addr.family == AF_UNSPEC) { - GENL_SET_ERR_MSG(info, "invalid local address family"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "invalid local address family"); ret = -EINVAL; goto set_flags_err; } @@ -599,7 +603,8 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) goto set_flags_err; if (rem.addr.family == AF_UNSPEC) { - GENL_SET_ERR_MSG(info, "invalid remote address family"); + NL_SET_ERR_MSG_ATTR(info->extack, attr_rem, + "invalid remote address family"); ret = -EINVAL; goto set_flags_err; } @@ -722,7 +727,7 @@ int mptcp_userspace_pm_get_addr(struct sk_buff *skb, spin_lock_bh(&msk->pm.lock); entry = mptcp_userspace_pm_lookup_addr_by_id(msk, addr.addr.id); if (!entry) { - GENL_SET_ERR_MSG(info, "address not found"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); ret = -EINVAL; goto unlock_fail; } From patchwork Fri Jan 17 18:41:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943898 X-Patchwork-Delegate: kuba@kernel.org 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 65FFA1DFE08; Fri, 17 Jan 2025 18:42:13 +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=1737139333; cv=none; b=QV7qXAZU2r2efK1nloIisdSFO8OHIw2XSNccPh45HICDRHXMjVez7azF0lw16g5O6frcM3tR9toiTuVq3YabfuO6w9zpVqMwaJCuJpd5RNJ1kPacr7hfRH2yw/+VbIN/lmNFq23XtFUfQacAFY8JtY5H2p5jyLPX7UVZiiJMKMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139333; c=relaxed/simple; bh=Xid79KRezN4YhYfSBbXxnXGqy4sFTqyai8Nz2wwthIQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VT8siEsTzIw5F7X98LAo7sc0EONbKQSHmWJNQFNfqLN24+9PqDHIcufk0JDgggQqFxlr1atdJMo7J+yFlQNO7qLvZiXLoPC4g8yoJbC/SdzGnrs5VBZTsZ2sDL0jEdXJYwDRhHFSlLQosHoTaiKqYYUvDMa7D5qKApGoAcqssa8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=STLBqNTy; 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="STLBqNTy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 198ACC4CEE2; Fri, 17 Jan 2025 18:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139333; bh=Xid79KRezN4YhYfSBbXxnXGqy4sFTqyai8Nz2wwthIQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=STLBqNTy1SehVCmKzzsXHu8lpvDJtIuod++bEnoXJK8GY2pegDlBlwek8E7DnZGcn Tc2z4TqwXRRG4OfOO8ifb5QvXw8tCJBgX7NAOLls9zorZXaeoIC8cvbCCQyM9zLVAr dGvHxIatnmuDjqowILFGWCPMdWu6/o5zE/ABrFhSnEldh5E6sspaSn4oJ8Uqp8xdGD 3IHqEU7sHTuIZNj+3y9r2la9Mndz7PYRiYnKDFYYeGG3NKSO9WaxlKrLRFMreqMBsN GiyQn7r2zMkcl9PNgAn2Ms3Y6TssRKXMC6iEUAIs1kNtLjJFdEu2Kj7Thw4vPu268E 66SubfbecoOMg== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:41 +0100 Subject: [PATCH net-next v2 09/15] mptcp: pm: make three pm wrappers static Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-9-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5676; i=matttbe@kernel.org; h=from:subject:message-id; bh=XWiaBBltaqmw0KW541qBtTILXfEM/Eu9eAIsZKblGzA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRq0m3v3b9wiJ6ZgAifofSDPJP1j0QSzYQrA SuY9dvyHwWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg cz/pD/9ZBDnHvK7xlIPl6LIGKQrzfcsLlL4osNrXvuowGSZRvllEckIRMT5KLHNeswdcJkYSVRm wjbsXLBOiL5CB8xeywzaMRiR5hZQAQsBSK2zaxL+60mjhpmCH7CZrkzH8xDC4I74WxrCNdWXgrN Es4XzC6HDicpOoDI2lRYg4LVnmYWHptuoaq/WhcaBsrEthuz4dmkOIMZx0TnGEi7ozK/1iJV3IF mjjIROMQTS5aolQNDIAO8cH+wqP0JTnkW5vfIWfkV4Yt6B0dKiZUdfKALZAFS6QgbI1dNrRHLXb 3KF5ZoQqRGuLZDsHNMk/5T+2fI02k1syOYK9+7fXA8vSaOjeLzyfEEcSxMOj4BiqFGhKe6FDAfn vC6lNjBq5xOruLWnDASerRFPuQndt8yETiCMOjBf7+LqoLUsyY5BDATFEe9twNZDwmbnq8b9lyJ CpXrc2jgE6gnVX8egFpk9UxkFURH7TuDb4cpzOi5kXNEr7QqcmLO3F3LBvIbAauv8fVVQYsEksg Ubo9I6/IUB8zHBmeWjnd2SBvN8xnfFUfAht8s1gHs1U8ZQB0yP2bHYn4khBKyVj9+4MH/AsdhM3 e5JXDiXHhSSZOO4hMjGyid4WckOBUKmr4GSCJt278qyM8V7GpLwiVw4JrIWEq515Ejj66wYp+zY xY0eXwPmBc9o7sA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang Three netlink functions: mptcp_pm_nl_get_addr_doit() mptcp_pm_nl_get_addr_dumpit() mptcp_pm_nl_set_flags_doit() are generic, implemented for each PM, in-kernel PM and userspace PM. It's clearer to move them from pm_netlink.c to pm.c. And the linked three path manager wrappers mptcp_pm_get_addr() mptcp_pm_dump_addr() mptcp_pm_set_flags() can be changed as static functions, no need to export them in protocol.h. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 23 ++++++++++++++++++++--- net/mptcp/pm_netlink.c | 16 ---------------- net/mptcp/protocol.h | 3 --- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 16c336c519403d0147c5a3ffe301d0238c5b250a..a29be5ff73a6b5ca8241a939f9a029bc39914374 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -10,6 +10,7 @@ #include "protocol.h" #include "mib.h" +#include "mptcp_pm_gen.h" /* path manager command handlers */ @@ -433,14 +434,19 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) return mptcp_pm_nl_is_backup(msk, &skc_local); } -int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) return mptcp_userspace_pm_get_addr(skb, info); return mptcp_pm_nl_get_addr(skb, info); } -int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) +int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) +{ + return mptcp_pm_get_addr(skb, info); +} + +static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) { const struct genl_info *info = genl_info_dump(cb); @@ -449,13 +455,24 @@ int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) return mptcp_pm_nl_dump_addr(msg, cb); } -int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, + struct netlink_callback *cb) +{ + return mptcp_pm_dump_addr(msg, cb); +} + +static int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) return mptcp_userspace_pm_set_flags(skb, info); return mptcp_pm_nl_set_flags(skb, info); } +int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) +{ + return mptcp_pm_set_flags(skb, info); +} + void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 04ab3328c785e804322dbe4fc56da85a58b8e0ea..460588833639e88c51a6e1f417bd4ba1a8039d47 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1827,11 +1827,6 @@ int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info) return ret; } -int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) -{ - return mptcp_pm_get_addr(skb, info); -} - int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) { @@ -1875,12 +1870,6 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, return msg->len; } -int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, - struct netlink_callback *cb) -{ - return mptcp_pm_dump_addr(msg, cb); -} - static int parse_limit(struct genl_info *info, int id, unsigned int *limit) { struct nlattr *attr = info->attrs[id]; @@ -2057,11 +2046,6 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) return 0; } -int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) -{ - return mptcp_pm_set_flags(skb, info); -} - static void mptcp_nl_mcast_send(struct net *net, struct sk_buff *nlskb, gfp_t gfp) { genlmsg_multicast_netns(&mptcp_genl_family, net, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 0174a5aad2796c6e943e618bb677a2baff6eab22..0b531b7a226d4e34bcd2314a6f2c94cd1dd49870 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1036,7 +1036,6 @@ bool mptcp_lookup_subflow_by_saddr(const struct list_head *list, const struct mptcp_addr_info *saddr); bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr); -int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info); int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info); int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info); int mptcp_pm_announce_addr(struct mptcp_sock *msk, @@ -1129,12 +1128,10 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_in bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc); bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc); bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc); -int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); -int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info); int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info); int mptcp_userspace_pm_get_addr(struct sk_buff *skb, struct genl_info *info); From patchwork Fri Jan 17 18:41:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943899 X-Patchwork-Delegate: kuba@kernel.org 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 0DA551DFDB1; Fri, 17 Jan 2025 18:42:16 +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=1737139336; cv=none; b=PVbEv3lmOG5zK6e8fCFmpn79dGNzv49qe2JQqBI1fwLbhd+tJyzekbTphl2OxiZGFm+v+eP6sf/8EFqXFjKuhTsTlAEUaMBFETs51ABmfC1hzsmLVjCoEhZSy0Ey0T4bSZnJCJ6fBc86mNCJAjBo326EB1r2xd6DfuLi3pj9RHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139336; c=relaxed/simple; bh=mvu6IUWOPRL/lhRbFIN3oa8PkJI7Jlzi4Oeq+icsrOg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k4t8IUn4TORtwt+iGtMovTl0MgKWAUbaM5nfn3DM9fiEcQFG3Vemzh4PzpRTNTzgosnjH14eEEDB8bLhEuCFQFA4nMk6Dzp14TBSABfhAbLNWxDhCDVMYozpg5HxuipkPIYuQjZNETMlzcgC8EVmfvDS2K7MX2u5Y1N7wy2ZNM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kiDPRfoz; 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="kiDPRfoz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5C31C4CEEA; Fri, 17 Jan 2025 18:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139335; bh=mvu6IUWOPRL/lhRbFIN3oa8PkJI7Jlzi4Oeq+icsrOg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kiDPRfozBhOZVrJD+sygJbPc8VRV7FGWpmjFzXR7Qwh3iaDHddmfctOa18xqbU+P0 /g/awRl9dQY5i8pHLTlR4TgFXp1kG2c4gslkM7ThaxAbYvO1T3aEKEbLjHGjCXThoR VJ1ESMEYBxdD9qQlhUF4fW1jla83xw2x5Kf7NdSyMR0VPQOhRE49418U3LTDZuwMme /LH/UxIPuwEfJ5CKUglh6br4cnspfE5izaC2xQXvgzV/ueeROv3q5S77q21deRuqHZ 5QOdTI0Kf2cnMetdzKMjT46np1bTk9px+E4TOKas+4EHfENoo0Ya2qYKYwtcmtM527 2M8Ohq7RUgGyg== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:42 +0100 Subject: [PATCH net-next v2 10/15] mptcp: pm: drop skb parameter of get_addr Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-10-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3370; i=matttbe@kernel.org; h=from:subject:message-id; bh=wh8luIyQXke/ISFO5psWlohlfPyOyFJOzmpg/L6wAMQ=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRqkgE8tciOV59JANkgq6NvyyQ6bT4zBDQcp 7UeOBUovJ+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c+/LEACjeEdrx9frDwRMnCT0bgxfzQj4WyIAiIFFJHfITLOD8K6R2lZv5GuR2jIGHVl+NSnKzxT 8DSGLCPPvMQiCYr4UE4wCiokJE6KGsDdLjyB7oEferXl5MRnruBqr371P9Au537VLia0nj03Ufr GgTZRB93+SMSTn5JlC1RU9Jkgzw7bt1srZoMLywZmQNvLwqwC8bY7uEWTT+H0tweG4RKE1kX4oG ltT3KhdHvyGQJOB6GT0UQ6BqYQE5mvIX9S1n5+6Fpx/5H39gzqOg1b6mapafHb/EHj/Bt65n/Lb ve4WxPpzBLBgHPZGhjHn2KtikNlk5MxtQGXlgPcpY+SIolZGfRIQTi+GHxjfs+vETuEXUKnXnRS DiNyTH7zVJo3C9T1CTqFcGdzj/6mtFKTv+QCg1kkmo+8vLgLW36onQIBEWmhtNg1lnGd+/KfrbN 2EBc7FGDgGz5J5dZL3OgCt5mKfSrOL7nVSBFlfn9aitfeC8cVYZ5oQxD7XUCTo+uwMyp7AaVujW SNg0xWxlIwpWD4OkmdefrKGhYWuvcoZBajDdzTw24K0dOWfZlGFkDdnChMjqcHSEe4YO771r8fm g3H3DcvJZ4JRjiLljhAtZHBjem7Xk43asEOmpEHseQks3qaDVuuvVkUnxOjP5sunHLfJxFfQ98X bZvb39FuDS3j2Jg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The first parameters 'skb' of get_addr() interfaces are now useless since mptcp_userspace_pm_get_sock() helper is used. This patch drops these useless parameters of them. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 8 ++++---- net/mptcp/pm_netlink.c | 2 +- net/mptcp/pm_userspace.c | 3 +-- net/mptcp/protocol.h | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index a29be5ff73a6b5ca8241a939f9a029bc39914374..526e5bca1fa1bb67acb8532ad8b8b819d2f5151c 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -434,16 +434,16 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) return mptcp_pm_nl_is_backup(msk, &skc_local); } -static int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_get_addr(struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_get_addr(skb, info); - return mptcp_pm_nl_get_addr(skb, info); + return mptcp_userspace_pm_get_addr(info); + return mptcp_pm_nl_get_addr(info); } int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { - return mptcp_pm_get_addr(skb, info); + return mptcp_pm_get_addr(info); } static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 460588833639e88c51a6e1f417bd4ba1a8039d47..853b1ea8680ae753fcb882d8b8f4486519798503 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1773,7 +1773,7 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } -int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_get_addr(struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 8dddb16247363a11ba11bcb94c4557dd0cfd8745..1246063598c8152eb908586dc2e3bcacaaba0a91 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -684,8 +684,7 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, return ret; } -int mptcp_userspace_pm_get_addr(struct sk_buff *skb, - struct genl_info *info) +int mptcp_userspace_pm_get_addr(struct genl_info *info) { struct mptcp_pm_addr_entry addr, *entry; struct mptcp_sock *msk; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 0b531b7a226d4e34bcd2314a6f2c94cd1dd49870..7fe91a2e170dd40a830c4301960b484017fd11d2 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1132,9 +1132,8 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); -int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info); -int mptcp_userspace_pm_get_addr(struct sk_buff *skb, - struct genl_info *info); +int mptcp_pm_nl_get_addr(struct genl_info *info); +int mptcp_userspace_pm_get_addr(struct genl_info *info); static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflow) { From patchwork Fri Jan 17 18:41:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943900 X-Patchwork-Delegate: kuba@kernel.org 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 A6FC71E9B1D; Fri, 17 Jan 2025 18:42:18 +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=1737139338; cv=none; b=STDPh7AHnLUqoZszROG99QBPa0cfdcN50zzzSDd3Y/1UNREwujVqFZqyJ/RNd6rK8kPJwV0bTe2GQHkxvbBPYa1qgG5B9vt72DjftDaDmsnsYC8aYElwd3NOFjd0B96h6wdAXocXSb2E5qmkajjeB3FQpXVL7TBqgJ7qbqMT6Y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139338; c=relaxed/simple; bh=aUS1NonvHy253RG7iD6V+MotJ2vT0l3meNzJIfFovpU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=adtRX3A1zdo2qwDeJJBSy3sujj+7uu993Dh0xiI2R6GVfYmon+/fIHZP/iKP8q2JTAkAajbSQufdCHxrXeqQCiDYdVSiA2HUhmlFFkjm+vTDsHwwDw+mnqDwOj9ECy1+DNpBZCj0hJMrmoGIDSsuqCRLY/ZgQzZ2sfZ/hJkGgOI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=la+Ee7F1; 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="la+Ee7F1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B894C4CEE8; Fri, 17 Jan 2025 18:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139338; bh=aUS1NonvHy253RG7iD6V+MotJ2vT0l3meNzJIfFovpU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=la+Ee7F1UcSXW8/j6Dw9Nzc5BCapmRie/w0IoybXXpMptCDAKNBAZT76eACefmuFp 0JQwnLKlFJoth4WNgqHasljTY3teGkcVNBFnEycGl6C4Yn5e8ZoD6UGhoH+cHd85LB XuAXi4W3xlzKxYyYqSE0MaEJXTX+/xcPgRYT1D0jER44S4NczDN2QmhG1bbD6EDpGY t5eio10rU4+rG3ptzwvlWTa4hWmpJFp0ngxvFHDOKaZS2GBfE6LqbuXYHbYdi2KhTW gfKCeqx//pm3fn0Xo3jSBSeHvnS3cZTblUXJC7zjed9nNX9VujmNbEUo5HPpISY/Fx famivKFT6aWFw== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:43 +0100 Subject: [PATCH net-next v2 11/15] mptcp: pm: add id parameter for get_addr Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-11-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5703; i=matttbe@kernel.org; h=from:subject:message-id; bh=w8FZxi4P8R7OyWva5g/VZWDB0AeZXhr4vEcDgu3NcOc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRqBdj9OLUibJqB+H2AWRAC1XFykdZroLknw XTb0I++bkeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c/BgD/4wCTI/jGwFong5zJdzwalo2365/2Ob6WB1iCEe7tkXjlmSiU+eD5lEAjDWe1Ae7L0HxI4 fG2uVSz9yTcNSqz+398V/Fr9QSTYRja2gtK/hKAF6552P0LO0OJXBC8wdwolB4zWe7iDmZfRO1a rQpEenaIE5HxaaErJk3IiCHFDDkDH0KOWwXZegfwHoyJ14IdEcYifI+IWn+7HpvLYVf0JFt9rJb 2KybjJvDomLlsvqb2exiTXaXlplulMo2/jilr6FjnVapJg2noF44c9F+jNfX+ihWD15xBHLijp8 LDiVjHT4mw2aZ/lbEJmGQ7ERu4VWqAiXvmiP4O1C9QP4kFkUVlxj4VJ6GyDiPM/nLNjh7SP6o1z uk/XmyTdN+jjUUZsvNPZ8u55QoS2eWGK41dRdB5HqM6VodWXoR7wW1WO72c2vwYYvBfmtTPyFcM FZO3GfgWqSXxgMdzFa2UuaoQY/YSOOu84TZqywwnZRCGJ6U4TB4LAp63LlnXefKq6Gz6BbYBfJ4 1VG/YW4ub4+OExAkKCNJwiOtN9DvYDH3PtWmTx+r3jdHzTX52SRsR+qBmjznfzwyXYWMlo6Y3Lc GC2lvxenldQBQkQqetjk+E+nl8bNB4BNVXnrdJeWKOurFyzUv30yvtLxsrV+pxzv9T8nr6iWv9G arb/Y+/1+R6hxHA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The address id is parsed both in mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive. So this patch adds a new parameter 'id' for all get_addr() interfaces. The address id is only parsed in mptcp_pm_nl_get_addr_doit(), then pass it to both mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- v2: - Fix 'attr' no longer being set in mptcp_pm_nl_get_addr(), but still used in this patch (no longer in the next one). (Simon) --- net/mptcp/pm.c | 20 ++++++++++++++++---- net/mptcp/pm_netlink.c | 16 ++++------------ net/mptcp/pm_userspace.c | 14 +++----------- net/mptcp/protocol.h | 4 ++-- 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 526e5bca1fa1bb67acb8532ad8b8b819d2f5151c..caf5bfc3cd1ddeb22799c28dec3d19b30467b169 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -434,16 +434,28 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) return mptcp_pm_nl_is_backup(msk, &skc_local); } -static int mptcp_pm_get_addr(struct genl_info *info) +static int mptcp_pm_get_addr(u8 id, struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_get_addr(info); - return mptcp_pm_nl_get_addr(info); + return mptcp_userspace_pm_get_addr(id, info); + return mptcp_pm_nl_get_addr(id, info); } int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { - return mptcp_pm_get_addr(info); + struct mptcp_pm_addr_entry addr; + struct nlattr *attr; + int ret; + + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return -EINVAL; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; + ret = mptcp_pm_parse_entry(attr, info, false, &addr); + if (ret < 0) + return ret; + + return mptcp_pm_get_addr(addr.addr.id, info); } static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 853b1ea8680ae753fcb882d8b8f4486519798503..f7da750ab94f7bbffafb258cb0d6ff01ad59c0b0 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1773,23 +1773,15 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } -int mptcp_pm_nl_get_addr(struct genl_info *info) +int mptcp_pm_nl_get_addr(u8 id, struct genl_info *info) { + struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); - struct mptcp_pm_addr_entry addr, *entry; + struct mptcp_pm_addr_entry *entry; struct sk_buff *msg; - struct nlattr *attr; void *reply; int ret; - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) - return -EINVAL; - - attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; - ret = mptcp_pm_parse_entry(attr, info, false, &addr); - if (ret < 0) - return ret; - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!msg) return -ENOMEM; @@ -1803,7 +1795,7 @@ int mptcp_pm_nl_get_addr(struct genl_info *info) } rcu_read_lock(); - entry = __lookup_addr_by_id(pernet, addr.addr.id); + entry = __lookup_addr_by_id(pernet, id); if (!entry) { NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); ret = -EINVAL; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 1246063598c8152eb908586dc2e3bcacaaba0a91..79e2d12e088805ff3f59ecf41f5092df9823c1b4 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -684,9 +684,9 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, return ret; } -int mptcp_userspace_pm_get_addr(struct genl_info *info) +int mptcp_userspace_pm_get_addr(u8 id, struct genl_info *info) { - struct mptcp_pm_addr_entry addr, *entry; + struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; struct sk_buff *msg; struct nlattr *attr; @@ -694,20 +694,12 @@ int mptcp_userspace_pm_get_addr(struct genl_info *info) struct sock *sk; void *reply; - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) - return ret; - msk = mptcp_userspace_pm_get_sock(info); if (!msk) return ret; sk = (struct sock *)msk; - attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; - ret = mptcp_pm_parse_entry(attr, info, false, &addr); - if (ret < 0) - goto out; - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!msg) { ret = -ENOMEM; @@ -724,7 +716,7 @@ int mptcp_userspace_pm_get_addr(struct genl_info *info) lock_sock(sk); spin_lock_bh(&msk->pm.lock); - entry = mptcp_userspace_pm_lookup_addr_by_id(msk, addr.addr.id); + entry = mptcp_userspace_pm_lookup_addr_by_id(msk, id); if (!entry) { NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); ret = -EINVAL; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 7fe91a2e170dd40a830c4301960b484017fd11d2..e77920c932442ce1d317fcda8d2561e11d0c2a12 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1132,8 +1132,8 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); -int mptcp_pm_nl_get_addr(struct genl_info *info); -int mptcp_userspace_pm_get_addr(struct genl_info *info); +int mptcp_pm_nl_get_addr(u8 id, struct genl_info *info); +int mptcp_userspace_pm_get_addr(u8 id, struct genl_info *info); static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflow) { From patchwork Fri Jan 17 18:41:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943901 X-Patchwork-Delegate: kuba@kernel.org 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 5784D1E9B30; Fri, 17 Jan 2025 18:42:21 +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=1737139341; cv=none; b=luiJ2tXhnhURUIqn+bVaQn5JAOX5Yoj5O49xDlZXHbwwqeJUfZqbcUGkSBA7XgLRBaAmo80F2pSiEOL4TPVNwGasO10BwbqW+tgFalv7PYJMzIpFsfzm0TBei9cx7reEcbkSks1/QY6GNclIGjW6FSG0jdZht3z6N62wRXpvMtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139341; c=relaxed/simple; bh=9u+/VKZ34P5LSRqFv/rwCW65UeDrQMZmaRDeDt+4A1w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VMmg2KYnZs6+EufylRRPQ8jNSN0nN3EXllR28OhIMD3ZqHCXOTgBCmqx7QNDHhRm3paj7JRqbT7uDfM9kEEqHgy/wTpVgke5kbrHe25PkiPLcmPfJf9SytUnkAdzFDURtRiXOXHyF/eL0qApEc2W54Y8ucYSsFHsu2tMWAiQIRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dW1c7BmR; 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="dW1c7BmR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02BEDC4CEE3; Fri, 17 Jan 2025 18:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139341; bh=9u+/VKZ34P5LSRqFv/rwCW65UeDrQMZmaRDeDt+4A1w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dW1c7BmRu8pA3Ovz0n6AUx0nyK9QeWibU94KWRnYuvHx+Ugngt78U7lAk8Q2ed1PA XFGx1S5pUQ+j/jUBvkYebxehuqGPHJQvQUofTHZdorLvAQoPmfGI5dyiyiXJCd+kV4 Bj1VhWiY9kh8l6j+rUkTc74BTa9fGhBTUi+F2ghbDDn5459nlPswwTSs+Fyuk0HBR1 tqRVinbJmdrjW9hL1W4EyWTAf7r6ValSF4e1m8vtNKZBw78h6E6IAY4YIFM7Kjb3pR 8YCnNVjuHhPB7pEC/kY6s9IOu6UeH/q5bMKS9fWVcRUWmPIMzJJGR7TTAHodXT47m6 q++wrm+GDNb9A== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:44 +0100 Subject: [PATCH net-next v2 12/15] mptcp: pm: reuse sending nlmsg code in get_addr Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-12-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7785; i=matttbe@kernel.org; h=from:subject:message-id; bh=fGPOONHoCNG2FPYHS9oXy/D99TGo0X9EGEq6XNuLdfI=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRq558wUTo4XH4qMUhtS61crl8z6D7wE4nfd FVcdv798xmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c2j7D/0SRHFmmpjHlsFKrtGsrQZceHVe0dsjV/nsnQWd4drz4ZgmMFtv/x/e4GrzAMN1G9mtke9 F4f7nlwsC7uCynKCA4xKFz9nOTDjXXyq7O9B091kZZK3N9rYfMEvWn786/4KM93B/gIOuJ/U3Wb tcsodp1gzm1CNysH2oDel5qQCgI0MtVS4IOPw6MTj1eqd7DUZJgbhg6BEp/SOLzcE1halhRf09J K8TiuQHbCcNp1t0fIRBu9ScEPObLaKuHBCtzEz84Y9Xe2zmxBUeYFMKTPpIfWEfBXUSKG9oB/BI 77hjrMrDgv1cYOqOp/uhkjGGiETNRQuROWS1qvtkoyqxlwoFvxRmUXOU6KAu5DxTvM2nJ7WRq6v YX6X90EgpbDMZJbm1NN7b7LXZ6qh6obg4aBzBnRVxys0FMW7TigaQMwWbYbPg++7iLk3eJI3PN/ MqzLto0lE7rtF4AXxL1Z/iSdOwixfwjUDWNZDou21r0lzhkLc5SHZw4Too7sGeB8kHb7XlgYZKR GI1yi1kwfbsxSWJH3IYzDZUtvapUMKo5wHggJ1g2btiTbHIbgUO/kSvBeGG9OCgAnUgyNeweLTy FkI6Bac3vJfOueFTqVB03mXpJOZXWpKzHVoUUBKvwPy5oKVPpg/HIehMjIl2RUDtlLdBKisbbM+ h647wlnlfGrPvug== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The netlink messages are sent both in mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive. This is because the netlink PM and userspace PM use different locks to protect the address entry that needs to be sent via the netlink message. The former uses rcu read lock, and the latter uses msk->pm.lock. The current get_addr() flow looks like this: lock(); entry = get_entry(); send_nlmsg(entry); unlock(); After holding the lock, get the entry from the list, send the entry, and finally release the lock. This patch changes the process by getting the entry while holding the lock, then making a copy of the entry so that the lock can be released. Finally, the copy of the entry is sent without locking: lock(); entry = get_entry(); *copy = *entry; unlock(); send_nlmsg(copy); This way we can reuse the send_nlmsg() code in get_addr() interfaces between the netlink PM and userspace PM. They only need to implement their own get_addr() interfaces to hold the different locks, get the entry from the different lists, then release the locks. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 39 +++++++++++++++++++++++++++++++++++---- net/mptcp/pm_netlink.c | 40 ++++++---------------------------------- net/mptcp/pm_userspace.c | 42 +++++------------------------------------- net/mptcp/protocol.h | 6 ++++-- 4 files changed, 50 insertions(+), 77 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index caf5bfc3cd1ddeb22799c28dec3d19b30467b169..ba22d17c145186476c984d1eb27b102af986a0cd 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -434,17 +434,20 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) return mptcp_pm_nl_is_backup(msk, &skc_local); } -static int mptcp_pm_get_addr(u8 id, struct genl_info *info) +static int mptcp_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, + struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_get_addr(id, info); - return mptcp_pm_nl_get_addr(id, info); + return mptcp_userspace_pm_get_addr(id, addr, info); + return mptcp_pm_nl_get_addr(id, addr, info); } int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry addr; struct nlattr *attr; + struct sk_buff *msg; + void *reply; int ret; if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) @@ -455,7 +458,35 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) if (ret < 0) return ret; - return mptcp_pm_get_addr(addr.addr.id, info); + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!msg) + return -ENOMEM; + + reply = genlmsg_put_reply(msg, info, &mptcp_genl_family, 0, + info->genlhdr->cmd); + if (!reply) { + GENL_SET_ERR_MSG(info, "not enough space in Netlink message"); + ret = -EMSGSIZE; + goto fail; + } + + ret = mptcp_pm_get_addr(addr.addr.id, &addr, info); + if (ret) { + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); + goto fail; + } + + ret = mptcp_nl_fill_addr(msg, &addr); + if (ret) + goto fail; + + genlmsg_end(msg, reply); + ret = genlmsg_reply(msg, info); + return ret; + +fail: + nlmsg_free(msg); + return ret; } static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index f7da750ab94f7bbffafb258cb0d6ff01ad59c0b0..d86887004781e9020061394c350e4710b68cc22f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1773,49 +1773,21 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } -int mptcp_pm_nl_get_addr(u8 id, struct genl_info *info) +int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, + struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry *entry; - struct sk_buff *msg; - void *reply; - int ret; - - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); - if (!msg) - return -ENOMEM; - - reply = genlmsg_put_reply(msg, info, &mptcp_genl_family, 0, - info->genlhdr->cmd); - if (!reply) { - GENL_SET_ERR_MSG(info, "not enough space in Netlink message"); - ret = -EMSGSIZE; - goto fail; - } + int ret = -EINVAL; rcu_read_lock(); entry = __lookup_addr_by_id(pernet, id); - if (!entry) { - NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); - ret = -EINVAL; - goto unlock_fail; + if (entry) { + *addr = *entry; + ret = 0; } - - ret = mptcp_nl_fill_addr(msg, entry); - if (ret) - goto unlock_fail; - - genlmsg_end(msg, reply); - ret = genlmsg_reply(msg, info); - rcu_read_unlock(); - return ret; - -unlock_fail: rcu_read_unlock(); -fail: - nlmsg_free(msg); return ret; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 79e2d12e088805ff3f59ecf41f5092df9823c1b4..80d75df18b039dc60ca5c4432da44a1a9dbf33f1 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -684,15 +684,13 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, return ret; } -int mptcp_userspace_pm_get_addr(u8 id, struct genl_info *info) +int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, + struct genl_info *info) { struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; - struct sk_buff *msg; - struct nlattr *attr; int ret = -EINVAL; struct sock *sk; - void *reply; msk = mptcp_userspace_pm_get_sock(info); if (!msk) @@ -700,46 +698,16 @@ int mptcp_userspace_pm_get_addr(u8 id, struct genl_info *info) sk = (struct sock *)msk; - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); - if (!msg) { - ret = -ENOMEM; - goto out; - } - - reply = genlmsg_put_reply(msg, info, &mptcp_genl_family, 0, - info->genlhdr->cmd); - if (!reply) { - GENL_SET_ERR_MSG(info, "not enough space in Netlink message"); - ret = -EMSGSIZE; - goto fail; - } - lock_sock(sk); spin_lock_bh(&msk->pm.lock); entry = mptcp_userspace_pm_lookup_addr_by_id(msk, id); - if (!entry) { - NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); - ret = -EINVAL; - goto unlock_fail; + if (entry) { + *addr = *entry; + ret = 0; } - - ret = mptcp_nl_fill_addr(msg, entry); - if (ret) - goto unlock_fail; - - genlmsg_end(msg, reply); - ret = genlmsg_reply(msg, info); spin_unlock_bh(&msk->pm.lock); release_sock(sk); - sock_put(sk); - return ret; -unlock_fail: - spin_unlock_bh(&msk->pm.lock); - release_sock(sk); -fail: - nlmsg_free(msg); -out: sock_put(sk); return ret; } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index e77920c932442ce1d317fcda8d2561e11d0c2a12..48a1028116efc3c325b1c1976fad04054bad9474 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1132,8 +1132,10 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb); -int mptcp_pm_nl_get_addr(u8 id, struct genl_info *info); -int mptcp_userspace_pm_get_addr(u8 id, struct genl_info *info); +int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, + struct genl_info *info); +int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, + struct genl_info *info); static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflow) { From patchwork Fri Jan 17 18:41:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943902 X-Patchwork-Delegate: kuba@kernel.org 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 504331EBFE0; Fri, 17 Jan 2025 18:42:23 +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=1737139344; cv=none; b=MfHe6+WTZTBrb7mhkfsQCheqpwMWWY0rFmQLYUX7MoXXBPFDZfAR7rDVDveicyD4WejOyHdDV+7enCrkru+vJfrFBoI4MKZP7enoEVG8PU8Uijq3gMB9Dfwz8neeuoLtgjOE0f/krZquaFNnEO5Mu85yLdhnfm0WjopRSaRFRgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139344; c=relaxed/simple; bh=Lo42uiy/Ey8jGg3oFe9uM66JR1ID3zP02Tdudc9cHaU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d7TLymloN6qSJTtw/f1NOOwQ+Fj18lIFWjiVKS0zo4Lkf2RgGwuy2PtQALwlpiVgz22e5jdjsXtTwvciDgX6wLMpbCDQ/AGp2WCww/QBzRDnWsQ0ocBjQuMebL31MsVIcCXm0vO4rjP39081eytK7rQ/uHrwn6D6gLVfaY5k2/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oCTXdfg5; 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="oCTXdfg5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A23A0C4CEE2; Fri, 17 Jan 2025 18:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139343; bh=Lo42uiy/Ey8jGg3oFe9uM66JR1ID3zP02Tdudc9cHaU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oCTXdfg5raM/6/ir5VlZVpoq9SzlH3TIMeqbqLgFO8Qx4+qU5E4ZSZygZzA5muP/c rai3RZ3Z2yeoUGQBbCKV+FubfKg+cmDYMLigMaRExZt9NpV/W4TeSM+gg8OuRFshdS cCht/ZIHiGqTOxOMH41OPTv4mpgbJGFtREG/xors4SH3BLlMAmbyM89W+TQ1qVJm9W kBB0+iYMIPFa4Bbj2yDFNwWgawIcxpI3U6FUV9jelaVu5axFxZ1gCOwjpQLBh0ZQ+V ANGyhtvkHOSE1Y1HaVDuVnlIMk9UCo849xzirHMq3rRZsZuuu3XIE6zXqbsPR4PDaA 5z4rp/4eGrAqA== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:45 +0100 Subject: [PATCH net-next v2 13/15] mptcp: pm: drop skb parameter of set_flags Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-13-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3871; i=matttbe@kernel.org; h=from:subject:message-id; bh=gUqz4ZQZTa4dp9KdO1e/L9oQx71wboHJUneFiBj4Ge4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRqNODMb02OBX10nTe03cUUwMxr9oeGT5N5l fv7hhIkMFaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkagAKCRD2t4JPQmmg c74xEADeUkL6aTkzMKNJmp0PznRHYtr1T1y8Ees0aG/mULzYki1qK5zbBKoUkuIrReO4LHugtvu Dsm819XbeunYbrvb8v2azNH4Z3UJ/NaW2nmTOZj2c20CVozuI/Dom6StXrq/ZyVcoCL0R/lrexP BkBUZiey2BJmuXqU8npS8ZBLxBYgOmI0GD7WfnzwGohxHMDtbKi7TXRTzPBwXIGMsf55WB1pdy9 5PddICxVMcVu7LzwNQBBLX1ggUSOJ2xd8KjPwBBUhlFEArNoo1X8LRp0NwpjZoeoeNgjVM/VV4N wIpYSsXwdURaVFHXw0FrTsicGnhyQ93yeMIXL6kEf0Hh4jDK1mrReZD8XCAnsPKidkqBrri4HAL C7sslR002lm/ujSF9cK+3Tjzkq/3a+udxz5aVZVh2JwAkXPhxmXAMzYo6znZFwo/qS360/9R/PO gt77AJ6S232AhSo2ofb1z/FCKnHSK5TpABjq64jFDssYJ3SWHoyXiGNeNIYWZHngbwkubIBwYeL iZjLPOBb29QqYlyiLd6L039iDBOePLZ6icDcck9D2gpCWfheRRFLdW3BLpSDsQ0a2B0lwa0hzAI 5GxTEoxj7g+C6VApcrwhwAGf8pkHQ2r0zUFAKN7Ng2Dr2YR7b2+1YCiL1y65mmBrWsCR5N6OJKo s3SJj1nUSU51COA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The first parameter 'skb' in mptcp_pm_nl_set_flags() is only used to obtained the network namespace, which can also be obtained through the second parameters 'info' by using genl_info_net() helper. This patch drops these useless parameters 'skb' in all three set_flags() interfaces. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 8 ++++---- net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index ba22d17c145186476c984d1eb27b102af986a0cd..c213f06bc70234ad3cb84d43971f6eb4aa6ff429 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -504,16 +504,16 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, return mptcp_pm_dump_addr(msg, cb); } -static int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_set_flags(struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_set_flags(skb, info); - return mptcp_pm_nl_set_flags(skb, info); + return mptcp_userspace_pm_set_flags(info); + return mptcp_pm_nl_set_flags(info); } int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) { - return mptcp_pm_set_flags(skb, info); + return mptcp_pm_set_flags(info); } void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d86887004781e9020061394c350e4710b68cc22f..c2101f7ca31e648aa72ff0890ba3a0801c1bf674 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1951,12 +1951,12 @@ static int mptcp_nl_set_flags(struct net *net, return ret; } -int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_set_flags(struct genl_info *info) { struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP | MPTCP_PM_ADDR_FLAG_FULLMESH; - struct net *net = sock_net(skb->sk); + struct net *net = genl_info_net(info); struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; struct nlattr *attr; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 80d75df18b039dc60ca5c4432da44a1a9dbf33f1..4fa3935c5b477dcb50260b3a041b987d5d83b9f0 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -564,7 +564,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info return err; } -int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) +int mptcp_userspace_pm_set_flags(struct genl_info *info) { struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; struct mptcp_pm_addr_entry rem = { .addr = { .family = AF_UNSPEC }, }; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 48a1028116efc3c325b1c1976fad04054bad9474..0fc74e567329f005096cb0769f4fcf4a5019f532 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1036,8 +1036,8 @@ bool mptcp_lookup_subflow_by_saddr(const struct list_head *list, const struct mptcp_addr_info *saddr); bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr); -int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info); -int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_set_flags(struct genl_info *info); +int mptcp_userspace_pm_set_flags(struct genl_info *info); int mptcp_pm_announce_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr, bool echo); From patchwork Fri Jan 17 18:41:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943903 X-Patchwork-Delegate: kuba@kernel.org 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 F214A1EBFF8; Fri, 17 Jan 2025 18:42:26 +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=1737139347; cv=none; b=rVSKcMKyIayPePWkR2YpcrDVbl653SBCUQ6kRRvFQbhhl5y+uOAyrVGsIZLgAmXALNcsU5uaC1aY2vcgKIDrZFSJgcALgSoXU3Sp2NX2WqFb4w6+zGJAEvh0IvfDf+khphKalBkujhVZYzU+eAyNtxPerb1uoys4SB+X9hWEUt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139347; c=relaxed/simple; bh=gBNXX9ppG946EXfwDDL/S6hzfb1PJK8Xt2CCfsMNeRs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZNbmezHNyKeebSRzCcGLXwiowH2y/JLw0Qr7K10yaG9T7PceC+Lorcs42bTihY2GGZMhsb1YC7RKidHEkRaTUaZxwo0tEE4UxoaHbmQ490L9eByH67VgUWGUlNo/XFQfMZYDB2D1J1vhHSo7yLRa/7z3uH/b0O0coshaFqvbcp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h5vv66EZ; 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="h5vv66EZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46D39C4CEE3; Fri, 17 Jan 2025 18:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139346; bh=gBNXX9ppG946EXfwDDL/S6hzfb1PJK8Xt2CCfsMNeRs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=h5vv66EZpbw2frzQ5mMMj8iaBFYdOKYNFVKb4GmvkkgdwT8subbBsemlVGcEBeaOR ypF6fSmCP59BnZHH8RepA5vcOkmet7t0z46IbfToMs4FuB+PWIpO7aBIb9eB/nr/dZ JK3w3i69lHyXfqy6wqEYT4w9eVZwBxOVswT5YCyglHzOEN5VmcaEwf4Gz7KcWY9Oyt o3tCfdLdcyCJ6qkZxCQGVjC44/TaKF8D4wLEfPXBcB9TevHDLlkThrt7rjO/jIgHPP fWhZbx7wDvYi+6cRifKPmLOOD5q9/Mo6QfioDOBG6LAlSBfAeGw/YE2GyA4aR3B7dn e4c+cKCcwwDyw== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:46 +0100 Subject: [PATCH net-next v2 14/15] mptcp: pm: change rem type of set_flags Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-14-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2314; i=matttbe@kernel.org; h=from:subject:message-id; bh=CVowOfogh0VIETqdYsiGlawSG6f73txjSRWz/bdF42w=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRrVWAOiYAFe+ymgVjCLDSfV8y3CEFNWe/kE SK8DZuqy3SJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkawAKCRD2t4JPQmmg c1/jEACP9yO1Eot9s+qMwdePso1MzeWnd+sUh5VxyRBj1Pea7TmqgJCINxdkpMPDUOjXV4FwMBv WXnfTSQMQfdfyjupMsDPaODpJRPffelT5QJfmi36YMwmM2kfNtXXLhY9qi0k9a08A8ZPxjClAhW q1dHjxE8LAbsbD+tuyif1AtgHJO3EyPT+SyVom0qtvKKp7SprwJaIQXITR2lz8dIdM/6POkpasr dR/u3Zun+DDnCqmBj6umMtzuDjS2PBLNcnUNLIYsk0xa0j/DxnwYHIBIRSgPdQkVjOUjXTi/1vQ 6b2M6JUUEwj1GojW8rs2ORy+N/o3eYzEQ3AKMMuDnwNwfTjPxAUmYsBtZE1k7kql+h5by+cvzbM /hgoWOELG3ry7WuuNf7jdEOcdJfyVRgJJ5ghHhe1vli8VsvqeMdD8Yp3ta4ve8DL9gf3lLFYelI ADk7/PkcTc8I5sVpLZBej/ZyVjUhUbRDT15tM0LMEs5uaQX/ZebGrPf7dkvTtIE4k3TwGIVLHWw TKkw3XxslTPZJ2w/KEWNMcms9qyx3mSihq7128hvxJRMg35mOwvyNeqVQxe6cNPzVAq/3hKWucl h9F3+EIQtIWV1/QHcuzeZFQQ2xq9RzSDKIhQP05ik3b8KOrEsm6vctm4UCcXd8xtXE5dhWul+cf +zS5CcrJxzB/iYw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang Generally, in the path manager interfaces, the local address is defined as an mptcp_pm_addr_entry type address, while the remote address is defined as an mptcp_addr_info type one: (struct mptcp_pm_addr_entry *local, struct mptcp_addr_info *remote) But the set_flags() interface uses two mptcp_pm_addr_entry type parameters. This patch changes the second one to mptcp_addr_info type and use helper mptcp_pm_parse_addr() to parse it instead of using mptcp_pm_parse_entry(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 4fa3935c5b477dcb50260b3a041b987d5d83b9f0..1af70828c03c21d03a25f3747132014dcdc5c0e8 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -567,7 +567,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info int mptcp_userspace_pm_set_flags(struct genl_info *info) { struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; - struct mptcp_pm_addr_entry rem = { .addr = { .family = AF_UNSPEC }, }; + struct mptcp_addr_info rem = { .family = AF_UNSPEC, }; struct mptcp_pm_addr_entry *entry; struct nlattr *attr, *attr_rem; struct mptcp_sock *msk; @@ -598,11 +598,11 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) } attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; - ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); + ret = mptcp_pm_parse_addr(attr_rem, info, &rem); if (ret < 0) goto set_flags_err; - if (rem.addr.family == AF_UNSPEC) { + if (rem.family == AF_UNSPEC) { NL_SET_ERR_MSG_ATTR(info->extack, attr_rem, "invalid remote address family"); ret = -EINVAL; @@ -623,7 +623,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) spin_unlock_bh(&msk->pm.lock); lock_sock(sk); - ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup); + ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem, bkup); release_sock(sk); /* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */ From patchwork Fri Jan 17 18:41:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13943904 X-Patchwork-Delegate: kuba@kernel.org 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 91EDE1EBA08; Fri, 17 Jan 2025 18:42:29 +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=1737139349; cv=none; b=jI/M8YzfV0Ln8uWZOViJluA827I9+n8SoSdVBXuQ7sLVGQcmeIkvLwVfj4QViKoaMh2sjLulPxHT4pojYik/zjtfd2pvUddxTxG2TSt4exRmfN6aWt1IyiXqvFdCvuZgKMeFFJ0vLmHZMZEDWFzo4Tg8w06ORv8BkkSKlwW3gpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737139349; c=relaxed/simple; bh=wx/MAt8aTDGMMZUp/3rZvd7r6+B3dtTjjmLAqsXJjSE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QWnNpu1UOZkH7qa0Vo4cPRJdxRZulq/iyH47inY2GLCraQMOOxIOLux0BawrSqvlvk/q09EpkZqWAmWHnMwuUprqlOuTLvWkpPkCZqsmyNHqhWB0BImG3MzCkZnVtU3yW2EfgWCJ9NG3FuPzCXheuAUgi9T0xMEE0CFR8mdSpGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fmmv+W6N; 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="Fmmv+W6N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEC3EC4CEE0; Fri, 17 Jan 2025 18:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737139349; bh=wx/MAt8aTDGMMZUp/3rZvd7r6+B3dtTjjmLAqsXJjSE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Fmmv+W6NLGXmYXB41BrG8p4A61FL43hx4T+NvQNE2nW626mLXHpKgi7QI8ltJLRKQ DNb623zVWkPnvUfDLfOX34vRPhF1uvkhEsawzIpnjiAubUOhmcK0LbTDVhLKTT0Q9B Dtd1ibvmLSS5zoxYAWqslo0WJPVsvBOg722yjoXUEOZAffS0pH8Nv24sUg3atoPXKK 5VoJ53fbmD661LxAU4AYPvm39u4Yo+z3wx/sNQulThtjBrh+AlaomAF2x/4RSa/JYY MZ16Xfof04AvN0ZxifLk6hRD2EbNpebjiqFn2VJwaFg+ue4BhKGt/AyeXEVHnBoklM WdGuJsxEGDCoQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 17 Jan 2025 19:41:47 +0100 Subject: [PATCH net-next v2 15/15] mptcp: pm: add local parameter for set_flags Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-15-61d4fe0586e8@kernel.org> References: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> In-Reply-To: <20250117-net-next-mptcp-pm-misc-cleanup-2-v2-0-61d4fe0586e8@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7567; i=matttbe@kernel.org; h=from:subject:message-id; bh=jtC6ugdm2BzQr6tjHVlRQQAfuKWYk/N/2vrKM0wc/J0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniqRr6gxqv43R6khcwZ8O+btpLV8j4lNpnup4z xRyGOl4B7KJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4qkawAKCRD2t4JPQmmg c3HTD/9g666JXszTh3SsXVStQ85i4T1M4sMxWU4F6bxzd9z2SApW73+drYrZd6b0ILZCGs9V2YU Rh9tS56rqtltuGY/UGwpJv4XTXSR/WblwoyjB+dqgZJcoHbPzQvD8g66ZlNvOfm9ZfoYDDAYIfQ oiZLr7MtxSoqBU7H6epI+A3OK6oIbkRUsf0tCOrxuBQdObNu2LWBQJELVRdiJH7q1IM3d6+7SoC GKsJGhvC5zIH/1Doe5O8zb9zbNZXCQEzhucws+EoelkGaWvhdP5wZs3DTw6elM+k2EobH7ys0X+ o210/+93GdgOE8WL8gDO6TnWPVhI1NPUPt+ZASZtyPGj87n36QwL3CXKD+OmsFdsxLZj74pZiGK QU5aOrEPNsaLOgGOPHt7rFZkpr/ZV6Azr02mZEeeZv8KK2mBD2+LMayAHv0/TI+A8kJbVVI7iaQ Tk1dJN0nfUbSMJPLew4K1sut9tPk7QJeKhyfuMrQLjxzN6YJVrsc3IH6fPC4eJ3EXXUKE53RfT9 +nx/NMn5j0HcvPFmy+POe/g3TmbzikLApXt/bMZC3uAOaPOAApkKHdtsqHFO2Cvoq7XH6qyrPgq Wmreg3oZ01grqUs6khPXZjDbMoJQddmlqAEuz5+3gW/a6vQr7lD3IWScQDyjkOrWo4uavtdM0Zh Va/hMSDJ0yg3OAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang This patch updates the interfaces set_flags to reduce repetitive code, adds a new parameter 'local' for them. The local address is parsed in public helper mptcp_pm_nl_set_flags_doit(), then pass it to mptcp_pm_nl_set_flags() and mptcp_userspace_pm_set_flags(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 16 ++++++++++++++-- net/mptcp/pm_netlink.c | 35 +++++++++++++---------------------- net/mptcp/pm_userspace.c | 19 +++++++------------ net/mptcp/protocol.h | 6 ++++-- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index c213f06bc70234ad3cb84d43971f6eb4aa6ff429..b1f36dc1a09113594324ef0547093a5447664181 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -506,9 +506,21 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, static int mptcp_pm_set_flags(struct genl_info *info) { + struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; + struct nlattr *attr_loc; + int ret = -EINVAL; + + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)) + return ret; + + attr_loc = info->attrs[MPTCP_PM_ATTR_ADDR]; + ret = mptcp_pm_parse_entry(attr_loc, info, false, &loc); + if (ret < 0) + return ret; + if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_set_flags(info); - return mptcp_pm_nl_set_flags(info); + return mptcp_userspace_pm_set_flags(&loc, info); + return mptcp_pm_nl_set_flags(&loc, info); } int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index c2101f7ca31e648aa72ff0890ba3a0801c1bf674..fef01692eaed404e272359df691264f797240d10 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1951,62 +1951,53 @@ static int mptcp_nl_set_flags(struct net *net, return ret; } -int mptcp_pm_nl_set_flags(struct genl_info *info) +int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local, + struct genl_info *info) { - struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; + struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP | MPTCP_PM_ADDR_FLAG_FULLMESH; struct net *net = genl_info_net(info); struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; - struct nlattr *attr; u8 lookup_by_id = 0; u8 bkup = 0; - int ret; - - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)) - return -EINVAL; pernet = pm_nl_get_pernet(net); - attr = info->attrs[MPTCP_PM_ATTR_ADDR]; - ret = mptcp_pm_parse_entry(attr, info, false, &addr); - if (ret < 0) - return ret; - - if (addr.addr.family == AF_UNSPEC) { + if (local->addr.family == AF_UNSPEC) { lookup_by_id = 1; - if (!addr.addr.id) { + if (!local->addr.id) { NL_SET_ERR_MSG_ATTR(info->extack, attr, "missing address ID"); return -EOPNOTSUPP; } } - if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) + if (local->flags & MPTCP_PM_ADDR_FLAG_BACKUP) bkup = 1; spin_lock_bh(&pernet->lock); - entry = lookup_by_id ? __lookup_addr_by_id(pernet, addr.addr.id) : - __lookup_addr(pernet, &addr.addr); + entry = lookup_by_id ? __lookup_addr_by_id(pernet, local->addr.id) : + __lookup_addr(pernet, &local->addr); if (!entry) { spin_unlock_bh(&pernet->lock); NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); return -EINVAL; } - if ((addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && + if ((local->flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { spin_unlock_bh(&pernet->lock); NL_SET_ERR_MSG_ATTR(info->extack, attr, "invalid addr flags"); return -EINVAL; } - changed = (addr.flags ^ entry->flags) & mask; - entry->flags = (entry->flags & ~mask) | (addr.flags & mask); - addr = *entry; + changed = (local->flags ^ entry->flags) & mask; + entry->flags = (entry->flags & ~mask) | (local->flags & mask); + *local = *entry; spin_unlock_bh(&pernet->lock); - mptcp_nl_set_flags(net, &addr.addr, bkup, changed); + mptcp_nl_set_flags(net, &local->addr, bkup, changed); return 0; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 1af70828c03c21d03a25f3747132014dcdc5c0e8..277cf092a87042a85623470237a8ef24d29e65e6 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -564,9 +564,9 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info return err; } -int mptcp_userspace_pm_set_flags(struct genl_info *info) +int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local, + struct genl_info *info) { - struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; struct mptcp_addr_info rem = { .family = AF_UNSPEC, }; struct mptcp_pm_addr_entry *entry; struct nlattr *attr, *attr_rem; @@ -575,8 +575,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) struct sock *sk; u8 bkup = 0; - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR) || - GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) return ret; msk = mptcp_userspace_pm_get_sock(info); @@ -586,11 +585,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) sk = (struct sock *)msk; attr = info->attrs[MPTCP_PM_ATTR_ADDR]; - ret = mptcp_pm_parse_entry(attr, info, false, &loc); - if (ret < 0) - goto set_flags_err; - - if (loc.addr.family == AF_UNSPEC) { + if (local->addr.family == AF_UNSPEC) { NL_SET_ERR_MSG_ATTR(info->extack, attr, "invalid local address family"); ret = -EINVAL; @@ -609,11 +604,11 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) goto set_flags_err; } - if (loc.flags & MPTCP_PM_ADDR_FLAG_BACKUP) + if (local->flags & MPTCP_PM_ADDR_FLAG_BACKUP) bkup = 1; spin_lock_bh(&msk->pm.lock); - entry = mptcp_userspace_pm_lookup_addr(msk, &loc.addr); + entry = mptcp_userspace_pm_lookup_addr(msk, &local->addr); if (entry) { if (bkup) entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP; @@ -623,7 +618,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) spin_unlock_bh(&msk->pm.lock); lock_sock(sk); - ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem, bkup); + ret = mptcp_pm_nl_mp_prio_send_ack(msk, &local->addr, &rem, bkup); release_sock(sk); /* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */ diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 0fc74e567329f005096cb0769f4fcf4a5019f532..8dcde58a62d5243e3868441cd5859712aa98826a 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1036,8 +1036,10 @@ bool mptcp_lookup_subflow_by_saddr(const struct list_head *list, const struct mptcp_addr_info *saddr); bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr); -int mptcp_pm_nl_set_flags(struct genl_info *info); -int mptcp_userspace_pm_set_flags(struct genl_info *info); +int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local, + struct genl_info *info); +int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local, + struct genl_info *info); int mptcp_pm_announce_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr, bool echo);