From patchwork Fri Feb 7 13:59:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965043 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 DFF371FF7B7; Fri, 7 Feb 2025 13:59:31 +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=1738936772; cv=none; b=Dr7TVQnpXYYOnyQwTgT3JLkHG2o2K+fn8TOtk6jY5wKc8ujmECcT0bniTSuBxLp5k9nFDtakWdzEKt08c3eLinQtPiOLbu3FhiaT71+3VlXKalmmAh1IGurJFYq6cVdkNJs57KRS9/d1vhxU7WlNG+qyHmJYVwMmcG/scyuSKRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936772; c=relaxed/simple; bh=8G7twJP3JZxNmu7hReZPonWiPiIdhHNGTM+TQzqkMBQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oFj7LIjS+SV2ffx1vdFCK/nJMk5mcq8PVpnZ9i6BmvfSoryRpIh/+XlvN4QLcU0y43DDTNWU/LH1w2zHVUA1/4zRzZpN0XxRqnWWJGPDxHsGU9wphOCXmJOmFhOogp5vvh6Oj6n5WzzQ27DWoIgTEqTneSeX+Ecqim9eH6ThzOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AV5WFwb2; 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="AV5WFwb2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8360C4CEDF; Fri, 7 Feb 2025 13:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936771; bh=8G7twJP3JZxNmu7hReZPonWiPiIdhHNGTM+TQzqkMBQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AV5WFwb2SD6u13LgxroMbVw6+/f5Msf2KZ0ELFPU2XApqMWNutVVHgSX1NVz7Dm3Y t/vOxrov4/d5MvOXCJyXJLax26kwuNoQb12qVL8ZUmkUppJjLXIIKFQUZe0X+MdaOb ubJ7XgguzUNs4OWXAICzfJHUrCgftdJiLEtBIUr5BLHOtGofuwSC2K0owtg5N5kFHw NUfgG6U+lsVp9uTUHU6vQFF4ngD2oVhBt/VVvA4MXYbUXKsvIa842A5xomoOeopFE2 GrVbhDvHKoqoSjxPcwWWwKhSx70+SpX2TLC+I7BAcThCGgu4GWRwHb5a01PTL+kYYD BjT411IEtYJYg== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:19 +0100 Subject: [PATCH net-next v3 01/15] mptcp: pm: drop info of userspace_pm_remove_id_zero_address Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-1-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG95yUvMfTLqrLRlVSzW6YN5nsWxCQuRe5aL BL8hHzyDPiJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c5snEACPFECu+UiQ2A68W84Dw/2xzL+KDlOhZ3ShBt7VZmmE+Ovx3KEvGmJFHfZSwyqMVNi7UJj xLgb+DuEG/DsDu5eoiK4QaM7pxhH70KdPVzwVKUrnOO61SBkuMuJyo4DGL6Bee9FH9ZrCLYnY6f qWcBp/dzXmc8FanP56Ggco6pVZqytyIx0IWbr784KmapUT4qgNPE6d2JjJy4m5ZQrFcucyr+QWg HRnfZriFJkrK3eTaVOdRZ4BZZT4Z7P2AHgzKAFavpGD0o29YbjcItOOGs+sWWFEj9fypPw5lN8A tjnWFAgn09cmquTZLmO/6emTZw+A0wxagQyPIiZmYx8VCdXJtQnDIIa0MmLRcinAP1/ury0GiC4 KMBsWKnAc0z3309oDDrkGulK3TRLD3BzDL9h0A2DHh+zt2z8eEj7jMue5s+wWnLX+Pv4CJqBhhw AoeK3d8ng9yEg2mq1CfcpKAPlISKAnYkoAKgpIfX+6OgXl/6pPZhCoKmxYfLgnF+rpPM2H8muUd 36hS4+cCZqCmjUFNCUdljqRm2EDoY2ygXn4WfSzIbrJCkW9ssuQhftMLz2wjFnP9xjeSuOPlP4l UsSYkFgUra2LY7cCfU1h4kOU/s5TcW4hOg3Jsq7Pj05Jz1Lgf/JCH6LNN+OIidF5uobWPAdco0r tsS6OYwL3qMS0PQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 Feb 7 13:59:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965044 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 B43EF2236FF; Fri, 7 Feb 2025 13:59:34 +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=1738936774; cv=none; b=n/YBjeIE/Mp2nYKUEyPSIHF8KCz7rXJ2bfLXrsP5oEQjIi51A65WBy8J5KgwIUgQ0w6C5fbVoNMngP9Mav8U6RAUi/XfHcIMpO3GUTLcwyBEGclEZmVpHVbAzkxsJtbwsoP2+v/yr5zpkitU69DwvBpD6tAHPl4RhS/gLxGbaiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936774; 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=X5k4+8Lwvk+CVF35y2C5lkpYRr3UKtNpIdSZqwrLlXYCiYz8DhjxWrxqSP7cKbDcakUskiSIcNfo/ciE/msrpYcK6ZJ/oS9ecrW9XEGCm7asmqf9H6mS7j+e+OfzpyJpI03+8/ByVcPnDTL0N6MsACWHGq1qDiRZvTl8FapZYnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ip4gEOcb; 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="Ip4gEOcb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28252C4CEE5; Fri, 7 Feb 2025 13:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936774; bh=B/7KR3jBwTwNArI5wXpFWpYyFwZ/q/RqH8P6VfvLqUs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ip4gEOcbGtWR1tpreBGBnHxNe4WAL8N+x46W2A23uwFWDNnYLMF25NCoFJIYWNfPE V7BkM4ERIbOsQ2yktFVGGW99Ise/JBQtQHYzZubV2zNm/YhcquXUaJcQl4kVJVzsOw GzHQSK858VtaCbzv6W+RE6WkDo+Jfcd84SFHwKR35h5qxsdUfg0rtJopr3n6rWO8Xl PEl+OQkN5mlSK/KNar5Bhd74aB900Rx6sxOJJkhDaUGy+BOFr4bwzydrs+qkUYFg5B nMF4R4+zRtW4foPufqNZI9e8afRkXPrlSsuI5kWIrGfmKqg6MDUQEYbk3jonpJ+R1O tqp4cE3nh2IpA== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:20 +0100 Subject: [PATCH net-next v3 02/15] mptcp: pm: userspace: flags: clearer msg if no remote addr Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-2-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9ueOUUFMEVn3mUxWi0jMe61DcX1n1i6nbA Daq7s7v6bmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c0OuD/wKwl7YfF2RJ5XEe3lQ6EQYRsT4VD1Zl6f5zaj2NYNTjSIQF9KbmPoxWQcIRnZwRt17tOZ OiKuDXcAvj83NNGWxVztSqW0qJyHO7/B1exRsy+X+8OH+7pH0k0uO107uSpBRkAwuKbzF9hAQIN O0mEROt3nhyDGDKZXdLrBD7S8K0cOHp3+HwDSwPLh1VvfcgoC+5TuN5BZMk+ggHINP4dwjndsX/ J9b5GfMKkyYYNhC6i+T57YA9ZYJuHdoElHMq/W2kFLZB3ZicWjtZ3wA5j7iRbnE0bYC91jpFW+2 889XqYygyF/wRpyJLXVWJfvAxTX74Ko9hva1hZhwzV8VD1EO4HbjKTP82tvr2S/kLFTBoilY33T 00mejNrV+2K/A5ReTx1oFANzjpJfS7j6qCvf1YJllREtTzrgMlr/DXswt/dEC3R/wiG+ra7KAzP YZTARxHGKXjRNMVek6XS8liJBrm6yH4BZRRyh69L0eoMsAfFKCyENlFPg+YYFFuzUZj1j+FPsJL nf5va7DOeVWM6xsaiB9pTwjODAJ48rQprX95B/cLoYBqdy4OJQco21A++LtIB2BsUxC9MjJd5st gQwrMPyIydrf2ne1lWtfLXfdDFdCb2c4ToZHbv1bVetJyLsrqX9w7WNXLRC00PZ4dbowtsfm1zV saW9apHMNdS/TEw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 Feb 7 13:59:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965045 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 080C4227593; Fri, 7 Feb 2025 13:59:36 +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=1738936777; cv=none; b=XKmZKWH5uBSaUoW8ScUdpOE7/unDX3IPd7szv7NQlhcEi5C8cbm/IC2JoEQluQj7LrTSGFSJPYKaekEI2MFTtGadSB1sVeAeYkG/pooBCTZdt9AWxGsz0ByLMo/W0SyJRF48QujKclq1WY5NlNdSr1wkYimjotPjfin7Mb+dHPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936777; c=relaxed/simple; bh=ywVqaLMcTnS7/LX0E47JY1rOXoObiNL+nHvd4fAztMw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X9y26VNY64C3z0P63rqeYFChTXugiG33NiosszsRzjhbuXbyVa2u4R14vyKbxnHcq/CwyBsWKZ168qIy+jhmrAbj17alDssqECVEct8VzcwgQm8xSlSItSUiUJnHPh2Fe+rBayOnke2S+99PtLTyndd+uG6afaxW24ya5Ve23oU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=In7LmL10; 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="In7LmL10" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A2B1C4CEE2; Fri, 7 Feb 2025 13:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936776; bh=ywVqaLMcTnS7/LX0E47JY1rOXoObiNL+nHvd4fAztMw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=In7LmL10dF0ZgRD6Web/OedmjiuO3oi4UIJQLixMT5qtB6+LS9tydlo5BM1EbJVSF 77TD/OHAZLFN6DKx2bsuZOdh5ws8Yshr0eL3ymndY7TKPBSfBTm9SfVsXHSvloXaXH FOOkqcACI3MP+xIKFgRnaE1yVJMusM8oq69MUiBoD9X5/0KA+pYRhOtANDARPhkXys Oy1yjv9NGRo2M9BPBidgjPswQMk439mHwMIyrJ5rp65d/PYVQhyVBGBfSBftdl9sSA iGCnFljztqBF8ZYtdgckTmtfhdb9+9HYaeyzC2cpr2NOr+Ae3xoHBYFKRn+zIR8t+p MV82pFqQCv67g== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:21 +0100 Subject: [PATCH net-next v3 03/15] mptcp: pm: more precise error messages Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-3-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9Bf+x5kGwIOUPZFFikes5EMXj9cyiRuBDD JwhBDTITliJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c3UtEACGAy7f/gp+Xsp+W8WN6khikmHxUXc40kQgM+R5NqdTL2V3O7C4UOyn24aiD9t1Yy3i33a lE2cbu7U3OuVWZp4YWC9lkQZTpB5IoCFdXRgpacxKU4ZGPbtLiyCt0qtp0lr/XTlQM7yLEJSU4y V9y1kR5tLJvVmrHHB665os9BfHY1zyR4SJewt1ReQQUy2U/EmP1uj5w3hfqYhgrLBZyrGZpu56r q74WmQD74F3G8Ze39VYXHbFQRHJUqmTUQyShLlUc1PoQHyylqh/SEqsXy3u+G2ioPnuQv4LKa/j Sz4Jok42hLfQ6BkEj53uBbqtMqfJRXV0C7o8zQGrbQ5rkMQ66C1NOtDI/kNOBTEKzcmyG8EuUOi vApWPjB6VuEWo+TIK8sZExmahvTn9m4C9AOAydl458XHdfZNERLSI4U5Qlp/tzSD27DpTgaww0H LTQekz+yWECGatzVvI2CepxCWXLL8V25SO1xH0sGK+PMtVQKfVR+48lWV55ViXoIRf7a1bEOkmW r0+AgfpeDWP5LqEVX4LLI3KqvFfd5QxRYgdVFbpoRyEi2Ir9+h4JqBVJj7RorjeZHU4fXakVpbF SYPOOJXF4v5v4kNC5Lu2/uGv/aaMhQvyVJhvMRa9DuHNcBmRylFHTZGIij+cfKe0xcx7c/GOtjo xV2oml9D6/toZLQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 Feb 7 13:59:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965046 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 A0C38234981; Fri, 7 Feb 2025 13:59:39 +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=1738936779; cv=none; b=H8tAhjaRe5DxfXwncAB3Wj/yndMqQV3u3RkEaxtKU9eG2K27HHQgPDNA9dNDolFBmvIV4KtFL02uBdIXPFhMQcNxzuZbFR4PJn+9MEeMJZUKDn4VVokIYbeJaoLsywG2pzJK9G/bLy9hAgBckCn4IMW7PO3eASf8xRqjxPJxePw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936779; c=relaxed/simple; bh=iJKLcXa+lRER20dB3wd7wbKtdem1XltATghiiAeKEiU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i5us68meWyZKZBTwWz98RyAHvv0PaicrQvGgXVc0HpXkoMj0eQuhmAlfo/+BOjxjA8luijWMBdwDluCDRhpH4C3Elv5rngG6oTiuuIW4xxgu0F3LsYJGYTRK/mvqEjpv05KdxyQ/GxPhhBjB4nrQUyR17SPB6aIOP6bCfOKgIng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YEBMR0Yd; 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="YEBMR0Yd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15376C4CED1; Fri, 7 Feb 2025 13:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936779; bh=iJKLcXa+lRER20dB3wd7wbKtdem1XltATghiiAeKEiU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YEBMR0YdVuR+O7PV1luxE1qxzJ1AyRI+3WkcjACox8rFxCb3f8suoUjKLibfCOz9B 4++7YpdKRKYvHikkDkARHrDokjMsddwjWaF/aMyY2t1M9CH+kkvuWatFADZtrSibFU 9elDpkqyHUtLR0GzBB4UX+JXgT/aLjRXr9IawvEgTBMofs/PS3bSquhhwqVeTzF3A+ QGHXM2jKLDxGPSzn5SYRQrfPVxK5jkeeBdcCulX6Dlawg+oKr+PtdNl0y5R3dPx/+8 bqMxGRgGHKnzzfENkvd69bcXiMe5yf9Ph7QwgsFMRmqNsBE3jH6xhk2Rh+kqTGyb9g DId9qwTRNuqFw== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:22 +0100 Subject: [PATCH net-next v3 04/15] mptcp: pm: improve error messages Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-4-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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=iJKLcXa+lRER20dB3wd7wbKtdem1XltATghiiAeKEiU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG972Ida5v20ntBYQ8jspnU3GmaQZdm2zyOy r92LMRRYb+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg cxkTEACylQo6L36ElYzdZvmQSrpLPWR0Tbj/0OHkF30VxkJDpfvmr5GhzYLAWjn7mSnhh0NlTPF QIXjjkJrSsHSjqP0y7TnDYkp9Kevbf3SHmrnBOKFD62lrdx2PtrtIvq0Ypn+kfofMgf1ewZ/UC6 u3g9OPFqFEY2ndTBO/afPXSx6EBzgOwhrTl21EDK8oFNJ6P3uwhpv2+6pmxSGx+GPTUk1q5KEZJ XziGw2t6q4O03mDQsulXq0KaLwrII+NXsJJTYYhdRgNv7jfVhSbObSVMJIFE02w44ec3ovNUhGE jyrP+sfKeGMHWihuYOrXRRtshYhMCAS9ZZHSrZJ/oy/ns5C2RQCtKAea5/jnv9Y9qCdHFtEAp4+ IYyLZP74ul32+zVaiyn09cjXOjEl7j8UYmg01H7OsZAS5YcKQWMEwr343gy+SAdWJUwkXGTPJ8E tMdMf6y3x1h41Ca2LnJuLjkBPB7ujITAXEHjMCpQkl6VmGDfyQ67I7jt2iGm0ol06DNc4GOHMNq 1HwVUZXa8FBmLBvqatGnubwALDqlbomlg4V+2HRd+NS4m4TVCE3yCqAjrvDI4LCUYWpB4F2h+Vr HQpPbNtj0mEzQVvjFT0gvWjk+YBR4ZnDI0KezDQ8B0VO9UJeVdzL3PFcFSHfxT52d9QyfEpuEFj MMys03WaqdW3kSA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 572d160edca33c0a941203d8ae0b0bde0f2ef3e2..1afa2bd8986231ae2eaab3a9c9044f841e2aea0e 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 Feb 7 13:59:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965047 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 B09A6235BEC; Fri, 7 Feb 2025 13:59:41 +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=1738936781; cv=none; b=InZzqmbnkVHIeb9ypeS+HHT5cFtXSi7l7Xit6YOvULudkByW0EQyDL5LT1lNS+YIqIORmNoXAD+32KhSUqYO1WgeQRZCPI4tQvDCpOeea4hbNcBbnAug5QsRZ4inKDntUSJn261TJH/w9a7z0bdqOtSD/8+kgljNylh8fmDfTQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936781; c=relaxed/simple; bh=Lqek27knGwgehju7/g0u3Xuoe0fvOylfOxCOeXWYdF8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cFMwdgma/BHIFMahcx/vDXqAGuCT4G76tK3C7Z32E7DGtG5EBRhDWJqQQouAuVIJqUy13trkIQjMt5v1DHi48AUHjMXxsf5W4RLzldrdeFEdRrao/wIDRFNVbFbptLtXktY1rpsC0MnX9MEVTa/0RThIj/QGdGN4OGW9t51OOWs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IM6rx6LQ; 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="IM6rx6LQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84C07C4CEDF; Fri, 7 Feb 2025 13:59:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936781; bh=Lqek27knGwgehju7/g0u3Xuoe0fvOylfOxCOeXWYdF8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IM6rx6LQRt9o0vF6rVoOXRU1s1M3fKqbTg8r5yYPwuCUtq/Epvzx+I5gK12I2ZrSF W/htjYNfNqF6gtB69/j72KTGDfFnpmBuMUNwf3/fyZCmzHc17513qsPyd1jrN0CCXV 3yBZE/L/5BEsrNGPkDLxpgoQlr7DjR10hBrqKgI8YQQGmAYqfHT0rq0iEcVMj8X7iJ eAsMwUdcl7+OyjMxBoQfbZ53LngXtxH5IxvUJk7eBKJl3FfHr1+2JiOmTlBJYLE9h6 t+BHtZLMp2vxemboYdwZifnCZNso92XwUCNXx7u5wxzi69XgGq1K5NZduBencZk16x wpcFITzChPs6w== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:23 +0100 Subject: [PATCH net-next v3 05/15] mptcp: pm: userspace: use GENL_REQ_ATTR_CHECK Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-5-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9sXJcXjTDpfQC9SgkPgEVErFivuRCY5vMq 2X24xtHiQCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c9rED/45m+vQ0pW3UMN3sXmtRRTPAVMNHcWsY7ACZtrf21xQnFoO+6nPzz/9iDCrUiOZnYkZ6EW 3Ea0D2STVBs3sKZdVyQfdzzuw0g6//77mHRRXJ1gDFRGS/VKZT7SOj+oVEep3yAbXkYBcN4rhp9 9slurrEwBMo7RQuQbCB2nvwgT5Iy1ez/GTOoPhhVqq+ycjfroS4TtgvWY81ORTOV22/KR7DWp8w abmMgGUf4DdRypPuSW6g0Ln7TLLFiqzJMx4vH5IuKk+D6MfvidWvzHaIQpbXQVvZ/j6IRdBENfA 9JnwnAZKJDxUpaYt+NSJj2riGLORX+A5qm63U52mfA+OlPNFqDIaRQLpSe4liAux5Mj5IFZ3oWh rDH84lupiKhG2jhQAEuzCueH9f2aLQnknSeDXmo8RnWmUA7O6k5Y/S0XeT8OGALCx6Wtg6sCFSa fxxX2Gg8oxKs0IX5phtZJocbT0CEeSSQ9lbmMwlqbczN31AUTtZgq8wPjiUqxxv1rrircbFliMk CYF7hU05a8mAboDsg4dGhOVUiFqOHyiKytjEu24cfe1dH1vKXmeqUZMlFG47T8JCNcbVqXNez1O ZZUchL9x7duYgbvADF/kA25xFr+S1Qjjp52fU+MuMo/Zg4+tYOElRe+nCHy8J9Cqr8ZSOI+d1Ug s9K70SG7r9OkL1g== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 Feb 7 13:59:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965048 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 7F55C23643B; Fri, 7 Feb 2025 13:59:44 +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=1738936784; cv=none; b=Az/mUBHs+CoEdb0gzH6Cq2l0NFHCt+5mRT5PndGDGKrTMKR4sonwdhHbj+nbBxEDYCTXHnaI2cORBOJEfRHMV3pR9js9iIU+D+sILIp03RhgFt84JGhYuRDr+NfN2ixUdggEJW7+uVprdXu9ZJOgDj0AGBNDvwpAG+ArSwNwrQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936784; c=relaxed/simple; bh=B4EoGp6iIdIcXqT3mYInhSvXfXsv3hE73F8zcYqYI/k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=s5hiDcfmi1EKiLVkJwaDhECGmmps7zABwG5hiGSWABkzNF7TrDnKorSjTaOx3uGzJM1lUSml92UptHKNeSdmOl1dcO+0/4sI5f0lC8Gg8Y1IDzgNVx0pgjXrw1SiewkYJQ78FdEb0AmysYzPRKKKU+jofEqH4TjhDtVKVcOqGtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DnCJv/Lx; 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="DnCJv/Lx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 068CFC4CED1; Fri, 7 Feb 2025 13:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936784; bh=B4EoGp6iIdIcXqT3mYInhSvXfXsv3hE73F8zcYqYI/k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DnCJv/Lx4ZaigJL2VFjfCgDhVLQR6qf4jTsRwOKMKLBH855TH5VWK6wIQeBlZYv+r DctFc2yHa2FCKG6zF9ebbBqt/Qprp3foD2ZkpSlEBRgh3pyEvdP+cxcGRvSc73I7Ac bbbdHbNiRXddFwXL0T8ptfF+3MS/Ol/i4bxUIgFJhICkLbvhcpRFFF68gGlCiSwu8I 0NE+ZpL6hKgRooxWzwg1miU2Vs68ighbSxD5VcQmVWvPio+SkVMh+PRn848VcuUYhl Hg59VTDYmtq/tW3ZFXCPjflnlH7Tb7IeIMvQyyjvZ+J+0+u5dZQoyqwYtIuD/lvagZ TiAktnyisU3Ew== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:24 +0100 Subject: [PATCH net-next v3 06/15] mptcp: pm: remove duplicated error messages Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-6-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG98rr3+gAsUA5Q0DEPhHG+JHyAdOmEILbMF ysE0sdgsMaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg czXuEADqSnnD32pcFtEvTibreBFzzT8eKIrID9zs33kGP9Ni1uhbnBPYLSCAi4ag6VcTQEtrwAM jsGZVffKhig372xK2qwt9V2kxPQ53g3YV7PB/9Nmt8cD2M14spkdYYt3MGJB4r2gwoi1s4P8X+7 5TU6mya1l08/ThYyI+YyYlx8kaPDzlQi3i+SUPcGyWVTRaT+bunNPhfHO77HWkNg8rYOAA1Vyqq 70YaFX2xEMZoI7QWD2ZjQ5Y9B8cFcCvdCYFoIyIyHvvjK6gg7pMANV+0OAT6gFjnfU/IsXqkOc3 f+qJwjMH2zl+9XV44i4ttIHhxAHhJ1x9FqW9eiPKnaZ2qeCU5uP+lhTIQWYwT9UoXArPiZZ+BsT Z855Sx/aUhpd+q9Fx0dbjFjIOGd113wHfeLSqrgGEzAS5zCfif0ygijvUN9fLfFWeNyYkqFr39b agUCn3GIQLKNILwHhLuZPmcE7EuniTnMuy4kJD9kYmAtvFmi5Xg6QA1ubGW4szmFdWqWMDZf8VW daGD9juHhKmiHb5QKzuErolmsAOqEldGVUXBpzD13FwI575q8WgSz+6twLQXr52twJUtRdYwoE0 E9HvmMJNIfPCcNTs9Zqm/u9lqi/SuxrqwPEAUlOa/SzQvs5ZhaCqlOlXE9UJz0d5smRlpl3B495 rMvbE0AikBo+B+Q== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 Feb 7 13:59:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965049 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 0751B236A72; Fri, 7 Feb 2025 13:59:46 +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=1738936787; cv=none; b=U+VK9yBFSU74ImaKh8l1qrjpMPl6+yvlwVCStnRaJn4CaRqZatjQWewM1PCCvArJMo7TOYdpxcoj1XhO634Zc1VR8/60ruFVPSU1xh3I+lUD8G566dd+OC69X06q3MANKl8p/Bx/xfowQZ9VHtPFi+IoWFGNVkHc2FnFXv/00qk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936787; c=relaxed/simple; bh=vXST3kSAgC6fhkC0swVcgtAU9g6LQ4bUQoLevAWVemc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rtdEAogaDuAOjmsNaF5cATsfA62jCCYUpjsqwhNVXKdXaf2tBEWQtIn0mz/XutN04D3E0lxOuVq5z/499fFtc6GjJk43HiIDGBDR/B2FOnVsCaqsKb0GLKtxk7EQ6sQjwxDpzVpwuHjgaYn9SbnuTHuyfOTSjrLsXGDnv84H+0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fRRL27Zc; 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="fRRL27Zc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 759A8C4CEDF; Fri, 7 Feb 2025 13:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936786; bh=vXST3kSAgC6fhkC0swVcgtAU9g6LQ4bUQoLevAWVemc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fRRL27Zciq3JkBSNAPs8tUGZSGQCitIscrmd5HQKmoljXldeChj1+fmsImp78+Pj2 +l5Nvs//lcEPyzjXrtdyAzfVftPH6X2Db/S3ZmwjmjDGo1/I65gDDJXZTNzJAtgC8w S6DUakod2u0pXSuu3BRugtrrMgrtj+tKsd/Z8OdxfGF6VJdcX+qvx3JP8o6kkzo5yX IiSTQfK6VZ49PQOw6tdqEgNaf0Hn22KQXFOTiGxZQokIiq4/iZBOjmUrGGUHXkCVNR LeEZ3V0BSxg9bf4ty2Vqgc/DSevWyUA3VWtckkCS5DAUKcCSnkgH+pRneH6Hc5Bj3l 2WU2e8Kk/D9EQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:25 +0100 Subject: [PATCH net-next v3 07/15] mptcp: pm: mark missing address attributes Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-7-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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=vXST3kSAgC6fhkC0swVcgtAU9g6LQ4bUQoLevAWVemc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9GDoUNyg7TCZFksGiU9pDUw+EVr9kNyu+S ATGHVpScjuJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg cwGLEACkv+Q0/bTOStjbO8x4RPhUTUhNfzdDu3iXaxDwZPxQBRzqXibtI6G+FARsgxrl25X6vxp 53o//YhtfhF0w+YI90KQLwWmIAJRrQbj5TBeNzK7IpcBMDQCnwFVdQ5IDP/4FZYTvqdq+n8KQQl 4sJhdSsRwYlAiT5QDOcJOf5CuOR0RnYAnjLES4mRUQp4iH1V7lYQ/KIxZw1/Wx37uRGGHknpAor IHsO982Me4z6EnBMj/xPo1a8nbAH0SO+0X2B61RKSx1S2T1kw0k9fb0KQKWNf/1BAZYt2YyS1Gu pBoRZBbLqfhowqJW9Gp02V9F5K8bGjQQugaMw8tWNaKGqkZcCGVCWJx57hGPWMg0jeNtUhkC3gu td3iebXm/AhgjKIUKzJIK4trztFrPqu2gAySOebkC5Zg/1YyuTho+0QOhCHMooM+onBLOCHoYaB OicEbohWNK+LEU7wH/EBaX+YTnqDWkVSdzs2C6HYa7CwKHZS1XGqS7dX9wR+4YyHrF9u44ypaOL biLtb1yFYO2SUnK9dZt1F69yH9ked8sy1Ctgt3imAdmEoHHKljBp6kMTPKxCKlF48VZeVbQrtU5 L18nHJubmyDB5rbyx5fhiZYYpgCH76fQX1eUk+P8+N5LrVNYTNrxAdqhiazCSHhY3Vftr7ZYIpQ dYNrLj8dZ9u7h0g== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 1afa2bd8986231ae2eaab3a9c9044f841e2aea0e..4a1ba2bbb54d507af969ce9a9f8a3f606c2d5977 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 Feb 7 13:59:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965050 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 83331236A6F; Fri, 7 Feb 2025 13:59:49 +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=1738936789; cv=none; b=HH+mMhg0vk6vH94CBvW07tqW6acNXLLIm+FdOuhDUFNyPrxMthk9u3+UF6S/IKvlH8eEraon7nfW54h+WHTkKbwkpVyiM2NPT94//PRwYKCQ4b/JlMSb5ZQ5BhlwUIHlM3YOvL1eKNgiwrAQKTEGWMR9EqdPUMNUInuzD9qbQn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936789; c=relaxed/simple; bh=OK/ygVMFsjfgT6yxeyfWNjZtrHHAj7WxufDdhy/tU3M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EBGDUWeu3andh2E1FcUGvLumFVyt3P/YO58Yzi5kS1Go45Zxa8fTstsTpA2mVQEbp+nvUZZBQ8dg1H2ERLqUpJqYCV7C+oEhZ9WbyG0tptyDZq1+uriEfR5ToIOzi1VoM4EVfdKp34WqjDzYTXYFbY4SuChQfTF9b6N2btY3RgU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IKooHcK4; 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="IKooHcK4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7BCAC4CED1; Fri, 7 Feb 2025 13:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936789; bh=OK/ygVMFsjfgT6yxeyfWNjZtrHHAj7WxufDdhy/tU3M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IKooHcK4X3vXKHtM/DJU7g8210WZlFAwY9FJnUqm9/vqqCh3WWP021L1qcKuN12A3 NmM3C264FmwshODJSEfba6mEHh4WQyIVXVwpwRlreCMU8MuGZT9iMJSv97D105B8Hy bFowoF2Njve8Yx5tdy4YXV8cQv1ifzdQJiQYD52a6hMYqBX8725TKPBBBVsXo+Htkb CIQS/5HIxNmJwVMvhz0cJhwICr1kuu5YOt+msGlG5G2VQ5At6dou32T55MVAmuDzCo Le1pbqbw6nz7Xc8zWA0qyDsFdPUcGJQBi0cAFFYFx3h3eNybhCjsWXHpmEzWzX7thA JPIJM3HYP33Sg== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:26 +0100 Subject: [PATCH net-next v3 08/15] mptcp: pm: use NL_SET_ERR_MSG_ATTR when possible Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-8-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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=7521; i=matttbe@kernel.org; h=from:subject:message-id; bh=OK/ygVMFsjfgT6yxeyfWNjZtrHHAj7WxufDdhy/tU3M=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9AfGtuGxoN1HOfT/6ulgYlkmSs3GvpO333 LvHx5C8GDaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c+IcD/9/ArYT/vD3/nU3gFs/K2s/SPP0F+M84eRquyE8E0XJAjJ9OeKPQBgnFd0s8DwTgCIsYiW W0NOqEqvw7MhXk29F0qHkozC3ZXtWwu8h4q3JOZNEm4vWNRlOiGDSMpKF/qbCQKDs6Z+eRwAUOW zlChae+6O5Cr5lXLLfIdwiV14IQtdBBsFWzH57AdF4/N0CUCiWOyn0ZiA3gpr37vo3+43XyFeC/ S2NfPqOc07zwFzQN9IX33/V+5+aMALUrGk4pyx3WzexUDyFrIvoMgj1JyIlc7CTLr9G5/3snLoJ bzcEuKgcSBNeXaUZ0sUZ/4//2+x4GH0HovP9o9UVFREg5JJLXAq9SuvcaEwZkYcPOfh2/ng+wo2 LSz4jg3yarfJebGkKlN8dKs5iRpfCNL7vVfhsNF4DcV1mfEQihqvFGes3ziYKWA+kQIm+jBWiQp 1ylhcyG4sXfT49TZTP6hETvD9MqMc9bNVZRVVbbps93oVr/8jULM4wZoyyoOETQYDP30xQK8Qh9 SiI/Vej+9lvzPpfmXTvGdZ5+8BfNXCkm3VRizdE4rXsaWEzHO35SDKDAXlHnOc3dWyJ/+m8l4g2 MTAgmtRn2mQ5EVYGE98FBkbH+TdVUhsU8qpcbKVmWxg8JVs4Xk3O67kLR5pwJ5RIQgwpupTE7Re h/n0uobG6qEwCww== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 4a1ba2bbb54d507af969ce9a9f8a3f606c2d5977..bbdfb7700538e6570f5b743f8b3e37eecc3742b5 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,14 +2038,14 @@ 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 | MPTCP_PM_ADDR_FLAG_IMPLICIT))) { 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 Feb 7 13:59:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965051 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 8C27221B19F; Fri, 7 Feb 2025 13:59:51 +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=1738936791; cv=none; b=fGQS+PiHYjE++/yIoCdew8P8OEyUH7ge6qqnGM5l3dO4mtp1lf09wwOrz/IZYBrb4gVbSkWWC49gtdXMWNKDYkClbd4PqVbiAipAetv4LLOh73L88IGB9e95+dKsS0SaUGehN2KBQ6KIPZAQJLPX5PG5b7KQXxWVtKei32RitQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936791; c=relaxed/simple; bh=wCPpMDWHdoz7dX3xFDF3ZrwfXwNwryRxHCwb8iZL568=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E3+2sqi1yeBxT3T8mPckIMIU54GW9XMgzexteRazJ6IUdKh9nGkkyJicKeEmC4gnyhsXggMIfzXwtPKbNz4ZHCiunEOHFLumDpectTh/O+nS6hPTPHzFyPFwmCr2LrvvWP+2OVnPIAeMjMFT2p33aUGz0+Sws0lhDfWF+K+3GkM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GNn+Gf5p; 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="GNn+Gf5p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65BBDC4CEDF; Fri, 7 Feb 2025 13:59:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936791; bh=wCPpMDWHdoz7dX3xFDF3ZrwfXwNwryRxHCwb8iZL568=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GNn+Gf5pZkRykJrn415HKELLfffu8fcwYDGSZDkPPpkTlZJPvgBtMkIL02O1/QBuz RSYrETgYWoVYM0VDxlJbPrJTpJVSJO2HlBGg12bFyKae488podBELvVUSBNXTJb/J7 FmzivHtzvTLmMN9dYVoE10BQsJA7pP/JNShU7CGniyrL4UB/XOye9Fh9d0CJ4R431a YUE3OX8tDspQt23vWbYmCl8FJdxW8Uc5XSkphr+GVwhTOlOwJhjyb9/gftkciW6blD Ir2cCwIGYM4Psb+/nRkGghlNYhcKeoUPAlWoMKKAfCzP3DxF3LJTTvuKH9WM2EVWYp 7jq+r89EkMoHg== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:27 +0100 Subject: [PATCH net-next v3 09/15] mptcp: pm: make three pm wrappers static Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-9-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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=xPkV7ab/k292qOjMiW3wjSm8TB1Q5o1v7/i0nm0h7gc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9LWCc+ddgqunpgoeVNZ5fcWwJzfALPGwIJ NsoftTlvWyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg cwblD/oDkCYcamQH4cmbVXxealsiRsDXk7q2RjszvdkLKw4c6Gm1BWdb3bK6in5eMrPBIn3hh7/ qiftiAayS1iBm3XjFkmXzF1WS6Y1MV0O7FCX4XzRdUadIP+XU728WlhLMD82ZM0PNdWt323s2HS CTMEYgiq7+u8hy124ZbdF9Uwh+f1JcvtpWl2Xs7Aw3BA84uHWkfK0+WzQo5gLndWtC34Oe7QGZC wk+QjMv/Xi2BF6FriRFkJewSoRwa4Q/9Ww+ANO3BTL85Bh+6dBNHogkNVpQvgfs9genJRH7FCSB aCWAhl7lt9QnmkorZ/5OALmH7BjwCMgjNMJ6UjEkM7lLIwpFrmZ53GvB7a4GcQAqj71Uh68EIh1 MHNbCjkIEVQDL42zzf5E9Gw+2zQ/+HqyOOu8z3VIQHPK/hF9mYzcto/YiYv8x9w5jQk3gPoLaYe 47FFqD1ILNDCs2VS7L9apW5uxphcAl7xPgsm5lU+IKgvRdhW1Ygpz4A9VA7e1zn7SU9feSLH3pD CF0Gi6BzXDqOV+vMs287b+5hcI1Rj2DRKDp0sBi1f4bRz5/40+vVTZcMmwc9dc6sS57217pmipP 5IKbWU9KhLZCooijliEbcPenZLTWn0CyDAe1Ko8gcpd3/gRxxWAdsWm68RPFxhJv+8Oa46rmTBW ewSUaWI3xCqBjSA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 bbdfb7700538e6570f5b743f8b3e37eecc3742b5..eb8f68ee24cfbd25db1a3193a164d75bc9a9d1f6 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]; @@ -2058,11 +2047,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 f6a207958459db5bd39f91ed7431b5a766669f92..6bfcde68d915cf221109ede3ac334c7b2cc51131 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1038,7 +1038,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, @@ -1131,12 +1130,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 Feb 7 13:59:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965052 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 72924237A25; Fri, 7 Feb 2025 13:59:54 +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=1738936794; cv=none; b=BG4z6Yb9CbVTjaxr8z5nvoRiLrrMOzHCqNoy7C60oY1/blUuCN7vvh2KEIZzH/KlwtlmNZeu8omVUVOh/+pYUrmris9eo0/Qq6EzfMiK+hYMsu7jtu5/Wk12yQypq1XcwPvl8yqbLAGPwX5QtDgfDGLZ2Sz4V/YMgqwRR8zigw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936794; c=relaxed/simple; bh=UsabgHEt/ck1aa6MRVAMh0zQQhYQvr3s6pn5a3CssSg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ubk0hJnMy31pEusDsiO1KT0HXE8OXsHzBNkwehDyGL5PPEvsd803JRcDSKnFe92vUg7VEAXen+kqsP6ixxc9SciVi2HDyusccKgpQzDM0SLJWMYMXTl/cveDLghwga3Lrz3URyvLA0jsChLJMSx6DF/be0oyStw8cBj6s58Q/9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U+JPlTfv; 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="U+JPlTfv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D78DBC4CEEB; Fri, 7 Feb 2025 13:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936793; bh=UsabgHEt/ck1aa6MRVAMh0zQQhYQvr3s6pn5a3CssSg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=U+JPlTfvzsFVmH5uH558Q+weyziKYVRDt6SJGLUojkAB9UNB2xL9gJEYr26fQ0iFB nie4o4hkiOb2m4/E+Ehs6A5jrt19P7weAQ68j100S8TESO1oosPnhK91Tq26heHAzJ Lhrmkeg3aXIpZmaZfasbnBj8TiqBoQ8KclSo8kx7dyAzZqhyZfaAxl1dZ2jJaNw3CS VrdUAZPW47lzs8JzJBDR0DBfX6Ww68txGLV+ZLeBU7Unv9ovT29Xt+Im7iVPbTv1iW jcywp+Qo2gqtM26ieb6jhoKy9KL+C3k2ISRA2i7KPqwAqLAZ8yPjNBi48wnHCwNOTi uhQUVCRA+uYsg== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:28 +0100 Subject: [PATCH net-next v3 10/15] mptcp: pm: drop skb parameter of get_addr Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-10-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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=gDYJ0Hy1BeL4PjvL7Turp/8H/wm0qeG6UIMp35SZBjQ=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9she6fare9E85HOfTbPcrUrURnrBPyDjn9 RNty0lS7AWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c9qGEACzRzUUgTmGlaMu/MBDay3j2T4VaAbV5EvmiDnx2aGc22alRL+rsWZzOLGPo8oTJSTAuat +A9s3yJTMftlPF0X9+SGbzGT4VkVF4RGej7Y5AFpOya0Q09nb4ieoc+yP+js24E/J20kkHT8eu2 +5O/XEO5z/ss9V1+EYDlBJjGGhXzBT9jiRfBE80GfLIffA12Wq7scvYEuAplT1UhlKvSXIWCi+H KgBgLfZfhxEUiT7ynUP+RE7D12OWOGDMAo8V9ei4v/zyPRPkBsZ8P4xTzxGMVFm+rXaA/a6yvFW qoDlYCcjiMlTkpqhDod9hiuAG9hFjYwkgBL9p+P0/sJ+FlC5eiEnb6nx+iG25k2JbJifyzsqjPd qJzVOcSg8xjMSwQgizek9qpfKRrdeymIw8CKTLmn3nSqQrj2vI8og+c3FbfS4/D5M21ZcQuzMuP bwI4zq/ksA7Whpk66pPTiLCVnHuTlWRLJuCdFfcaIf+1E5gE+2YazZpe4WnbWlcf6ZLV0RngWn4 ktJl4wJnkCO/ZY1X2BbCDAmakeP1Yacys3y8NpAtWry4EJkMVq+SXbzYoFvzWxiK72SgCvH7Or0 dOBE/hGypJUGhEEb7/cuNiMbYbCbhFYll3w2D5L9onNsUx75kn3gNly9rEtByFYRMMrSgvUEDER MMznMG8MuVPQiAw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 eb8f68ee24cfbd25db1a3193a164d75bc9a9d1f6..8185697044e2b735edb161578685411f9ab231e4 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 6bfcde68d915cf221109ede3ac334c7b2cc51131..a4c799ecceffe2fe495c0066bcb31b9983d64b01 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1134,9 +1134,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 Feb 7 13:59:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965053 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 D369A239065; Fri, 7 Feb 2025 13:59:56 +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=1738936796; cv=none; b=NdG9/1o9j75thgdscMhuEvQjUeHDLWx3gnAkwH+V/uJtJeaSCGT2pZRlB9wdxDAH0MVhZIQPq/thQbeL82SWfqsdeqnJ8YF7d5i/DL0AqOpHP1t6ybU/U0ryye4YRkF2toQhMnZZFd3UDlkY3q6Ym24Fd2RuXbU16E6BMJ4092U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936796; c=relaxed/simple; bh=7M8zHdU1PZn0d0vrNjtFpzTQwFdAblqqoVi6ORrd108=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QqL6mn4ANmzfCGzwsRneQXeLm+nWgPkXg+8zBu/zG2cag9PhezkxbeJGA2fbI/73/nXDS1NnOlCtJRvJxB6Y4IS1jKXgR7VH5ypbMOFju27loeiIqfBJzeVN2PJiiTuYur0REU9uCikl0g1x9UPzExwM1eqnigaphVeZT0RMCLQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rAi3NjAb; 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="rAi3NjAb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52AEAC4CEDF; Fri, 7 Feb 2025 13:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936796; bh=7M8zHdU1PZn0d0vrNjtFpzTQwFdAblqqoVi6ORrd108=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rAi3NjAbFr36QPN24l/FBnpmVzGtV7/+ser5JHaumB5qBoZhYlMHRjvYQTV+mEKZK 9dQ1DdcDRDIBF/hktzCYZRusQmp1G87MLiR52SpqfEgFkLWHV5cxxbWlb6jKXTusSs 6nbtG2+H+ppOEjYdg37yF2IcgXCNMqr4F4M3koKK9wNL8uuCduf3ODen3C6bYTMrqh 4k6DY/auorA56Bb+lSKGybX/7paOmnOAGyZkTjTqDcAMNqz/LkSjpPUuF9QTeaPDTy KAFjR7QmNgiBhEs5oRJMq5EzUJAh1PcX8hUhLYMvCojNXyG6FPcaPnmQfxYYdygxei rDswXr3WAJT4A== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:29 +0100 Subject: [PATCH net-next v3 11/15] mptcp: pm: add id parameter for get_addr Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-11-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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=5775; i=matttbe@kernel.org; h=from:subject:message-id; bh=HXd6Aj/DYG7JLfN2KwZ/tTYEUnX7lmHLq+ywdaJ48lI=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG99hO3JHkPR9+8pUdNVaf4dwM34Hzq1mvrV kwFCMUc6eeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c+NYEADMfi6JGT7GkY7dfJGZBGp/hJBeEtXi+s/jWSVDpFr0nTTF4njDtHnPyOx3hEmTCfDLpIF PuP4bGiQcjYS3GqRt+jKxEMzhB9ILWGIkjrfJRvriAWgXeXsstD0VC7VcaCWppBLqjo4FNJxNPC PqQHhSuWYmk1Xpo4+2Gb9eIv7H4WL6N+x3TjoBg6oOxY2o1TcztSH3SFq8m0a3RLDZWo4UNG3jP Fz6vbGO+fDWWbZlLAfqUBQsvFiIC2BwWhPbUqjHwSuJP+/IdpT2dV7HsBLg2StWxz+rMfG3sHw5 kl0NsE2Z2N9wNl070zb3dm8JFmOaDbV1q1TDaTIT1ibZjOwZqf9LLq+On56Q3NwJWRBX9H0Qpi2 1UAZ3+LyyaPNhIS+56BRkUuetIr77D4CmIc5PcFUdX7V1SAM8j7kW3Y6zV9L/M3Bl8CY4PzKAiy cS/kKHV1LFOIeVCZxZ2MBBlOfr8wesGlQE3X2jFEcHv7yuRnSNsgfGbkoVqcei6CUOzD0ZVGPQ/ EvkRfE7lDKx9qTrbUwe3d6pF3uNiPvpwyrkaJANYESRf0Y/vKJjs4Z+854KaLttjCjlPcEmgvvQ z9WZB9P0Msk8t4TZhbbYYXt9WzTeumTwZEDrxIduiXMJkW11UKDFwqgAWOMBD2IKzF6TRwvatyP 9HZF196GEpAbTyQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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) v3: - Same fix, but in mptcp_userspace_pm_get_addr(). --- net/mptcp/pm.c | 20 ++++++++++++++++---- net/mptcp/pm_netlink.c | 16 ++++------------ net/mptcp/pm_userspace.c | 16 ++++------------ net/mptcp/protocol.h | 4 ++-- 4 files changed, 26 insertions(+), 30 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 8185697044e2b735edb161578685411f9ab231e4..5a6c33d0063df7e741b9a83a624099adab1611f6 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..99e882a5a67180bc912818ec0952fd50ed601ac4 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -684,30 +684,22 @@ 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 nlattr *attr = attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; + 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; - 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 a4c799ecceffe2fe495c0066bcb31b9983d64b01..ffe370245ec55fe64b1215b48878d1bdaabd3248 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1134,8 +1134,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 Feb 7 13:59:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965054 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 594FF239091; Fri, 7 Feb 2025 13:59:58 +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=1738936799; cv=none; b=H9XFhRkLix23TpY5wDH5vQB5MRDraZwpWBwbZ0fXZJT5faGKkeCIGccfR7R0B9JjFaT6iAaz2ePdtm7z4M37Nh2CBOt6cbAbKz2DtWs6m/i6kwNMUWS2spterUCWcNxTVqsdxTpR7K64Xg+yyVXZF2kGyDze20ME86x7EXp/CI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936799; c=relaxed/simple; bh=eyhxiab3CGZAxQFHa4pGEaSwVVOA7tJGOIbXYlmFY1Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ivFYT4hSWhzWQ/DQ/tnjWArhZmZRN9UynMuzvFY0B58L6xNPvbXF/wHdFlayQmUs74avmO2/1wALh2TqRd+OKFlE0xBHQ4t5MkNtVunvxYZqpLXKpR77c5aIAN0Hu7fgoaairQdUukaXmoh5ZwLlsG/XSq/2M5wenw92tCmIw5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S+jyv35l; 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="S+jyv35l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C53B8C4CEE6; Fri, 7 Feb 2025 13:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936798; bh=eyhxiab3CGZAxQFHa4pGEaSwVVOA7tJGOIbXYlmFY1Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=S+jyv35lO5aZ46Dh9M8KEHHyHczA8m674VSKGF5N6B8c78mF1IJBBn22T8PRW8ZqG tbREL4a9jq87tiC9mVg1A5ujPeR42F0228vw/WcGBRHPf3RIl4gKN99RHN2lz44lTP ipEqvMFVLCfXR7T9gto5lKlV6Xi8YgVPt4mXVwd63ECCV+6vPmkQA2JvXWZzXVQr5V yaAWyhJ7Fd4M0IDUmKOqYpKPTEsTD9qpgvvQ8uW8sgq/fbRiNHoG+nwI1Dt+6Wt2lk Gf8SuZ6r8EpjSP6cSauTSl4sCyOnueGAMHeDTyQ0vZxWud+Sfqp0Oa8rkntPVmm8wU BFFlo5LbYsLsQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:30 +0100 Subject: [PATCH net-next v3 12/15] mptcp: pm: reuse sending nlmsg code in get_addr Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-12-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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=7830; i=matttbe@kernel.org; h=from:subject:message-id; bh=zL3wNCajhRrUYnP0+5iwG0YoRPZQFWrOYe4TJ8ENLPA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9kZrmuWcvyD6Fh3NiiazgJCKVfd/wK5ci5 YSsKJ372huJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c5lbD/99mBNC/DOX5uvhFj4QSfpk3hhJPRTZM+JmGm7UJgHf/3HFkpsKFYDgDeCL/ZlDTYZDj+9 g56e91ja9MEikSLXHrIX/h1PAFyvT2nmlW++4AY1txh5bMuafXmB5+GDxoAKee3fD05rOQjWcWy ApI9UuEi9/kzgY52rOtOVi64muV489YWoS0thga2QpDC2SJOCxMzpD9lrGsh3VhjrWGU0ToDDBI 4S6xpU8icSg4CNNBBEOZ8knaHHr/mbAjkQGKZgzPpCFqXdX37wFfcfpHW3WrpOkmkjmzE37fybG FCRmpbYki4kPjVY1JHiqeDcwboMF+uyJ3UqGWRCBCo48kMaXXMp6Jl9CCKax6u9e8P09TH9FvMd NRfnULjznoHcGf5flsT6fEuvPn3mueRuGv7Cw8rIcBUb2ug6bPZg6gMo6TxLRUfBKgselW57cB+ h39PlcVZj9nmnzi08pKK6fcm1mIXPWo7cY16WYu5t/jzySEXd4Hxy595xgKU2EWKfyv5lOzRlaW cYw98Akim9c0pvWzjeV9mLpP5GsqXKAnDUmNR3G70H2qTQ7eeNtTEWoDw6iaSniVo8LWYNl4Jyv WXlS685qFCYYELVdU2yhs4T13tP8+kzaJeY98k6Y3zRDXrxtjBwXZR0ogem0AQW0LEX3CHLoWam HCCPRWtICYoAQwQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 5a6c33d0063df7e741b9a83a624099adab1611f6..25b66674171fc39d73d88948ba952816b504051e 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 99e882a5a67180bc912818ec0952fd50ed601ac4..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 nlattr *attr = attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; - struct sk_buff *msg; 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 ffe370245ec55fe64b1215b48878d1bdaabd3248..e18ecd77a7f76b5e4d010170532f7b9e913ec78b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1134,8 +1134,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 Feb 7 13:59:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965055 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 C85AF239787; Fri, 7 Feb 2025 14:00:01 +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=1738936801; cv=none; b=kJy6UYtXz1rx8LIiA6lvUWO/qCqApB0+mTR8KHYD/DAj1VkO8V6tF0zPTMyfaUys8g55qekFF7i+b7OTxpwJDSufDSU4K15U5QYM/ejyumQ6QPFkaOs6bSwwHRZEvHQ3PiRMqvjQ2bAmGtJA/kwLX3D4PrDebP6Ok4unb+TtMWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936801; c=relaxed/simple; bh=ea0vZWG8kOgTR77kccByve8CPXlkY2lK8CORWkN81B4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BZT98rgfpSPTtzY+7Zs2XhJnQRA1L0VCR0bC/xIEA4vFZa5hq42s28P6NxNk1WWfQDeKU7q+r1f2A6aUryjLsufsoWAl52y0WrovOKNLji8Tf/k2Y1hnF15Gqv1iMJxon3eec0eB75fyJRBK69mUXl00Y+V7PVkH08fR3GjNKN4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P8bVjdE8; 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="P8bVjdE8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43350C4CED1; Fri, 7 Feb 2025 13:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936801; bh=ea0vZWG8kOgTR77kccByve8CPXlkY2lK8CORWkN81B4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=P8bVjdE8+BEzPxLxqE6cU5jEQ/p861uTspVJQhV8rDShObKHRMlOLoIiyMCl7Fbox FR8moyjgqYQLTMI7JamYTaXyGm2rmP9L7ov2NnocXJ6mEa1C7v9blDHaPjBDEkCRTi scgMFrA3h46wd7wHOyAX+DgzH6KiP5mEKAL3JZlc3kZLtr0ZWq2F3iRfkKV5pvjo4W r8dwh3OFfWZC/llKKyBgC3W0Xg6QCeYKVqe7/0ccgneU744RuEkiaDDeFFErzr6etw B+2D5+4ZMzvd+VW/fIre8gi8DFSRgfgswRm6HscMEc6xIcYAjgEuw4y39VooSOFJbM rgwacJcMqyY8g== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:31 +0100 Subject: [PATCH net-next v3 13/15] mptcp: pm: drop skb parameter of set_flags Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-13-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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=g7nmmeVUyAQjhxQFKwC0d9BzoN+mnTfzrT4q5SyYE+8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9Lzg1uD/LdHfjfsSzPzpEykVfBGAhd3RQJ z/HzwFeu+qJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c6VSEADA6kX0IjTgySXTiMQXXNzS3aAWCnfFbuky7Qt9X0HLq2aLJb1Tk3gA8M9DobpMA4MB77+ m5nzyTN+2V+KaBJ0v+h3i26sSjBsepfsObflNbGE6yEK1HwO+3f954HPAQhzjDuKALVB/KeiB+p 5VpnJdq7tjo9E8FqhGNrmYh6d/51iExQdjtXkQQOiBkjq4QBmGoYnJOaAGuGAXYXq5+KlRugN7n pC4dtWuuVn2ZCWo5JHBXsiIozGG0oAvF4OMoV4nV68fBfxzzRgzVnQMuZA/d/qJMNKNgAU8FuQj i+J+Ddjve9XhDBIGpMmi8MUKakIrnQPX9pA+5SE4htD4M4onhAk6ILHjiIHR/P55m7kshb2pEEh 1VS1KovVgk0s8tYqA00hgKVt0eAcM4GSYe0/DyTsuUNrRWSzmup1iYwmGFPfKXYiC8rvt4/ZMk4 U0uOtqLF8IWcNNFoiLoFfYpWS/rNvx8HM36nybkzROscxe8Cz3Xu+Jzwpp0K5w1F6XdDsYumFea Ux5yb/8yV7l4K7OE5PSMyd7s1bXh1SEdXg1dpyHN9HCSiu0bt2LswB38uAK9D/4HFTrf+J0bkXn ZK2ndl9JPrl7vmRADNByjAmQ8b1M1eMXmVL9TERHQhcYoojQcrEZtNuv8Ab6ub4y/RgON+Svfd7 Y8geJAEr5590x1Q== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 25b66674171fc39d73d88948ba952816b504051e..172ddb04e3495348a62feb4b634ed2c32ad7dce2 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 e18ecd77a7f76b5e4d010170532f7b9e913ec78b..6e7dc5375e291f9b6ec27bc8c632691401b91717 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1038,8 +1038,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 Feb 7 13:59:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965056 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 DC49C239091; Fri, 7 Feb 2025 14:00:03 +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=1738936804; cv=none; b=M08oCIhvFuFoRu3rCi5dEIn57F8BFJ9jYQXjl/X9XtDayL4+l1ZI2rOlhTH6vYTPwy6HVgELHtJfXUOVO4GdAf09yga++A/qnjV4RwKsiTdXaAPQuM5HTss0LwnDUIdHDxyOd10wjH8q/a95EdlPHxW7NjJ7YC/OwHQtMKALbgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936804; c=relaxed/simple; bh=gBNXX9ppG946EXfwDDL/S6hzfb1PJK8Xt2CCfsMNeRs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kckF/OWK730eErbAy2EdkVNlVt31h0KxOY7zYIq9To47ztGtd6g5RYCszQun6meYCoxWHZMaeLESlMeQN3A74FB5r/R1bDCd65IfXBgQRBajgksq+HpatFa10X0nPDmhokFPfo0h/bOobBs6rPrxtguB+jpTjrlQS4bES6Lg4uU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UVW6iDix; 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="UVW6iDix" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3820C4CEE7; Fri, 7 Feb 2025 14:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936803; bh=gBNXX9ppG946EXfwDDL/S6hzfb1PJK8Xt2CCfsMNeRs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UVW6iDixZPM03snWEoDWVl0eqsINxQsqqq6ETYVoi9K06dMeEgy2Zf3MVRvS2zY8u LbSNqvOFfkoVCbgajrrAONMI4ZEteoKyOhkXV9at90QKQb5zvupDr0P6AP3/+AzBql OD7+Vj3Krwl28YdSWtHGERNIGR4NEUrXxGu+Z01hhY/pjPCxeRF+lD0kgdFSy38unk Uw/jvvuRroOA+Nuqb0Jtfcwt9gFly7sDiRbB8mlJW7c1+cx7miN/jZNrPVZO+PNmxZ hPm/jz8mXcoPy/odakSc8y9JlJh0c++fHeIO6gJUOuAnAmvFD2kIbSpOluo24XKy9N hE7V2WXHrX3DA== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:32 +0100 Subject: [PATCH net-next v3 14/15] mptcp: pm: change rem type of set_flags Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-14-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9Li8/Ot5614PI27kR6K7q+MxvlhgH13OZW aF4FxbTATuJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c9mwEACHu4bBv+3KvVU4nQyKc0bVuUDh3YE64bHYtrJ806d3q7laAgrc5ekgiabtdsHG00y91r8 Fi4hFDY/hloDZ0u+WHKQlYjzBhOl1REsS7UzFG2ESQTT2hP4TFAnYmJxlndAR4HEkPmW23kGr3a RLTVvIwVZgSgZy6ACKL/JSFjkHoR6CFPorKu1JLtYtbgbXdkD+m8DM2UQZYbNxBWter0CknwevI yozM6T6BJO5Ed5rKaBG1uFu5GkmBK0dQNMtOfbP7eenWMm/L/npuZgtUty5e60FWzF/D2NcgL90 bpzIBBbPUWWTOWymIqwWzXml8Cpm+CC0n0Dxp40dTsa0t5TWp2urdr046huwPrs2wr1p0vEzIQQ xUyRPyODOFjXY6TVZiGkkT2UGqlzQLjs2vVC4qWS53F/PpRsh+9FD2Oqdvtp90XW+MhtAmPA2dm OP9ZNDZajrFMf+GeenYQ68R0wpsVDasN2yrzugQ+KRBqNLXbrXdPIelj6G3e1S+tRLPL3ciCHVO UX1FWCruMqPjFs3KY3Ul8mWMHa771Redl+tvwax3oIOam95blaZyRYIVYKI+t5os7tfOvdbY2UI jYQA1+cmam47dPqr9++bIyjc826zRKw9e8mpdudXI+daspS7kWPXQ8DKZZtOebUi3Okk/Q2JMVB xAPwWNwBGUlDZrw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 Feb 7 13:59:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13965057 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 B7E3723AE80; Fri, 7 Feb 2025 14:00:06 +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=1738936806; cv=none; b=ZHUTPE0Rmt2Qb1psyluJ9DiG8tG8zdmudgH1zGKbgiEd5A/vAp806CxEPBEE4RmUiYSryjOYPC7TtblHg5HD6g6MapkCMcYGoUDYcIsdEmChBopLl3B5uHqCeqCyENyC7jwF2wMGBZSwsed7ZI97sVAZIrpWpKEXKtSjCJ6/ISc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738936806; c=relaxed/simple; bh=w68cYSg6WyAk3uTwltAFjwgiEcD8LUi2kgnY+OQEoTc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JJFo30btRtyRJ0U7qYdiW6c2QIOpflrvvRfZX1C4GowY7rlswcweDat7FiaW6f/uffjiM1RH9jYVyTV6sVb7leYGeO8hzz/D+d2yuXgPzinIMezykXXzqZxL1F8V9Y0u7eA532zCJeCcu52KD8BVYBanWmgu85mM4LNJJtpQ3U4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aB+UAHNX; 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="aB+UAHNX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32454C4CED1; Fri, 7 Feb 2025 14:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738936806; bh=w68cYSg6WyAk3uTwltAFjwgiEcD8LUi2kgnY+OQEoTc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aB+UAHNXjhRnMEUxsk/HIrXDa2P8wLRz7kFR5nH/UC/ELAvBxLMcm2BGxCWeGj1XX WIu0aiZtJyszmNC0o8s07kkBLh0hq9AMiwSIfNogXhg1k5uNsTYio7DQryfLEbMl+/ KDRxqKqIHPiSGE9rgUxlbDpDX/0PYMMjHSKNie5a2CMhhSLXssRmHu+n0We1q3C+no uavJyOaJ1YmCKIjqkp4/P4OdgRDB97taygI+IWAnnvZZVFu7V5Vu253jdEeynjjOzS Lyiqs79moXlatoevDkpAbkxGFMjoDXeYYUHbIcajc29RD4Alrc9C9EEgBOZXjrbolS kxhzTYqxhWadQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Feb 2025 14:59:33 +0100 Subject: [PATCH net-next v3 15/15] mptcp: pm: add local parameter for set_flags Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-15-71753ed957de@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> In-Reply-To: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@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=7617; i=matttbe@kernel.org; h=from:subject:message-id; bh=qj9m8m0a3wfgfUzgBFHqOovOUzvV2q/ybgg+jHEABjI=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnphG9msOuXbrLsJrdogTH566Shz1XOiMDFTvsi 4iP4ohxhCuJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ6YRvQAKCRD2t4JPQmmg c8D5D/9TpPLISFDO3Jr63keIuvFWcSA/NJd4SvcW3vUcGQQYweBU2qkMarM3iUzUtvHEUMCoPgJ 9LbOrGE4px29l13A1Q7nMEiS/2/D4yro6tc/ZCQP5fU5lCGZyzq82R09oDxb0HNz1w2x8NCfy5M XtcAduO6EpFqPFpt1IT9Lp5FRJIBVvGLzvOGSwT+BOJDtMGOxmpY0x0rRTL0PlwuX61kZeZNu+L czE29qMaxDQ55/iZrOoat7VxVlxGxaSGaRG7fwhzrggHYKZzFbllXc5WvA8QCB4fYDlgmQpY7ft 8GpMowV2fpSm87Np0wERB6GUPiYNAz2RcqMpFOz3Czp00bou9dhW+yhq2Jp4Ws8fcbp1/D1CbGm abCJM4idzkdWUiwtuQcKXKTD0kVqSMTB72ykKnmzCEQBISIrfYuJOau3nKV+4C0JdIxkdwXtn1b MPFHgLDsMKYKEWEgI3f8yTn5y0qkrigHsY1uPnkqe63eIt+tYufSqw0H7BnuGsZds9XUG3EkI9/ xfd12yPo7ireNI93KHAyjSGeZk9Wq8fMet+cGbylR9hE7RlZ0yiRkkjHjGVLbWbn5eyKe2YP7Te rjyeDxPjZnSCRUNHutnS2KarqoifGPeAQnMSP8Hhv7kygys5mOaDZppazvQ431wYBTKzV7YsB0a 78TQj23YzxV4lUQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 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) Reviewed-by: Simon Horman --- 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 172ddb04e3495348a62feb4b634ed2c32ad7dce2..99705a9c2238c6be96e320e8cd1d12bfa0e0e7f0 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1951,50 +1951,41 @@ 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 | MPTCP_PM_ADDR_FLAG_IMPLICIT))) { spin_unlock_bh(&pernet->lock); @@ -2002,12 +1993,12 @@ int mptcp_pm_nl_set_flags(struct genl_info *info) 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 6e7dc5375e291f9b6ec27bc8c632691401b91717..37226cdd9e3717c4f8cf0d4c879a0feaaa91d459 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1038,8 +1038,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);