From patchwork Thu Jan 16 16:51: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: 13941988 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FF8322D4F2; Thu, 16 Jan 2025 16:54: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=1737046477; cv=none; b=BiQLxmNmMWVjn21lBsOiGdfShZ/RlPond4fruhCIPYtJExaB7G9Kzu4iRcfgYsLp9qscNl0NTkvbTThZHe1/iBx34IgahpmmOxnYgbc8SvdvEsGqgnILD7P8CiwpTIMYVH/LD/sQ8ben2htkBNnQuv0dO9GubleELOpKshL9xVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046477; c=relaxed/simple; bh=8G7twJP3JZxNmu7hReZPonWiPiIdhHNGTM+TQzqkMBQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U0gal/wWgnj6QAq5gVfGzkWHlNZGqqixHV8Miag6UvwbAqNo5SsOaugb8zU3YvAMYEqT5YOf/7DO1BjwpQCKkMABHsgYoj5kVJorOCmAZsqHWGDttbUV/ux4sUFIsvLyVyeguizmWgyY/+s0RXbihCe9YaOuyGuyv9dNi07mIOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K6UIBwkW; 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="K6UIBwkW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DA28C4CEE2; Thu, 16 Jan 2025 16:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046476; bh=8G7twJP3JZxNmu7hReZPonWiPiIdhHNGTM+TQzqkMBQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K6UIBwkWh+zJjFJ2Apb7WdVNtcjNGtZFSslN+w0J45eb2jQ5uhbOPygCAWb3BIIPe EJscv8bLVBy7RsqXZiMztshzqIEfd8VkgHIQgJEzrNYxN4kQXGpUMKnKsk+MK2oEgF IeCEHfY/Jo2WtnJwWiV0nuPOJsgJ2EdWGGqQr7bmbDLdcnR/MvhxJ2rArzSaXto4yl uGR2W2Nc4rcKUb5TtLFEe4uLZc9JgV1ULA5Ck/VS38vtCEH4muvNidpYofZFYmMc+x Cc0djT0Fl7DwWTDAS0Syw8nd2r3s7fN//onbi8+agXecDFN9dz19NQyGW42RN1C5PR L+ys/saQ8LLeQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:23 +0100 Subject: [PATCH net-next 01/15] mptcp: pm: drop info of userspace_pm_remove_id_zero_address Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-1-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnGcJpIVPIiFC/QvpeyHsU4abcZGVpWK6QJR i/kaZ6MQsuJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xgAKCRD2t4JPQmmg c9Q+D/9n5YbhzQqbpDvNsZM7ziFTBKqt9X5BRORy4VL+Lu9VUuh5FUzTdds7zeteIrf4L1/eTJQ yCzsOcA/ELRPOCeirAmevkWIeCFR2Fad08A8bI85tEPOZ3kSoexY+i95Hqxnslc2AXEL0WmfzAi B6fSSN0asofVy8r/UyQ+hFURmFX9PpkxLlyYdwI4v4zVYqXaaESRxrt3UStrYgQzjOiDc0NY71P 08Kgh1h66MDrRlQR7xFiUB4kBqxlVE3SexFp5nggTSblWlLj33rj0vPLLNaLo19tyi9VwMRyueg nxp0nbj2ziD6H1JQpJNVnJjP3dIXd/DgNAKUCVtPv80u5thPuqHAT32NLe0KfnwoT2dg3cI/t2g yS9xYcr6778AGXKtMjSwQgrpAsomrmUacBQ+QmZtK794f4B//Pd+nwgLbJXxcC3BBxNyz8xm7oi ph2fHtECJwrBrK7GIvRRHQ6SP6ds4NLVAGPd/RwdL6/FTO+Y71VkpMowRcU4+PrWnZSKYkiBbE6 RS69cosWAEKnrCZ17vmIt0qqrMbbyWlQHAlfvGEMG+UR15oaiH/xMpEU8YFr7o0Kppd8fOc+d+h KQrGvjPsb05qpUa3mei3JzAMo9OM73Md+CLfL2QF4I616Wo6F8uFbPqa4h0llpIn0QE0naYui1y lKYSpZOYqQStaqQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The only use of 'info' parameter of userspace_pm_remove_id_zero_address() is to set an error message into it. Plus, this helper will only fail when it cannot find any subflows with a local address ID 0. This patch drops this parameter and sets the error message where this function is called in mptcp_pm_nl_remove_doit(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index a3d477059b11c3a5618dbb6256434a8e55845995..4de38bc03ab8add367720262f353dd20cacac108 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -253,8 +253,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) return err; } -static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk, - struct genl_info *info) +static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk) { struct mptcp_rm_list list = { .nr = 0 }; struct mptcp_subflow_context *subflow; @@ -269,10 +268,8 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk, break; } } - if (!has_id_0) { - GENL_SET_ERR_MSG(info, "address with id 0 not found"); + if (!has_id_0) goto remove_err; - } list.ids[list.nr++] = 0; @@ -330,7 +327,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk; if (id_val == 0) { - err = mptcp_userspace_pm_remove_id_zero_address(msk, info); + err = mptcp_userspace_pm_remove_id_zero_address(msk); goto out; } @@ -339,7 +336,6 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) spin_lock_bh(&msk->pm.lock); match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val); if (!match) { - GENL_SET_ERR_MSG(info, "address with specified id not found"); spin_unlock_bh(&msk->pm.lock); release_sock(sk); goto out; @@ -356,6 +352,11 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) err = 0; out: + if (err) + GENL_SET_ERR_MSG_FMT(info, + "address with id %u not found", + id_val); + sock_put(sk); return err; } From patchwork Thu Jan 16 16:51: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: 13941989 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A791822F38C; Thu, 16 Jan 2025 16:54: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=1737046479; cv=none; b=EHpZKd/veX97UbkrvfadciW3aaIs8s16PQuBPpg0nGlMA4M1QzPkm6g3wQ7utC3LaKKIN+qQOtbmv2SJheP49Eb2U58s6HSm+lioPcyd8Rqn693Wkk0L5zwuVzB19YMU67JQIaTZhx3hJAQsF4L45SjCp8/1E8rCyqxlyiJaJik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046479; 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=hqlKU+8B0IdIbP03CPPGgSKaNRlpokoAb0jcWWZdXPOFZGlN4+zEWIbHf4ybAgGrgn4Ualh0UU0zV03xaniPRk9syUecwuabfrrz8oUmz3/7Xl3sqSdaovz6Hxk9Hd6u8tBtz+hgP4VJAKgaAl+chjv6ewUuet0l+9zhS2zQln8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kocE188b; 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="kocE188b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C39FC4CED6; Thu, 16 Jan 2025 16:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046479; bh=B/7KR3jBwTwNArI5wXpFWpYyFwZ/q/RqH8P6VfvLqUs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kocE188bKrxqczw35nkntL1/h5XiHxLaaJWv6+N1L/0mLxvsMU5MypQqHJTszaJyZ kKe1yso05A8So0A1DEJxrIH7RJnokYQssze2m6XkZH0F3QDNsVfmCXgUgpdmp7Liv2 UoPak1BAKHT2GAd48W8SozgqmOTgSE7FnKeUmlujSkGvKCZK4u1GMfVqKmZ4L7iO1W yRRVkUW0TXzokPqI+9JU3s5J4lW8QLJgSvPgsE5QJTpH8RPGkkK4zou5NJfH46yu0S dQXoDqPHoodGuJfd1N5qZHnqhEkk73YGjJlS7aTUalKUwQiKzrN0QkibTf9Potk5Zr nlLIi+grK8d7Q== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:24 +0100 Subject: [PATCH net-next 02/15] mptcp: pm: userspace: flags: clearer msg if no remote addr Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-2-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnG4XnKMZnZXgKIw/bNiM6dV3QmPZNtyBlaZ vaXtuenvy6JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xgAKCRD2t4JPQmmg c1yuD/0fl6XOA2/D9kN65aKOsvLheImK0w+a8hO8IqcY5pNYR8/9swt9kTlhJvl/UQvmTxdGGQH vIOfKpB+mVlxPVBigECUw29aGo2tKGpFtajpYfWjXwBR9LNYWALlTX1p8WgJYjQY1JR2+7BXImt DsGQK0oo55k0FIT9LZTWtSaGWIj0x3I3U0VaOK1Fs9h9ZmIw+MUb0bcOU5oKH6dAYFf4JBS5ttd b7PbRfDytyTcx/2LNiwKEtj+72RUiI9MqB5hSLghq/Eewhl8fvZBOjfFru9bzaPRctbSibDgHFX K6GDBP5fALJu629ODLEVzJCA9rhuyC3py+X5FajskUhu7Z2DGAnXXDigfdpgZ+saB7+0EzsShg5 tLAO3yefNbhRqjUVORWXJ4atdricCKXyfkRGImPtz7sdOqXm48tQMTd7JklZgBM81/GFIOXppjt R8TtVUxo0sw4ljIojArqOgPJO2g1EipYI/D9gyR2UTt2hZznohL4lEwMyHVfvI5qnNLKeCNpd1n bOeJNC/6VaGUGuVABX4lXTZMnPMVpmKqy85jJuXaoqYSVv46o7cKh8QzZGmJDwdg/uhPt+EaAWc deNtVPQ+bGcK1RDzPENH5uURZVMDbWnx9AFMVTdEQbL02LK8g/Efgg+fv0owpzWd7Cn8xVmDSld xZTMivj0mBTH/DA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org Since its introduction in commit 892f396c8e68 ("mptcp: netlink: issue MP_PRIO signals from userspace PMs"), it was mandatory to specify the remote address, because of the 'if (rem->addr.family == AF_UNSPEC)' check done later one. In theory, this attribute can be optional, but it sounds better to be precise to avoid sending the MP_PRIO on the wrong subflow, e.g. if there are multiple subflows attached to the same local ID. This can be relaxed later on if there is a need to act on multiple subflows with one command. For the moment, the check to see if attr_rem is NULL can be removed, because mptcp_pm_parse_entry() will do this check as well, no need to do that differently here. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 4de38bc03ab8add367720262f353dd20cacac108..b6cf8ea1161ddc7f0f1662320aebfe720f55e722 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -580,11 +580,9 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) if (ret < 0) goto set_flags_err; - if (attr_rem) { - ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); - if (ret < 0) - goto set_flags_err; - } + ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); + if (ret < 0) + goto set_flags_err; if (loc.addr.family == AF_UNSPEC || rem.addr.family == AF_UNSPEC) { From patchwork Thu Jan 16 16:51: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: 13941990 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A74B22CBEE; Thu, 16 Jan 2025 16:54:42 +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=1737046482; cv=none; b=IvMaubL16SF1jV0sVwToNVrGue4rAxGxSSQcCMRadybgR67zizNBfeSzlG65svMwX8h4BuXuk/yLBwU1rRtASYdMFcrEBMEaLO7tfSvOeSksqsj/RXtKdQebFMJV/zfdLmreWjMf5LcB6BH2UE3LT+n1RV8Q166lU0W0s9qLl94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046482; c=relaxed/simple; bh=ywVqaLMcTnS7/LX0E47JY1rOXoObiNL+nHvd4fAztMw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rVU4QI+ggoQik7atYRZe/4yaMP5+Nm+yF6BASiQo8k9Vb7uNU/BxXPYbz9fiUJiURluDstszr5hBY55NbFe3ztygF6XSj3XeQKixJiyBX8KsLZQrw9ULRlZTxzmMiWHsQkW6VAceeXOG2k7jHHVEXZxNcKBO4lXPKYBVFlYVBBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=btBbeVx/; 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="btBbeVx/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE51FC4CEE4; Thu, 16 Jan 2025 16:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046481; bh=ywVqaLMcTnS7/LX0E47JY1rOXoObiNL+nHvd4fAztMw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=btBbeVx/B1fuysYHpZEhH7jEMNdt2aNgACM6lCp5Q0hWA+YffLyrA/OOgpImkhheH 1CJ9IPU7b+zqP3O0CXs3W+/YZCnAxk8vB3MHk98ZwL2Px25/rdC24pu9F/uonq47N2 ay6mN6FLlzEWk0zo4nc5MvDN7cTeGRqnOw+O56QVIk4dcaTV2Dd4nRh33aNuhlIVSj 2gvmcDxOuAuihInoFJLU62RICDiWoR97ZKB+7FWqF7eXbCkZXmInKOANpMAptpz9dU IvsRlYSNfTIT5AR10QwVV/SEyfkUFZC9xwawEcEzjUPAmFJNcjkcmRsdc2Adc+mKP/ +cMwqH5/BeKmQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:25 +0100 Subject: [PATCH net-next 03/15] mptcp: pm: more precise error messages Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-3-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnG5p7BZzhyXeOBcJOMYIC0VKj7uIo+Eq/vA /HfLFgbB7uJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xgAKCRD2t4JPQmmg cyL0D/99IRidY4r9bsEAuJusa/tUeU8VvT9pcdn7BtM8Roym098NToGpxGmB9z0j5G97uUctqEc bvyC99NohQQpkCNO0pZ59PcT2TkIfLt3Nw8uCgVsyfLGWTFTpoEKF3gwfLloOuWEMQ5MFNQLeOW WZRx2WXpXDaVOtQ7RIWi+SXMGeALx7kVd0z8gs6gfSkCPi1Ykah0chmAArmX+eBav7NN3mas0vx TgFjUylms7oPIBp7KXNFH/dq0BsXrUKNOv9/aTfw7O0pMSrm5GrptJsFf/w2egJLeq1QHZC/P3o cb47DDX/dnucrMGvmxIuvc4ugCmL2OfKJlcmjGUoUEDJwcUKKfsKSULDHaAv4wxVmcXfKC2rH0d dZW5LjNLinWY1dY8yIZjOYoyBnG5e0gY8IghdlyxrOZ/bt4EDbqMnQz5FLdG0m5/TFPsaLLiccj PutRPcpEaGb+w+7dixCLKy4wFm3+hzw1Z3K7wID5/mFA+F1n5fZXHQhAjVCjXsY1yXelTmFyLhi Jxuu6N8NzEKQea9tZq1JHlnDsIXxIecWYIyZyoUxQhcghku89/VfG2248EQGaebmgUWR4Lv+fM/ SRzKB3RgDSwIUKxCd8RJ/yV4eCPeVS2Qf1veyBTJ5jO7aXCOTj4/H5oJRaOD609FH9rWwMPQE2Z 9kKQdqUEIzfyxEQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org Some errors reported by the userspace PM were vague: "this or that is invalid". It is easier for the userspace to know which part is wrong, instead of having to guess that. While at it, in mptcp_userspace_pm_set_flags() move the parsing after the check linked to the local attribute. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index b6cf8ea1161ddc7f0f1662320aebfe720f55e722..cdc83fabb7c2c45bc3d7c954a824c8f27bb85718 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -223,8 +223,14 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) goto announce_err; } - if (addr_val.addr.id == 0 || !(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { - GENL_SET_ERR_MSG(info, "invalid addr id or flags"); + if (addr_val.addr.id == 0) { + GENL_SET_ERR_MSG(info, "invalid addr id"); + err = -EINVAL; + goto announce_err; + } + + if (!(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { + GENL_SET_ERR_MSG(info, "invalid addr flags"); err = -EINVAL; goto announce_err; } @@ -531,8 +537,14 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info goto destroy_err; } - if (!addr_l.addr.port || !addr_r.port) { - GENL_SET_ERR_MSG(info, "missing local or remote port"); + if (!addr_l.addr.port) { + GENL_SET_ERR_MSG(info, "missing local port"); + err = -EINVAL; + goto destroy_err; + } + + if (!addr_r.port) { + GENL_SET_ERR_MSG(info, "missing remote port"); err = -EINVAL; goto destroy_err; } @@ -580,13 +592,18 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) if (ret < 0) goto set_flags_err; + if (loc.addr.family == AF_UNSPEC) { + GENL_SET_ERR_MSG(info, "invalid local address family"); + ret = -EINVAL; + goto set_flags_err; + } + ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); if (ret < 0) goto set_flags_err; - if (loc.addr.family == AF_UNSPEC || - rem.addr.family == AF_UNSPEC) { - GENL_SET_ERR_MSG(info, "invalid address families"); + if (rem.addr.family == AF_UNSPEC) { + GENL_SET_ERR_MSG(info, "invalid remote address family"); ret = -EINVAL; goto set_flags_err; } From patchwork Thu Jan 16 16:51: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: 13941991 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 034D723243D; Thu, 16 Jan 2025 16:54: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=1737046485; cv=none; b=jsf7BF3bL7nYiFDI/6/Ifvdr819u7LSIzD60y1+ZpDJDXdCAge2kIgK3yHEpUNVpYBhN+AlwIkANdL5a+JZDA0583pPM5IyT6CWvEQc2Pv0CtUajREKQHt/oPrHfcSUY5kGx9p6EyazjlWKlfptDFxtKAIKJuTkVKck6KLID5HM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046485; c=relaxed/simple; bh=ziY1kNo4JB2WGFwqk/DGfw7wmfDoIoZ2o4P5q2wJOOo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rahexGIIb6ojcDhF/v8aJzu4q30/jW66CGVDtAG3ZR9d5j0oFAzG9hsCCfQg/jfI9w4tbiFafdJu0KIBkLJFLJ1R0Q8tkreQzhO6/VdWSx4hNd03f9LvYl7gQdIh3ryd87Ib7x3S1XVBXGJIcIkmF9rXT4/kk3l1UIaGnUpuO2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=inGsTxum; 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="inGsTxum" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DB36C4CED6; Thu, 16 Jan 2025 16:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046484; bh=ziY1kNo4JB2WGFwqk/DGfw7wmfDoIoZ2o4P5q2wJOOo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=inGsTxumRBZ7RvrCNVdca+QhtgHIIQZCkmddqaTiKwpcy7KsAbII1C/0uigpDSuF5 GsjROws9rKQafYqo3Fl7Df/lF9WTeKgLXTxf8Ss9SD8KnU05/Fd3+vHOCDRiT4H9eK wPf+UzpkFoJhoKfhEsAbtv9hcpCB7L/VrX2Puppw+vbebTK7v+jopFGUSltZdoXMaT zT44MqcreA7ZOCSQBYLuXbDGsYPmy3na0CEQICh2x8vh5LQOzTiQI2EmLBpBUvXqvU 8l8a2I1zaAqBP+MMMv6ykEBxTwn28XtfH08qZ4YgSYlEaCZgE6XdlbrblQitYBuyf1 4Bx3EWvrwGMOA== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:26 +0100 Subject: [PATCH net-next 04/15] mptcp: pm: improve error messages Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-4-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3062; i=matttbe@kernel.org; h=from:subject:message-id; bh=ziY1kNo4JB2WGFwqk/DGfw7wmfDoIoZ2o4P5q2wJOOo=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnG4flcF3NSKxOkKdfa0fwkOjEhqGgpTHxlN ELnBh8thjqJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xgAKCRD2t4JPQmmg cwdoEACKPvWXr2JpO9PR2sJHAvp/i72MjOm6nii1F1GBA3jDcHiPmfuVSh1S0hwFSgStR/3rHHr Vkmk14p20H53tJT7SCl0jBdP/7+KuI72b1v0khnlrUlqdVYMDKJXk8Mfi37RP4EZhoO5aPgHNxV Ylg85KMYTHs92Wsf0kksGS371hrX2Rhu24CU4YvuOGavjT6dSrUZpWoF3eFa5fPzLLn8ZWEJes/ Ga3l1lk3uW52qwe/GpIVn1EAl+YQtAOgF2NtL600RbDVf1RazwPOpTR2nEYzEz08/Z2OYX1HleJ o5mKwoWD+NdLrp6krAhVk0m3upiiD4tRLW4E2DGEKjIUITAMLKMAKQp57d+vxer+Ds+RMJGVYlI 7k4eitue+Kc+XQe2K56G5wy5Vyrk8A5YvYkC7g4JF60ui3YMJkomdhuQe3V1lJZS94iUdmMlC6E O67K8Q+TTcoidAqImsKYLfKCaLoqnzPll6iLCSnCgYgE//QRYvdPZW+jxjLrmaNALeXiS0dXnMm WW9jZ7HjdTJxjRJZDst+9yK5UxpogHNRm/Q3WoJNBf+583VYqfW9yzby/B2PQXUrZE1Ol7ASYTa /t8G8UY/pfy0Pwh0y9rdhRzPRTbR9Cmok4dX4D8r7HwQODDFO/SorJR70NiYh343iUHlAFEUBgd IT7cMlGu6OtWxNA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org Some error messages were: - too generic: "missing input", "invalid request" - not precise enough: "limit greater than maximum" but what's the max? - missing: subflow not found, or connect error. This can be easily improved by being more precise, or adding new error messages. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 6 ++++-- net/mptcp/pm_userspace.c | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 98ac73938bd8196e196d5ee8c264784ba8d37645..a60217faf95debf870dd87ecf1afc1cde7c69bcf 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1875,7 +1875,9 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit) *limit = nla_get_u32(attr); if (*limit > MPTCP_PM_ADDR_MAX) { - GENL_SET_ERR_MSG(info, "limit greater than maximum"); + NL_SET_ERR_MSG_ATTR_FMT(info->extack, attr, + "limit greater than maximum (%u)", + MPTCP_PM_ADDR_MAX); return -EINVAL; } return 0; @@ -2003,7 +2005,7 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) if (addr.addr.family == AF_UNSPEC) { lookup_by_id = 1; if (!addr.addr.id) { - GENL_SET_ERR_MSG(info, "missing required inputs"); + GENL_SET_ERR_MSG(info, "missing address ID"); return -EOPNOTSUPP; } } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index cdc83fabb7c2c45bc3d7c954a824c8f27bb85718..e350d6cc23bf2e23c5f255ede51570d8596b4585 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -190,7 +190,7 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in } if (!mptcp_pm_is_userspace(msk)) { - GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected"); + GENL_SET_ERR_MSG(info, "userspace PM not selected"); sock_put((struct sock *)msk); return NULL; } @@ -428,6 +428,9 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) err = __mptcp_subflow_connect(sk, &local, &addr_r); release_sock(sk); + if (err) + GENL_SET_ERR_MSG_FMT(info, "connect error: %d", err); + spin_lock_bh(&msk->pm.lock); if (err) mptcp_userspace_pm_delete_local_addr(msk, &entry); @@ -552,6 +555,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info lock_sock(sk); ssk = mptcp_nl_find_ssk(msk, &addr_l.addr, &addr_r); if (!ssk) { + GENL_SET_ERR_MSG(info, "subflow not found"); err = -ESRCH; goto release_sock; } @@ -625,6 +629,10 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup); release_sock(sk); + /* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */ + if (ret < 0) + GENL_SET_ERR_MSG(info, "subflow not found"); + set_flags_err: sock_put(sk); return ret; From patchwork Thu Jan 16 16:51: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: 13941992 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9A372361C3; Thu, 16 Jan 2025 16:54:47 +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=1737046487; cv=none; b=oPP6Oar9L8seKluhq34iHpQKKc3fmJpoj9wQ+YHpFAs7m4aB5JlALKADK1Im/zat7vrrUGlnopbF7Pb4ozhFuH/HBU/90eqf2hUXxGN3ami/wGx5ThA0rJ+G/1pKYTMUghm+HQFPqj4bOEf1bA3gBZE/PD1j/xT0bmbfCE4ittk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046487; c=relaxed/simple; bh=Lqek27knGwgehju7/g0u3Xuoe0fvOylfOxCOeXWYdF8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iOGZIPcDKoJCfQOwl8zyB+Hk8K/teW95C45ZZGOSfo3H2CBESiNaZsvIz76ACd7q2jcJEP8X2uuVpUuCrHY8PE5/TU1YLvhj31oQfu25qtk2BM+XDP+l0ywHsw0OzNzHock4c7XD3Bip7UtWofzZNvZJ4bTIpV3xEqNcQwystV8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ctVg2z+I; 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="ctVg2z+I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F989C4CEE1; Thu, 16 Jan 2025 16:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046487; bh=Lqek27knGwgehju7/g0u3Xuoe0fvOylfOxCOeXWYdF8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ctVg2z+IKKSRIQv6sfb9+kzVGe9vPnMmZH0b6Jpa3HQ+PaxD6723KQrYbsc8JGGR5 S5MOWNTlYNcIzixxrGoVF0QGU5//zPYx9f1EIGqlfkNDPA5zDmoxPpjhIrqIqBi+8t DqWhJWvaxUnjM1ofDDX1/OQNjn8+5hpcXqlfie5mvE02gtK3YmnBWBWHzz4SxbqFGD EZO1ZCEA4WRX3BzedEsHwMsrsMldkeoB7at0yu3yREMcTRdbcAxbMSZnpgNSthf6Tz FbR7+UE2uDVylJqfJ2wFf5BremkwIzC6aAg74hnNfs8JKImA8e/iI5h+Zxva6gt6Qa 9faKXHGwl3o7g== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:27 +0100 Subject: [PATCH net-next 05/15] mptcp: pm: userspace: use GENL_REQ_ATTR_CHECK Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-5-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnGMEW6nWSrNjO4oDGjNH1e397ChpoBUcMOO 3Ht0CfCH8yJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xgAKCRD2t4JPQmmg c+7jD/9B6JQkGoAtGNmvjiCKDy54d0dzmOTsQPQlPZtwmxBGIpEefIENqvEB+Os4X0T0fuv8G5E 1W4BiQTpzTaPktuEND9RfnpApJVBj8flNCJgQ0r7pV5GIRg4ycRYkjj4xEtm9U00PieGRVkjqi4 70L1VYWGTg94GbRNITifIH/E7Sh2cR1faaAV0S6Q+g8Bg27xyNW03VG4th5pSfoD98CTGHvni/v cgfS/LrXA0jCQxhJ8QV8MDoaPLEjOprO+HQHXV/CGtNo06T1JaIhxUXLJOlXepJyULIQXFWfHDl UZszdV9Uhq1oxwlgqDx1uYTmjgSL4fDWxTS85Yke78YUCcbG/HksLGVrfwegO4vQf2Vh4SWWYe6 GjZL2UeBkKuEkKShUhxvZGQQ5AecayPpEE5dhFQ9MjXAVLcmXjeOCSVs1SBn3/X6qlzZT8ziEn+ wopBZyZMG0LZ6Drow/fcRQKgno2zwD/+mTU4BsGZ56VNm2uc5zozowz3E4rFwGDOKq6RuxJoy5i ysyhAoTXR3/X7GMxa4sYo+4ZRZDDTf3ByuWRNd7udPjRIgKoNIm9v3BVuB7Vazh5QzvgNHojtdP eXzwfYDTCd4W85tRnwKR7j0/TB67981B8Otl66NNklDK0DUPbEomEPu3P6LZKBN0lK8gmdHSTWi RGtvQ7gLAbF90yw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang A more general way to check if MPTCP_PM_ATTR_* exists in 'info' is to use GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_*) instead of directly reading info->attrs[MPTCP_PM_ATTR_*] and then checking if it's NULL. So this patch uses GENL_REQ_ATTR_CHECK() for userspace PM in mptcp_pm_nl_announce_doit(), mptcp_pm_nl_remove_doit(), mptcp_pm_nl_subflow_create_doit(), mptcp_pm_nl_subflow_destroy_doit() and mptcp_userspace_pm_get_sock(). Suggested-by: Jakub Kicinski Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index e350d6cc23bf2e23c5f255ede51570d8596b4585..4cbd234e267017801423f00c4617de692c21c358 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -175,14 +175,13 @@ bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *info) { - struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; struct mptcp_sock *msk; + struct nlattr *token; - if (!token) { - GENL_SET_ERR_MSG(info, "missing required token"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_TOKEN)) return NULL; - } + token = info->attrs[MPTCP_PM_ATTR_TOKEN]; msk = mptcp_token_get_sock(genl_info_net(info), nla_get_u32(token)); if (!msk) { NL_SET_ERR_MSG_ATTR(info->extack, token, "invalid token"); @@ -200,16 +199,14 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *addr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry addr_val; struct mptcp_sock *msk; + struct nlattr *addr; int err = -EINVAL; struct sock *sk; - if (!addr) { - GENL_SET_ERR_MSG(info, "missing required address"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)) return err; - } msk = mptcp_userspace_pm_get_sock(info); if (!msk) @@ -217,6 +214,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk; + addr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(addr, info, true, &addr_val); if (err < 0) { GENL_SET_ERR_MSG(info, "error parsing local address"); @@ -312,18 +310,17 @@ void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk, int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID]; struct mptcp_pm_addr_entry *match; struct mptcp_sock *msk; + struct nlattr *id; int err = -EINVAL; struct sock *sk; u8 id_val; - if (!id) { - GENL_SET_ERR_MSG(info, "missing required ID"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_LOC_ID)) return err; - } + id = info->attrs[MPTCP_PM_ATTR_LOC_ID]; id_val = nla_get_u8(id); msk = mptcp_userspace_pm_get_sock(info); @@ -369,19 +366,17 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; - struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry entry = { 0 }; struct mptcp_addr_info addr_r; + struct nlattr *raddr, *laddr; struct mptcp_pm_local local; struct mptcp_sock *msk; int err = -EINVAL; struct sock *sk; - if (!laddr || !raddr) { - GENL_SET_ERR_MSG(info, "missing required address(es)"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR) || + GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) return err; - } msk = mptcp_userspace_pm_get_sock(info); if (!msk) @@ -389,6 +384,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk; + laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(laddr, info, true, &entry); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); @@ -402,6 +398,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) } entry.flags |= MPTCP_PM_ADDR_FLAG_SUBFLOW; + raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; err = mptcp_pm_parse_addr(raddr, info, &addr_r); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); @@ -493,18 +490,16 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk, int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; - struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry addr_l; struct mptcp_addr_info addr_r; + struct nlattr *raddr, *laddr; struct mptcp_sock *msk; struct sock *sk, *ssk; int err = -EINVAL; - if (!laddr || !raddr) { - GENL_SET_ERR_MSG(info, "missing required address(es)"); + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR) || + GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) return err; - } msk = mptcp_userspace_pm_get_sock(info); if (!msk) @@ -512,12 +507,14 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info sk = (struct sock *)msk; + laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(laddr, info, true, &addr_l); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); goto destroy_err; } + raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; err = mptcp_pm_parse_addr(raddr, info, &addr_r); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); From patchwork Thu Jan 16 16:51: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: 13941993 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12BE7236A64; Thu, 16 Jan 2025 16:54:50 +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=1737046490; cv=none; b=Zuh76W4e4zjF7V4LtQN7OziGq+oQdm008YEOw6GwcvUFLYRqvtACfzLxM0+rzKncw+KskZiO/9ZonqZBZaBHEyH55g9EsDywiRTaiJPZ4hkxL9a+bXlOZc+2x7/6FxpRBTDYBWQHMwteUXYfS3/fKndrrEOKTBNFcYawpPmRpMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046490; c=relaxed/simple; bh=B4EoGp6iIdIcXqT3mYInhSvXfXsv3hE73F8zcYqYI/k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l/7Fny97U5Nhvb7G8s6Qr3llCY9bsAZNSikw2k+9Aqw3D9NV18V11Nm3zjMtAzJqiujX+a2aezKMmZ88hkWYcwPsbm4aFVjldbJ/xO97PFqwD+vpNA7YLrvfnTeE+lftX6MDK6CMSNkZPrgomG682gvKixvBw1aij77xMhUNJ4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cDOCjhAq; 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="cDOCjhAq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5AC3C4CEE6; Thu, 16 Jan 2025 16:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046489; bh=B4EoGp6iIdIcXqT3mYInhSvXfXsv3hE73F8zcYqYI/k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cDOCjhAqwsJSfrIsUAQOvwJyHuHD1cmp4DNPwwHUVAPmagp1VnCWjmmAmEyLrkAOt tk/Tj2Q7eVWvsMVlvQI9Vp0DaBnD262Oq6uHhLRfOxbegKmnFfXYKN/ANdOhYiferp eRI+D+4Ju0vcr3/+6vyJADvYtHmUMpwqOu8IPo8qYo4PlbwwtlHoQSwWkA7dZ01dyG gvkWQ029gAWKFGRu4GuVgme05Qi1bgDdAZnyUXj8vLNivxrfXCvh7egwzdOo7W5XlA gb8e7nl39FZQ6UAyt2M1oeQrpsCL+9h3ovFdHZ3FA034VIxKA0acJBM3ISuDyR8XXB lMVG59c/KSXgA== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:28 +0100 Subject: [PATCH net-next 06/15] mptcp: pm: remove duplicated error messages Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-6-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnGxaYLs1TiVRC6j/u7BoWWE7o1He2duD+i6 0v6100Sy9KJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xgAKCRD2t4JPQmmg c7ghEADZibm1B5keH3QNWL2BFKGVkglG5GMkIfhpIy+QH82FvbPTLj38h6UbBKmfN2dZvI+M3V2 M2VZwFMOOIUk2AhWW4PVGmeMEVwfSwPOJzVmv2IEkeXcxxVpAbkd/xM/D3oYwCv8lpRtZVX3Yt7 c23ILvStgQkmNisE7G0nsBguriKbQx/sEo8m2bqwrwJJA1VFhe1vdfnc8HIZq0Bs6GVzPuFbWlZ o6cxRHfT4HOiO/juKATPAK67VPddFyJrxJKip5XbXrExGo1tKgcA6Wx2XbxYu9BfUCMs9R+zXDL G4dqazq7xiqC7NzABRSbdkz0J0lb/EK3GhycHlLnvBptUIB0MsKYRx8YmIYulSixQGQExsZpg7Y rauSTW/FLkBquEs+qRlt9CPUXLso8LC2Ki6B/+95+sPfNwE1KTbu3PVYW3YZHOm4K2L02WBA4jF 5y2XQOK6fxuiZHdkJATFFI0KtQpHrNsbmDaW/4MIxZeCCDRN9twhVZsEqpqG2t0zzkLBPWFSBB7 KmvvSr4KxyyS5QwDzvwfXOvZbgNpBWlHt0W7rThOgDAKs5HaPAB/reVX9dyGAut+5zHE1brfQ68 /3SZlpGrdJaKEpt9n7M9MP6p9L6nHLkDxLHnQ+sAFICfIIzu6Vuux4cuxA4TmlKX/2oon9xcpaB xeH1CQJJZpolTTA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org mptcp_pm_parse_entry() and mptcp_pm_parse_addr() will already set a error message in case of parsing issue. Then, no need to override this error message with another less precise one: "error parsing address". Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 4cbd234e267017801423f00c4617de692c21c358..ab915716ed41830fb8690140071012218f5e3145 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -216,10 +216,8 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) addr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(addr, info, true, &addr_val); - if (err < 0) { - GENL_SET_ERR_MSG(info, "error parsing local address"); + if (err < 0) goto announce_err; - } if (addr_val.addr.id == 0) { GENL_SET_ERR_MSG(info, "invalid addr id"); @@ -386,10 +384,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(laddr, info, true, &entry); - if (err < 0) { - NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); + if (err < 0) goto create_err; - } if (entry.flags & MPTCP_PM_ADDR_FLAG_SIGNAL) { GENL_SET_ERR_MSG(info, "invalid addr flags"); @@ -400,10 +396,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; err = mptcp_pm_parse_addr(raddr, info, &addr_r); - if (err < 0) { - NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); + if (err < 0) goto create_err; - } if (!mptcp_pm_addr_families_match(sk, &entry.addr, &addr_r)) { GENL_SET_ERR_MSG(info, "families mismatch"); @@ -509,17 +503,13 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info laddr = info->attrs[MPTCP_PM_ATTR_ADDR]; err = mptcp_pm_parse_entry(laddr, info, true, &addr_l); - if (err < 0) { - NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); + if (err < 0) goto destroy_err; - } raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; err = mptcp_pm_parse_addr(raddr, info, &addr_r); - if (err < 0) { - NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); + if (err < 0) goto destroy_err; - } #if IS_ENABLED(CONFIG_MPTCP_IPV6) if (addr_l.addr.family == AF_INET && ipv6_addr_v4mapped(&addr_r.addr6)) { From patchwork Thu Jan 16 16:51: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: 13941994 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9D8E23F28D; Thu, 16 Jan 2025 16:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046492; cv=none; b=nO7Ii7m+ldDErwpoYzaHfeQx+cGEuzQColX2bi3Kf48NAwOtxCWDljszBOPNoIxzQHI0an0RL0zWl+Kf8Tvp49dkKHt3m1ASyW0o+rSuui0cOk930/AnZ9zB8tDS8S9Avr/5RNYe8VbBEq2V/WNOHkaxQ459si25Pc+pTZ8kz5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046492; c=relaxed/simple; bh=NtTz4FvD4ReIufzfyx8mW8HEmn5ARaIOpdOhSGpc6hE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ECsUpMGoV1qRoDq9HGok9znHYJ4ELMStAvpNFNsG3l5POp+1lJVobYYP3nJrXGXRH7sa1uyF3r7po/qSV6VIcmz073/9jjBkY7bTZYQqYpZ5yPLg6iKXzOJ5fvJrvSKnolAVF6TkYQhgRH8kgzj68fVZpc95q3SUovMn25Dow38= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rIfOMdyX; 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="rIfOMdyX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62AB2C4CEE1; Thu, 16 Jan 2025 16:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046492; bh=NtTz4FvD4ReIufzfyx8mW8HEmn5ARaIOpdOhSGpc6hE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rIfOMdyXjdC2GVJGpe5bnBDzUGHfeJ8Mmjd7kHCejyb1jkbBWB64g1s2YYftRLwn3 Yj1F8Wh9oTr91g4hHZV40uQOaCCx8niBLVSFd4W8kVJckDcvwlEMjAsj8+KDO/ozlG 0jhI1cfj1+WolPTw9/0SJwoLV8MfCYiT/YpFEIhWPYAdhL/mJjFfweEcqKBlCi0ozJ HY+C29bPw39FgolUTTzQRBslZ6kKxMZjnofQPr2sclKjUjtkaMf2TYounttWPoAbwS jtCAKtteP2R5r7C7n8RRb/TOhWlnU41MDh6wwg9ISpLMsh3zgpJfIsNSgX96lEd2vY PAPu6uxgXXwPg== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:29 +0100 Subject: [PATCH net-next 07/15] mptcp: pm: mark missing address attributes Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-7-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5806; i=matttbe@kernel.org; h=from:subject:message-id; bh=NtTz4FvD4ReIufzfyx8mW8HEmn5ARaIOpdOhSGpc6hE=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnG8pHlkcm6T87q+loHWfat4JPboJFgq6uAD pT+2vCHgl2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xgAKCRD2t4JPQmmg c3fxEADb/i1dJe6qKqZ3Mhn95Sd2UQSzW0INAhApqBJKlCWmecCkQ4IaO8TgZibbs6SGVynw2KF UmAD4zMrd3qiB5Qlu7Zh/o3AtpvMx0KORrTZ54FomimgcIpJL6oEacUJYSTwtsb/QhJ9U6YPk+V PVVpvenQ7+V+HCv+SRDcpnD0Qd9RLDW6NmZVzqh/WMCX+ecbOqWSYDyPwtF2wkIAIbIlkDt5Yne ar1MksdC2rw0bgHgQrLzECrIg4/gyJU3eXOriqORLL40mAnRtbZu+ZBNJwLjnnbOHvFDB4u7HS7 mlWJt80EnVi8tucDy/FzPGvtmKIo+SzbUjlolkG9zqSOLVODS0cG+WpUIXSfCxND/wS0LYDJOoD one+/UGZ4cufk+Tg0I9K4R3M/dSlb4hWj5qOWwZHGFLvoKzlcSnW1lq0seDd77wNiRuoyJr5k+7 HcYdPf3EmfbYLbcJWucsx/uBsN7sQZ/PWPLUefgVZILlw/Zh5aZaPzYtKafyzqAFDbFWBPM8Ksr bEUGagrC1WUMFIAe00625slUcGXkALGyjLaACrwv8TLgrGtD6BL+6fA3O/Ybqf1hJXsNDI2NBfx ApkfzfKiGXArH22J56w5ClAHeJ3N4U8KGd8g/FEA0/4ESekf7vuH5CbR9jL/W4pAWtNJueh8/eV h24evxHRc2odASg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org mptcp_pm_parse_entry() will check if the given attribute is defined. If not, it will return a generic error: "missing address info". It might then not be clear for the userspace developer which attribute is missing, especially when the command takes multiple addresses. By using GENL_REQ_ATTR_CHECK(), the userspace will get a hint about which attribute is missing, making thing clearer. Note that this is what was already done for most of the other MPTCP NL commands, this patch simply adds the missing ones. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 24 ++++++++++++++++++++---- net/mptcp/pm_userspace.c | 15 ++++++++++++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index a60217faf95debf870dd87ecf1afc1cde7c69bcf..ab56630b1d9ce59af4603a5af37153d74c79dbb2 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1393,11 +1393,15 @@ static bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr, int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; + struct nlattr *attr; int ret; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return -EINVAL; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; ret = mptcp_pm_parse_entry(attr, info, true, &addr); if (ret < 0) return ret; @@ -1587,12 +1591,16 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; unsigned int addr_max; + struct nlattr *attr; int ret; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return -EINVAL; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) return ret; @@ -1764,13 +1772,17 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; struct sk_buff *msg; + struct nlattr *attr; void *reply; int ret; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return -EINVAL; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) return ret; @@ -1986,18 +1998,22 @@ static int mptcp_nl_set_flags(struct net *net, int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; - struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP | MPTCP_PM_ADDR_FLAG_FULLMESH; struct net *net = sock_net(skb->sk); struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; + struct nlattr *attr; u8 lookup_by_id = 0; u8 bkup = 0; int ret; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)) + return -EINVAL; + pernet = pm_nl_get_pernet(net); + attr = info->attrs[MPTCP_PM_ATTR_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) return ret; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index ab915716ed41830fb8690140071012218f5e3145..525dcb84353f946a24923a1345a6e4b20a60663b 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -565,20 +565,24 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; struct mptcp_pm_addr_entry rem = { .addr = { .family = AF_UNSPEC }, }; - struct nlattr *attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; - struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry *entry; + struct nlattr *attr, *attr_rem; struct mptcp_sock *msk; int ret = -EINVAL; struct sock *sk; u8 bkup = 0; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR) || + GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) + return ret; + msk = mptcp_userspace_pm_get_sock(info); if (!msk) return ret; sk = (struct sock *)msk; + attr = info->attrs[MPTCP_PM_ATTR_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &loc); if (ret < 0) goto set_flags_err; @@ -589,6 +593,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) goto set_flags_err; } + attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); if (ret < 0) goto set_flags_err; @@ -677,20 +682,24 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, int mptcp_userspace_pm_get_addr(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct mptcp_pm_addr_entry addr, *entry; struct mptcp_sock *msk; struct sk_buff *msg; + struct nlattr *attr; int ret = -EINVAL; struct sock *sk; void *reply; + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return ret; + msk = mptcp_userspace_pm_get_sock(info); if (!msk) return ret; sk = (struct sock *)msk; + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &addr); if (ret < 0) goto out; From patchwork Thu Jan 16 16:51: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: 13941995 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B15F2416B8; Thu, 16 Jan 2025 16:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046495; cv=none; b=NW80VKJkFlPL/xYjjFkn8c1j6STn8bxlgki1Akgeg+YCWGVVHTQ3VZLa9rjraeGHeY0EWOvfdxSPFA3Xbotdr1ecRHhVNfBTtA/UyS0S8C1dBE9yG3qAnsOpRbT63euO0/SYL0khHSMKK/eliAPCPMW12SFlTKVdw9uiRdn3wug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046495; c=relaxed/simple; bh=59FzKF1u2GGsoOoRmtQfpYMeM5tjI0LbHfzsM02NFM4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bEA/DPFkRhXnEg4FxnUzMQI4kCGKqhj6X0NGzYsMuv1cTcdv9aG1+dOo4mwH5qYvNNTXwWUfY6X6TEPwnRaRxurh74S4te475LpOIGNplwEVvOyuivzMKRSU10S0T+GVknikGhDTlcUkOG9gexjyo9ex2lzmKnXrhGHuaJ8ZtJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a2jot5AU; 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="a2jot5AU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 136A9C4CEE6; Thu, 16 Jan 2025 16:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046495; bh=59FzKF1u2GGsoOoRmtQfpYMeM5tjI0LbHfzsM02NFM4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=a2jot5AU5vJbZG982+VblX5SsUohW3i4EEZChyH/wryfSu6xa+VtBluzAHBhSHPai 9u8Kfu4iHFzu/xvdJyFz2NOTLwqvMNIdxiNlIg0Y3w3wnh/sR7qAB9wYrscIm2N/sj nplwPiSQRv2VfVHFTsQoq9rCFI9PwGykYQu8VG3aimCVsLbuR2NkvOsfi4TnfsEFvm P43/h357FPLQ8DwZnQ/bBylTsAcG4JlbSQfskiyEiyURDFSGudBHkCZ7AkTUmtni/N EHseScrm5ZbugC+TzI20KvNozcQksf8Z1CFGOw2CB20M6Q1fQZUux2IvEVYAKYG7dK k/9zYHpvL9/aQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:30 +0100 Subject: [PATCH net-next 08/15] mptcp: pm: use NL_SET_ERR_MSG_ATTR when possible Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-8-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7479; i=matttbe@kernel.org; h=from:subject:message-id; bh=59FzKF1u2GGsoOoRmtQfpYMeM5tjI0LbHfzsM02NFM4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnGx1Z2dDYmycAcrHiNQ2XmZd3vZcsUVbXWO v8OtUk0xvKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xgAKCRD2t4JPQmmg c9cjEADabaoDJQx29XGd32SHjiSngwES1RDnsP68VVl/xs1GwH9tC1liQuiyrmDpOcpAVItKtDZ JnyYSUCDGkS1dYqsgPRJ8ZNGmwhe51OizOBAitNS/am/jwu5QzDcnB8S3zS22zTYzlb0X7zJbiV WdT/Q/7+HYbNz3/dgW0x0tzhZMQ61W2WnSUZZ5lVow8uyKIwhviy6DSItWLdb2u+7a9xzl1M/lx xvEv7SKqgT5dlV78PlpCoNP3tvNuBXjw2+TAZyVKUDfpeUIvVBaZouR+9JTMqu2d7Rco3kjJumd cU3pkm796ugPIZhfTbFnm83p6oL58gZQXPhiRzbXvxE/d6EYCtXgikjwHbwe98N6hCCfc9O1WBx 3GpOX4svW9Y8jsypvUzcTVPt++Z/ZUyA+dgkssQ4+5YnS96MXWhKgVc9LCONcC7IVMmFHFx8azV yNo2zjBy1+RUiLaMBQVrQJRWMS7NJR+VmC5c8VzpsTQMHJfCmQmFP2qfhAh9Qv7JIZ/IAs12mVU wJGlYnEmwWkCMjo/oJnMp+WBbULveAqwiNBjFY5icMYNgYtONWTsZNa9TN7gQ+Dxbcyt/g3Nxb3 uWHlOdYm9cvaPUrPIc54wHbMCVeqX9q9T9ery4au0fpCHxVZT6HVEQ/PkfoDKzRFm02+4zDc3sQ zZV+Ou+BR7ovTxA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org Instead of only returning a text message with GENL_SET_ERR_MSG(), NL_SET_ERR_MSG_ATTR() can help the userspace developers by also reporting which attribute is faulty. When the error is specific to an attribute, NL_SET_ERR_MSG_ATTR() is now used. The error messages have not been modified in this commit. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 20 ++++++++++++-------- net/mptcp/pm_userspace.c | 33 +++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index ab56630b1d9ce59af4603a5af37153d74c79dbb2..04ab3328c785e804322dbe4fc56da85a58b8e0ea 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1407,18 +1407,21 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) return ret; if (addr.addr.port && !address_use_port(&addr)) { - GENL_SET_ERR_MSG(info, "flags must have signal and not subflow when using port"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "flags must have signal and not subflow when using port"); return -EINVAL; } if (addr.flags & MPTCP_PM_ADDR_FLAG_SIGNAL && addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) { - GENL_SET_ERR_MSG(info, "flags mustn't have both signal and fullmesh"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "flags mustn't have both signal and fullmesh"); return -EINVAL; } if (addr.flags & MPTCP_PM_ADDR_FLAG_IMPLICIT) { - GENL_SET_ERR_MSG(info, "can't create IMPLICIT endpoint"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "can't create IMPLICIT endpoint"); return -EINVAL; } @@ -1616,7 +1619,7 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) spin_lock_bh(&pernet->lock); entry = __lookup_addr_by_id(pernet, addr.addr.id); if (!entry) { - GENL_SET_ERR_MSG(info, "address not found"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); spin_unlock_bh(&pernet->lock); return -EINVAL; } @@ -1802,7 +1805,7 @@ int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info) rcu_read_lock(); entry = __lookup_addr_by_id(pernet, addr.addr.id); if (!entry) { - GENL_SET_ERR_MSG(info, "address not found"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); ret = -EINVAL; goto unlock_fail; } @@ -2021,7 +2024,8 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) if (addr.addr.family == AF_UNSPEC) { lookup_by_id = 1; if (!addr.addr.id) { - GENL_SET_ERR_MSG(info, "missing address ID"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "missing address ID"); return -EOPNOTSUPP; } } @@ -2034,13 +2038,13 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) __lookup_addr(pernet, &addr.addr); if (!entry) { spin_unlock_bh(&pernet->lock); - GENL_SET_ERR_MSG(info, "address not found"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); return -EINVAL; } if ((addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { spin_unlock_bh(&pernet->lock); - GENL_SET_ERR_MSG(info, "invalid addr flags"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "invalid addr flags"); return -EINVAL; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 525dcb84353f946a24923a1345a6e4b20a60663b..8dddb16247363a11ba11bcb94c4557dd0cfd8745 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -189,7 +189,8 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in } if (!mptcp_pm_is_userspace(msk)) { - GENL_SET_ERR_MSG(info, "userspace PM not selected"); + NL_SET_ERR_MSG_ATTR(info->extack, token, + "userspace PM not selected"); sock_put((struct sock *)msk); return NULL; } @@ -220,20 +221,21 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) goto announce_err; if (addr_val.addr.id == 0) { - GENL_SET_ERR_MSG(info, "invalid addr id"); + NL_SET_ERR_MSG_ATTR(info->extack, addr, "invalid addr id"); err = -EINVAL; goto announce_err; } if (!(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { - GENL_SET_ERR_MSG(info, "invalid addr flags"); + NL_SET_ERR_MSG_ATTR(info->extack, addr, "invalid addr flags"); err = -EINVAL; goto announce_err; } err = mptcp_userspace_pm_append_new_local_addr(msk, &addr_val, false); if (err < 0) { - GENL_SET_ERR_MSG(info, "did not match address and id"); + NL_SET_ERR_MSG_ATTR(info->extack, addr, + "did not match address and id"); goto announce_err; } @@ -354,9 +356,9 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) err = 0; out: if (err) - GENL_SET_ERR_MSG_FMT(info, - "address with id %u not found", - id_val); + NL_SET_ERR_MSG_ATTR_FMT(info->extack, id, + "address with id %u not found", + id_val); sock_put(sk); return err; @@ -388,7 +390,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) goto create_err; if (entry.flags & MPTCP_PM_ADDR_FLAG_SIGNAL) { - GENL_SET_ERR_MSG(info, "invalid addr flags"); + NL_SET_ERR_MSG_ATTR(info->extack, laddr, "invalid addr flags"); err = -EINVAL; goto create_err; } @@ -407,7 +409,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) err = mptcp_userspace_pm_append_new_local_addr(msk, &entry, false); if (err < 0) { - GENL_SET_ERR_MSG(info, "did not match address and id"); + NL_SET_ERR_MSG_ATTR(info->extack, laddr, + "did not match address and id"); goto create_err; } @@ -528,13 +531,13 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info } if (!addr_l.addr.port) { - GENL_SET_ERR_MSG(info, "missing local port"); + NL_SET_ERR_MSG_ATTR(info->extack, laddr, "missing local port"); err = -EINVAL; goto destroy_err; } if (!addr_r.port) { - GENL_SET_ERR_MSG(info, "missing remote port"); + NL_SET_ERR_MSG_ATTR(info->extack, raddr, "missing remote port"); err = -EINVAL; goto destroy_err; } @@ -588,7 +591,8 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) goto set_flags_err; if (loc.addr.family == AF_UNSPEC) { - GENL_SET_ERR_MSG(info, "invalid local address family"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, + "invalid local address family"); ret = -EINVAL; goto set_flags_err; } @@ -599,7 +603,8 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) goto set_flags_err; if (rem.addr.family == AF_UNSPEC) { - GENL_SET_ERR_MSG(info, "invalid remote address family"); + NL_SET_ERR_MSG_ATTR(info->extack, attr_rem, + "invalid remote address family"); ret = -EINVAL; goto set_flags_err; } @@ -722,7 +727,7 @@ int mptcp_userspace_pm_get_addr(struct sk_buff *skb, spin_lock_bh(&msk->pm.lock); entry = mptcp_userspace_pm_lookup_addr_by_id(msk, addr.addr.id); if (!entry) { - GENL_SET_ERR_MSG(info, "address not found"); + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); ret = -EINVAL; goto unlock_fail; } From patchwork Thu Jan 16 16:51: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: 13941996 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 164EF241A0F; Thu, 16 Jan 2025 16:54: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=1737046498; cv=none; b=m3lkzJT8xAnmYzKxMZ+dNPim3qIAO3AgVt8F9UAkRhGB/yMBZdezRmSa2RcRDu4OG1wx8HJ8fuegAlEdUeLb6WTFv5PjYz0IUDmwbmBXd0LT66qInIUQj1bkaH9nQhDECbSh0ATJpvwb3MwnOyBUI6NclL7Oc1tNnSuOAO3bMQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046498; c=relaxed/simple; bh=hMA76qbYEKp2YrrM197S/JumQHpn+bPtipoM/dTb2KU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sPUsBdsMHiG9sge+5Y2qiWxdpyRyyZF5VnvBapQssg9ar/uxVH+iBwn8CG0ujTuC4C1RldLdZBYXcCdSu9RVXXQcKOgPT3cl8eMI+P+5s7aTvajVCScgNUxuOciglVTu3RZo9D1ixCJPxtDOFgq81mC9H9bxA5hN0taApLk4BUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ILehBrD0; 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="ILehBrD0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8396C4CEEC; Thu, 16 Jan 2025 16:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046498; bh=hMA76qbYEKp2YrrM197S/JumQHpn+bPtipoM/dTb2KU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ILehBrD0f08vKTs0SO+W+zRda3ErsuyRGWOUagWw7nBNJRBgCnrjZglt9Kek6weEo +5UUwbLOITJm99NtT4qyxl4BmEouiUHI4wNc3xz1e1SRA/Af9nbGv54o316BBgwBHB /x+yj0itYOWc9td7MeX06ZOSqtIjylC+HYnLFv9Ph6xKXDCQtd3+e3ruloAX+9CcBy TAw0xHv/wjSqrtXkQcbSKngI1ZaVgxWBaeqB4zgh7KQSBD0K7KIWmYeMPjGWunOv3F OFxo217sDT5RgkXFMxGmvqvjcNdRnQlp1f/1we9nHUGM8OfPYChaW5SQShkCEuFbzC XVQBomi1YuSEA== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:31 +0100 Subject: [PATCH net-next 09/15] mptcp: pm: make three pm wrappers static Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-9-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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=plRm5q+b0IuVvggnzam7j8Wkrm7SvY5zh4+UeiXI36w=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnHwokGmQhH4ySZpNKO/S/jDkTu1mLcnSp4v KzI3beU5oeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xwAKCRD2t4JPQmmg c5yGEACjI/kzX55LgjEYHodfqIihWNpKPlgo8bx5zeYnOiVO8B59iuDU59QEWPwez1lciyYOnKI c5/anvz/i4HdzdtR4WkJyIlTjfh8RwOGg5W4Usf6dzfI1aRWVawBVHLBMcbe5KcwqaOz8JJY3Ao y671c577i1OQQZmpStubbpWlaEh6hWLAijFzwc0mSzcNSTukPKFGqoRl55AqlXYOE05UbB/Vy4c 9ehXZW+FD1hb77bhqF651kMKXPOtL0tp9Gfz68qHZZGkZ/rlPwffv3QGxTnv73pxS3AkhSss1gz O9ugIvaoxotcr4XMkUXlqj5D8XnPuknwBapi2zymoeXa9XAIEDSosz+CLja3RwBklsnn6PcbFEa XkYfEcSzPrBCbUgU3QBO3rlFZlcG0Eb+0oDYmHia2CUaQCVhjVxqo6uIU3Qtjqh/gFBp3ev27ES oPb944D58SKW5af0SeiR412vr9ADR/s856pjKjSNEylL0kb6dbrNbLPsKz7nZCOHMwffl0ZqUcg 2oRJm3S9NbsY8Q0DogrjBc12IURjYa6jgLl5gZQ9e0iZEh+ei1nUub2QZEIeODAGuKdBNy59T3k e+Wh38KJJIgSOToZEJ4dwe0yCo33Zg29LLyRBZ4hlvo1Qxmvg9e2Btlu9lGZBhfo0E350wkJhnd tkmkfzgwChhGWDQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang Three netlink functions: mptcp_pm_nl_get_addr_doit() mptcp_pm_nl_get_addr_dumpit() mptcp_pm_nl_set_flags_doit() are generic, implemented for each PM, in-kernel PM and userspace PM. It's clearer to move them from pm_netlink.c to pm.c. And the linked three path manager wrappers mptcp_pm_get_addr() mptcp_pm_dump_addr() mptcp_pm_set_flags() can be changed as static functions, no need to export them in protocol.h. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 23 ++++++++++++++++++++--- net/mptcp/pm_netlink.c | 16 ---------------- net/mptcp/protocol.h | 3 --- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 16c336c519403d0147c5a3ffe301d0238c5b250a..a29be5ff73a6b5ca8241a939f9a029bc39914374 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -10,6 +10,7 @@ #include "protocol.h" #include "mib.h" +#include "mptcp_pm_gen.h" /* path manager command handlers */ @@ -433,14 +434,19 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) return mptcp_pm_nl_is_backup(msk, &skc_local); } -int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) return mptcp_userspace_pm_get_addr(skb, info); return mptcp_pm_nl_get_addr(skb, info); } -int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) +int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) +{ + return mptcp_pm_get_addr(skb, info); +} + +static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) { const struct genl_info *info = genl_info_dump(cb); @@ -449,13 +455,24 @@ int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) return mptcp_pm_nl_dump_addr(msg, cb); } -int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, + struct netlink_callback *cb) +{ + return mptcp_pm_dump_addr(msg, cb); +} + +static int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) return mptcp_userspace_pm_set_flags(skb, info); return mptcp_pm_nl_set_flags(skb, info); } +int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) +{ + return mptcp_pm_set_flags(skb, info); +} + void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 04ab3328c785e804322dbe4fc56da85a58b8e0ea..460588833639e88c51a6e1f417bd4ba1a8039d47 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1827,11 +1827,6 @@ int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info) return ret; } -int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) -{ - return mptcp_pm_get_addr(skb, info); -} - int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) { @@ -1875,12 +1870,6 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, return msg->len; } -int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, - struct netlink_callback *cb) -{ - return mptcp_pm_dump_addr(msg, cb); -} - static int parse_limit(struct genl_info *info, int id, unsigned int *limit) { struct nlattr *attr = info->attrs[id]; @@ -2057,11 +2046,6 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) return 0; } -int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) -{ - return mptcp_pm_set_flags(skb, info); -} - static void mptcp_nl_mcast_send(struct net *net, struct sk_buff *nlskb, gfp_t gfp) { genlmsg_multicast_netns(&mptcp_genl_family, net, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index cd5132fe7d22096dbf6867510c10693d42255a82..98e7262c6b06f96b9c3a8a711e4bb755015c118d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1031,7 +1031,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, @@ -1124,12 +1123,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 Thu Jan 16 16:51: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: 13941997 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7AD5242247; Thu, 16 Jan 2025 16:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046500; cv=none; b=beOajpC4LmdoGx/1a4DFvZXSGeU6so3F4tYEYRN2FuVRNFOb4z2E2xxPL0Vqe+5Pq+fY2DGrsJ3Qj8tcrroxes27fkSIrGeVDOop7rXSowVitGVBHkJdpRBBwJTmjEXwgkMZ0vIO4D3xQ2E/cmDQyh77oz325pah+6kz53QoVRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046500; c=relaxed/simple; bh=uziRL227ApHOvwJzr8yQyxGJWOUBP26j3Jr3QhVI4Ms=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NqYcnlESyDQjR6vF8d6q3L4UW5OycwnEHKYuWP2AZ4hxtunwmpTnZDd7M8/FN+N4cpucHbhLYX9f0oTeP7YiN4yZfsZdA2FoB5aXpbrf5V5zzZGeCYMtJI103Z2+lkwkpcZ5rdAyDpaGytwvkDEnplQ19Wr/ke4NwudUUDId8Q8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WkyQ/NjR; 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="WkyQ/NjR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 677FCC4CEE4; Thu, 16 Jan 2025 16:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046500; bh=uziRL227ApHOvwJzr8yQyxGJWOUBP26j3Jr3QhVI4Ms=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WkyQ/NjRd/1faneUvfeVnYHrIslP+Y36U0JFc7keriQ25fBcYV55Wvi4R+55ncCZ8 R8fML0MIzvTs89CsVMFaRES/zPzDqKTuvLgu0CQuwEv/RKlEpsbYymglvCchkMURDA KkXS1dMUeUaWLeG3y6nXXxJ14e4vidmdO8+uAQPMOQw1xTJrJn3OMPoU7noRwd/Cgg ymFLVzMxhNCxc3/oZrlqwaIUeLx/Vwtlc/FI/hXHqjv7KK2qHKiZSAerTRVq+eE5il /Riwp2XFFt5TCcaU7ik3cW5Rjm1NRGXsAZg3jcu3BnGtcsKFbZ17whH8CQ5kyFlXWK rHWy+tpafFxAQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:32 +0100 Subject: [PATCH net-next 10/15] mptcp: pm: drop skb parameter of get_addr Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-10-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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=0rjmG/ewCiPTFRj22Er2jmFVpoiIpDJnsPfK53wI9zs=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnH4RqyP7JrwgW/nTJ4I+NZ9enWimctVARDE i1cOKBVM1mJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xwAKCRD2t4JPQmmg c4AAEAC/Iyu2qfKBq1n+qApfJxDWTMIO5ydbEcTQ5PvdYbQhGiMmeO6fSpZXFtKeawIZm502F4t 9UD21J4gGgG0/zbzvnD3TnZUtUFDrt1xmGN9GWc8cka5v7SPKpIrWm9BxaP6fxvIYIARs79rYs8 i+M6ncfSAdcjkpFcNdxB8kyal2FSz5fcBFDTZ2MR368wwhCyBmCCIDE/C/26sHFsTLqAA+Xyuk6 dWPwk10HbWIOub8Hejs4RERILz5F6lJBKI6MjXRiYUwaEzOF3JGWNejgE5TfBpryIDf+1C5WgZ3 WfI3lURwRbLPz2SnHQTqMqNqNIAOEqzPHuI7mjujjW69lTRR/FX0qXLCv88JUIeNdPjfNW74JHS 0ooj5OSyQsi3XV9Ry6zYgoTQE1baSbN5VmTtPwnjetZ+gxmcrugqvf2ILZGNcx1AO2yxhpBVTUS b5tskiAu4Usr9nZKoUhMW/H9VdFdGn8VlsLflkBNQMHE+cbGd7Bixzd0AlZzToy1eUUBLzFckRT nWZuCIX5/0qt9vleaoEpxqB/2886QRbrgt7/kLqYxIbI4zAqLUbwnaRdZhuZb5tPeUQ6AHkR1O+ d30WPG6NnhN4p1m46wvsqdWMvpNJLTnprMJP7duQO+EBt4zhMsvALoXR/54rC8C/b7avu0eZWkK 6Ken8+RQfVqWwwQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The first parameters 'skb' of get_addr() interfaces are now useless since mptcp_userspace_pm_get_sock() helper is used. This patch drops these useless parameters of them. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 8 ++++---- net/mptcp/pm_netlink.c | 2 +- net/mptcp/pm_userspace.c | 3 +-- net/mptcp/protocol.h | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index a29be5ff73a6b5ca8241a939f9a029bc39914374..526e5bca1fa1bb67acb8532ad8b8b819d2f5151c 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -434,16 +434,16 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) return mptcp_pm_nl_is_backup(msk, &skc_local); } -static int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_get_addr(struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_get_addr(skb, info); - return mptcp_pm_nl_get_addr(skb, info); + return mptcp_userspace_pm_get_addr(info); + return mptcp_pm_nl_get_addr(info); } int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { - return mptcp_pm_get_addr(skb, info); + return mptcp_pm_get_addr(info); } static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 460588833639e88c51a6e1f417bd4ba1a8039d47..853b1ea8680ae753fcb882d8b8f4486519798503 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1773,7 +1773,7 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } -int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_get_addr(struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 8dddb16247363a11ba11bcb94c4557dd0cfd8745..1246063598c8152eb908586dc2e3bcacaaba0a91 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -684,8 +684,7 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, return ret; } -int mptcp_userspace_pm_get_addr(struct sk_buff *skb, - struct genl_info *info) +int mptcp_userspace_pm_get_addr(struct genl_info *info) { struct mptcp_pm_addr_entry addr, *entry; struct mptcp_sock *msk; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 98e7262c6b06f96b9c3a8a711e4bb755015c118d..69f3909bef8fd163e701f27a003378cdea453805 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1127,9 +1127,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 Thu Jan 16 16:51: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: 13941998 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1F85243845; Thu, 16 Jan 2025 16:55: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=1737046503; cv=none; b=PcHh6NJgb+gA/KIfGEPfJA3a2Am3g9Yz1AGYGZFwNGrCy1l+ddFnvCQUCzOUe/TYnsCmF5PxRiOH1YHJ+Rb/xcJSo9zk+DBVffdBei5kWdXN+P+lmeKYx7rSHeLUJsdUJqE5wgD/PXkJw3aeWv1oG2Y5g6E2T9Flwk7Y6Q0pYHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046503; c=relaxed/simple; bh=YRpq9JV5Z5meenpglwSA1AZ13S9YzSV5/fyK+fdxSao=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z1pA8bS4McTl7UI4GrkoGqZWAe7rWnoz4Kqk12QShv2N0AU8cGb+APaN9nZBCQHjIclzUIYCWG3Uwu1NNMCPu9q5lMj/f8sVkkcyYz431IjmseZyUsCHRSZ4QVf4y57k1bqFDqmlnl4/QUJ+RIw0G4OdnL9O7YHBuYrIsopoJ1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IIaPWzyA; 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="IIaPWzyA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18408C4CEE1; Thu, 16 Jan 2025 16:55:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046503; bh=YRpq9JV5Z5meenpglwSA1AZ13S9YzSV5/fyK+fdxSao=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IIaPWzyANJD5eqauO6H5FjV+kS+B5te75+QYhEdzgjdjQyWb1nVWNj6bTCqFxE6dP Q/28uF/3la2f2tQ6arRJs0ZoNEdbAP/XJp8KDhy/SkSFcWuyNWYceCk9bmm5gVzb69 JL8Y4tQjtb1LPX4jx54sDZHcA+N9alf0A422KRXsI5ZnNl0KpmB8BJH3AOVpZpWGXp xrllgsfh0RjIa7VkTUmBgJ9auAQbxCxMmhRgO0tVrNAuSHan6IBTs8oOx1MuZe1VHL HcxK/Z/s21pic9vgN9bRjzMkUWSlFL2cryH81RNwsFpC9o3uKAwGnNEaah7GMlZUpU LWGSIroXKA9Xg== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:33 +0100 Subject: [PATCH net-next 11/15] mptcp: pm: add id parameter for get_addr Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-11-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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=5499; i=matttbe@kernel.org; h=from:subject:message-id; bh=lqHa0c+mmfmiUAzGpi4E8Vg0xmIpkoSJxe0Pjghhe4s=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnHxi/xZCSgV+WfgAibPf5UHE3RyMV16cfoO up4kbjRxySJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xwAKCRD2t4JPQmmg c563EACi1bnp1PR8jQujqv9/t6Nr4uWCU3q17T2+A54Bw3SZ6NaHZOvqsw2W/xZ0TOpsqF8IL3l BvhQb7rxyDOHBT9S2wxghQYrM3PGIkeIn7YjcVP6ecL2/nf3pUEYJj9AQgGosnSM4yA5zRc7wlN S1ZUGKSiolEAyL1OfIlkig5hSp5Wgqyccfi066sm0WD+ifHSuSqavIce2JX19hoa5ieBYrQXZD1 af3vni3+6sVL4EYh8Vw6EW2bttOs0NSuXXh5vFE9zJCBn3gX8WnEIm3uTurIBMHBg6MxOvOS/yl lJ2wqgZa8uxOcvahv0l23mnd672Equ7xCeOde+UwhTTPgalewzXg7bddvNwxf8MIUg3VMn12MNN cUhvGQQ2E9oiKuig/0lc/SyOVcSljZ2yanDCy+3atcGS8pgpaxUw0rapGdUK+QEfa7L3xNwdP1X 4S7IsvGLulWRglj2BmLTLwJwySjHEJ+lZh7ZP9aHpKb5F4mggewNgdbvtHd6cmnuVi6DYx1aLkP ATwnDyiGYHYousDrVK816VY6bZdWdSViNw/QQ/gRl2LgkUBKwjRoQao7OC8e15OgjsHHVRCInLA QRgcPXv82yyyX3nu9U3kCmataUZu+je9EQV/NCFG3JzMyP2x4crKaCGSSdAKgzIWKst4LAmenwL JznyH8utnsF6fNw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The address id is parsed both in mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive. So this patch adds a new parameter 'id' for all get_addr() interfaces. The address id is only parsed in mptcp_pm_nl_get_addr_doit(), then pass it to both mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 20 ++++++++++++++++---- net/mptcp/pm_netlink.c | 14 +++----------- net/mptcp/pm_userspace.c | 14 +++----------- net/mptcp/protocol.h | 4 ++-- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 526e5bca1fa1bb67acb8532ad8b8b819d2f5151c..caf5bfc3cd1ddeb22799c28dec3d19b30467b169 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -434,16 +434,28 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) return mptcp_pm_nl_is_backup(msk, &skc_local); } -static int mptcp_pm_get_addr(struct genl_info *info) +static int mptcp_pm_get_addr(u8 id, struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_get_addr(info); - return mptcp_pm_nl_get_addr(info); + return mptcp_userspace_pm_get_addr(id, info); + return mptcp_pm_nl_get_addr(id, info); } int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { - return mptcp_pm_get_addr(info); + struct mptcp_pm_addr_entry addr; + struct nlattr *attr; + int ret; + + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) + return -EINVAL; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; + ret = mptcp_pm_parse_entry(attr, info, false, &addr); + if (ret < 0) + return ret; + + return mptcp_pm_get_addr(addr.addr.id, info); } static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 853b1ea8680ae753fcb882d8b8f4486519798503..392f91dd21b4ce07efb5f44c701f2261afcdc37e 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 pm_nl_pernet *pernet = genl_info_pm_nl(info); - struct mptcp_pm_addr_entry addr, *entry; + struct mptcp_pm_addr_entry *entry; struct sk_buff *msg; struct nlattr *attr; void *reply; int ret; - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) - return -EINVAL; - - attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; - ret = mptcp_pm_parse_entry(attr, info, false, &addr); - if (ret < 0) - return ret; - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!msg) return -ENOMEM; @@ -1803,7 +1795,7 @@ int mptcp_pm_nl_get_addr(struct genl_info *info) } rcu_read_lock(); - entry = __lookup_addr_by_id(pernet, addr.addr.id); + entry = __lookup_addr_by_id(pernet, id); if (!entry) { NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); ret = -EINVAL; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 1246063598c8152eb908586dc2e3bcacaaba0a91..79e2d12e088805ff3f59ecf41f5092df9823c1b4 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -684,9 +684,9 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, return ret; } -int mptcp_userspace_pm_get_addr(struct genl_info *info) +int mptcp_userspace_pm_get_addr(u8 id, struct genl_info *info) { - struct mptcp_pm_addr_entry addr, *entry; + struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; struct sk_buff *msg; struct nlattr *attr; @@ -694,20 +694,12 @@ int mptcp_userspace_pm_get_addr(struct genl_info *info) struct sock *sk; void *reply; - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) - return ret; - msk = mptcp_userspace_pm_get_sock(info); if (!msk) return ret; sk = (struct sock *)msk; - attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; - ret = mptcp_pm_parse_entry(attr, info, false, &addr); - if (ret < 0) - goto out; - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!msg) { ret = -ENOMEM; @@ -724,7 +716,7 @@ int mptcp_userspace_pm_get_addr(struct genl_info *info) lock_sock(sk); spin_lock_bh(&msk->pm.lock); - entry = mptcp_userspace_pm_lookup_addr_by_id(msk, addr.addr.id); + entry = mptcp_userspace_pm_lookup_addr_by_id(msk, id); if (!entry) { NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); ret = -EINVAL; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 69f3909bef8fd163e701f27a003378cdea453805..f209b40d08f372528b2294f3494ccf2d6bbb43e1 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1127,8 +1127,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 Thu Jan 16 16:51:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13941999 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7816A24386A; Thu, 16 Jan 2025 16:55: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=1737046506; cv=none; b=lAwvkFoIbgtnxvf8TRqdJJ7URmNz1TOvHODSkXZm6+zkIG7pMrO6Y2HjDU2XxIl/S8fOoeXzj72kXMl45yUCb9V4PBvDkeXYFYz5t7zwmBwNQfcRYKqWoOor91xEaAiuH8J6D7u6fGxLsoG/rMzkQzzgNMCOWwZgGRLDoNaBmu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046506; c=relaxed/simple; bh=PbVfnDei8esycz4yY+Dbr+xfdio/vutAk4LjcJsrUyQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IBh3BCgA4L14fsM7jXyswMFMBs4C+1NkCaxlYfoTzHoWo+/suWJbkPmY/LRWpJg3pxxjfohqCOt9hiDvPdjXaNaXxj8x+o/Aj4tQA/BLkk0TLM6sd+/lgZ6e0FH5gxsaj2AXKktfjNi62XXXjY4McaAfrzTprfkPiXTNv7UGLFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cD9iM/32; 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="cD9iM/32" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD54AC4CEE2; Thu, 16 Jan 2025 16:55:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046506; bh=PbVfnDei8esycz4yY+Dbr+xfdio/vutAk4LjcJsrUyQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cD9iM/324i0kwWnvOE8N4cyr7fUnRdMlhTK20Zv5xIqAlpSK4Qd0LbsHK8ghEpMkA q/m+PciMIdZsMRpX0OA8DnyrjydRMysvp5jE/RZNZCK1qjYlKKtaf9IUkLQMmqn5T+ d12Q5y0zJvN4En34zvVkIlG1VlQ/NEAABAXkqoicP/rnJkDiALMU9RN1dVXu3d/MB5 C9ijnNcyEohVC+luA8qxPFK8nwnVjtZgB4a/08MVSsjEYx74MQR+gsyYYuG5waQ+lk 46z5UqWD6y78h0eriJK8g8FrFNs0TZfBsEOwogfzDEq1m0S/KpDs6ci5xj+3DUqOal ZvhWZHvaJwSeQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:34 +0100 Subject: [PATCH net-next 12/15] mptcp: pm: reuse sending nlmsg code in get_addr Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-12-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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=7747; i=matttbe@kernel.org; h=from:subject:message-id; bh=hlcuc1ckPIlJFVnOveNkkX2nqEb/VHMmICaJVO+RQ50=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnHEoPn6sBN+nGu/LjgGajMHdxJdN/O0+53L 3U+IuBHtnqJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xwAKCRD2t4JPQmmg c+5fD/9mYI2JFwUjSNpv/kAVSLpHqwQcyV5x9jDD/p+EvDgGlpJQA11Ucu+5+H/oSlPbe0m2eOe KaH0mSwOLTfjUL4ke6Yeb44zEQA+bA44HEO8mq2kzl5Q3HGEGcTIq/GxGivn80lHpOBGWmkVDIN lJTEEFckf/dJfwM4iFfz/aiGOA9jQij1fxOmGnaaB9jQwi21MKuOVaN9SD0i9QHGHuHRgdNyMba LJkKmW/PK2JmCAHp4bM8DW4YyS6v7pIwksSqap8NAT1Vm7esc7ORthWVj87JpWVXB2JHUjT6Ko+ lPm8exK4Uil+zVCkIepPKiCKRfvajRh0ZM6iEraEOZYY1kGRhIv5rLklS5BvFh4lYcDSFQ6HHGF mUYA3V3Vb8tA1FW+KX210AsTyysIpjmTPn6s181c4cqJYHZJbEKpTHcYkS+ESFDTJUCjpo7b4qJ KC9qXSZFk4mbxtA6WGY/ZFs/OKott+6a2vrSHV0DCwxFwykFTtV8ph8BkYmibvLd4jcdK+2xyWa 64khjTzFe2d2vRWmibLPXgzBYlWsTTJCw8liFKbaqz65t01V4/IC5qlsCaZm3+Im9kJQ9wC0sIf vjQ51kh0vgg+wjp5gdYBOWhM20IBHx9onfLrzMsUResajtyewpDg6CZ9LPI6I2k1eHqxgxxdHeg SIXTjsbRs4P+5BQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The netlink messages are sent both in mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive. This is because the netlink PM and userspace PM use different locks to protect the address entry that needs to be sent via the netlink message. The former uses rcu read lock, and the latter uses msk->pm.lock. The current get_addr() flow looks like this: lock(); entry = get_entry(); send_nlmsg(entry); unlock(); After holding the lock, get the entry from the list, send the entry, and finally release the lock. This patch changes the process by getting the entry while holding the lock, then making a copy of the entry so that the lock can be released. Finally, the copy of the entry is sent without locking: lock(); entry = get_entry(); *copy = *entry; unlock(); send_nlmsg(copy); This way we can reuse the send_nlmsg() code in get_addr() interfaces between the netlink PM and userspace PM. They only need to implement their own get_addr() interfaces to hold the different locks, get the entry from the different lists, then release the locks. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 39 +++++++++++++++++++++++++++++++++++---- net/mptcp/pm_netlink.c | 40 ++++++---------------------------------- net/mptcp/pm_userspace.c | 42 +++++------------------------------------- net/mptcp/protocol.h | 6 ++++-- 4 files changed, 50 insertions(+), 77 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index caf5bfc3cd1ddeb22799c28dec3d19b30467b169..ba22d17c145186476c984d1eb27b102af986a0cd 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -434,17 +434,20 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) return mptcp_pm_nl_is_backup(msk, &skc_local); } -static int mptcp_pm_get_addr(u8 id, struct genl_info *info) +static int mptcp_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, + struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_get_addr(id, info); - return mptcp_pm_nl_get_addr(id, info); + return mptcp_userspace_pm_get_addr(id, addr, info); + return mptcp_pm_nl_get_addr(id, addr, info); } int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry addr; struct nlattr *attr; + struct sk_buff *msg; + void *reply; int ret; if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) @@ -455,7 +458,35 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) if (ret < 0) return ret; - return mptcp_pm_get_addr(addr.addr.id, info); + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!msg) + return -ENOMEM; + + reply = genlmsg_put_reply(msg, info, &mptcp_genl_family, 0, + info->genlhdr->cmd); + if (!reply) { + GENL_SET_ERR_MSG(info, "not enough space in Netlink message"); + ret = -EMSGSIZE; + goto fail; + } + + ret = mptcp_pm_get_addr(addr.addr.id, &addr, info); + if (ret) { + NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); + goto fail; + } + + ret = mptcp_nl_fill_addr(msg, &addr); + if (ret) + goto fail; + + genlmsg_end(msg, reply); + ret = genlmsg_reply(msg, info); + return ret; + +fail: + nlmsg_free(msg); + return ret; } static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 392f91dd21b4ce07efb5f44c701f2261afcdc37e..d86887004781e9020061394c350e4710b68cc22f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1773,49 +1773,21 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } -int mptcp_pm_nl_get_addr(u8 id, struct genl_info *info) +int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, + struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry *entry; - struct sk_buff *msg; - struct nlattr *attr; - void *reply; - int ret; - - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); - if (!msg) - return -ENOMEM; - - reply = genlmsg_put_reply(msg, info, &mptcp_genl_family, 0, - info->genlhdr->cmd); - if (!reply) { - GENL_SET_ERR_MSG(info, "not enough space in Netlink message"); - ret = -EMSGSIZE; - goto fail; - } + int ret = -EINVAL; rcu_read_lock(); entry = __lookup_addr_by_id(pernet, id); - if (!entry) { - NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); - ret = -EINVAL; - goto unlock_fail; + if (entry) { + *addr = *entry; + ret = 0; } - - ret = mptcp_nl_fill_addr(msg, entry); - if (ret) - goto unlock_fail; - - genlmsg_end(msg, reply); - ret = genlmsg_reply(msg, info); - rcu_read_unlock(); - return ret; - -unlock_fail: rcu_read_unlock(); -fail: - nlmsg_free(msg); return ret; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 79e2d12e088805ff3f59ecf41f5092df9823c1b4..80d75df18b039dc60ca5c4432da44a1a9dbf33f1 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -684,15 +684,13 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, return ret; } -int mptcp_userspace_pm_get_addr(u8 id, struct genl_info *info) +int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, + struct genl_info *info) { struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; - struct sk_buff *msg; - struct nlattr *attr; int ret = -EINVAL; struct sock *sk; - void *reply; msk = mptcp_userspace_pm_get_sock(info); if (!msk) @@ -700,46 +698,16 @@ int mptcp_userspace_pm_get_addr(u8 id, struct genl_info *info) sk = (struct sock *)msk; - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); - if (!msg) { - ret = -ENOMEM; - goto out; - } - - reply = genlmsg_put_reply(msg, info, &mptcp_genl_family, 0, - info->genlhdr->cmd); - if (!reply) { - GENL_SET_ERR_MSG(info, "not enough space in Netlink message"); - ret = -EMSGSIZE; - goto fail; - } - lock_sock(sk); spin_lock_bh(&msk->pm.lock); entry = mptcp_userspace_pm_lookup_addr_by_id(msk, id); - if (!entry) { - NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); - ret = -EINVAL; - goto unlock_fail; + if (entry) { + *addr = *entry; + ret = 0; } - - ret = mptcp_nl_fill_addr(msg, entry); - if (ret) - goto unlock_fail; - - genlmsg_end(msg, reply); - ret = genlmsg_reply(msg, info); spin_unlock_bh(&msk->pm.lock); release_sock(sk); - sock_put(sk); - return ret; -unlock_fail: - spin_unlock_bh(&msk->pm.lock); - release_sock(sk); -fail: - nlmsg_free(msg); -out: sock_put(sk); return ret; } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f209b40d08f372528b2294f3494ccf2d6bbb43e1..fe9bd483d6a067a3cacedea1e893e54fd2e1198b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1127,8 +1127,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 Thu Jan 16 16:51:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13942000 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 235D322F3B4; Thu, 16 Jan 2025 16:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046509; cv=none; b=GY8lb76sFgWsIyWX3StYXAHQv/LUbI+Lzf22s1iKpGM14yrlVsRKCO//KAy7YW7okVRtq2FJMB5P36UAuCr4jb57Ld6pwQZ5GszpejtAEwkwBtd0pACUsLiunl7NxmyDCWjWbhE+Qnpr3hwJgdkYaO6UxBtBqHcO3nJ8yZI2gcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046509; c=relaxed/simple; bh=azzLGjkOMMtjDQfHIDEH+JfvDf0FZrM8sjh+w3zlu4M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZpY5IRE07iFiZT3NZxvatlyRxziJZ8i3khbJYI8a7B8NY+OA6B4tWdqzwK2rmZAnyF3/lpQuaoF996zhCkbEuqsbLqQVB4MgDx8U4E5eK91xwjC3NEssyASEHahoQIQDyjsx7Z81iY0zcLmWYqvTK6+nis13upKeKhD215+Kk4s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dKnzwuuo; 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="dKnzwuuo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F470C4CEE3; Thu, 16 Jan 2025 16:55:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046508; bh=azzLGjkOMMtjDQfHIDEH+JfvDf0FZrM8sjh+w3zlu4M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dKnzwuuoQ1lLDyaC74NZad0neZvPEqJgflPrLPVywFMpsHYO38wstjeO58tzcU2yZ h9GaXSJcKiWxDnLxQ/fdYbD/RXha+8/cINpXhB5XGk1k1UHvA7SqguZEpnve/+Sf7O OuxBCibD21nhHyAaC7SwW8YdOxuXz/VGcmKH6ajwavSgM5uif4vhrWVH4q4kcW+w4q ZCn95k8bicdpKLXpGbCMrotB0GcDUt7uYbyKVRzbUvC9VAlf7IZMgUYr4VxfibVXwf jYyl590+T9tBXkqM4+NxN3tk+uH6TRdvurw0EY5ivx+XXyd2z9H44k4lO/wQf8IQ2j v8zKTTmX2deNg== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:35 +0100 Subject: [PATCH net-next 13/15] mptcp: pm: drop skb parameter of set_flags Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-13-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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=9pQkBEF2OOPtg9lKl0P9077iQB3N9mUy5uuj/vFpIPk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnHE7e3nRdcEMIPaT0fBdeGgeQTXwbnryrWp yTCPEQiDBOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xwAKCRD2t4JPQmmg c3RXD/9+e17HtpSyi2Pq9/PNM/W+3+J7ZzI2D25RE6FYpl1xxKvqHKYF5Wxc6V9x5DVAIBKYxlv BNz9s6RU0Hpe0efgtVRluzSzNIs0Kn2RXRPMQP0YnjyG5W6sDOkug7VZFfO346bEBqGUoAE5OHt FmP2vxQZ2lTw+L4xr7TBIuZPn0iHrShvP6+TarGIsf0yp2FyUFvaUKG557H+7XVAVDSehjxNA9V NigpibWz7bHDNQ4K7OA5Cfss5y3O/cL4n2jB1zjzX8tAK6gYH0duXFdlidFqruWtOHkVfWGz4Op psh+UQa3RFccVZj86RiS77t3OCk1NNLG3zqAb7Wx92Nb48sT2PvwCbGxfVsESp/wiuJMU4+FZzb svtZGt+bgv2UF9tcTRaureQo+A9PwANMzuIBuz2CeescedK4YtPeLxyWFflu9gIt0TYOKlXMrZw 8e5r5mMXiDlnQYPOTWw6muAxeljkEbwqP5G89JKiU9EeF9OnykGnkfwM3w8t/vNOCPykNg4cu5Z CNpC+M1ToXjweBkkqeKjownyJOsYCLkGaNDT6tG57C4ZD528HsiiWmzy/jyr6FKY7qjBu5RYvpd vo+o8UdP1Nm+zBApmoXStatPsklOADwdGj7sxWZbPE+jtT/NOB8xRBnkhVjLkiYQnjXCMQ0ppmF SoF0lnCMhG4Nrng== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang The first parameter 'skb' in mptcp_pm_nl_set_flags() is only used to obtained the network namespace, which can also be obtained through the second parameters 'info' by using genl_info_net() helper. This patch drops these useless parameters 'skb' in all three set_flags() interfaces. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 8 ++++---- net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index ba22d17c145186476c984d1eb27b102af986a0cd..c213f06bc70234ad3cb84d43971f6eb4aa6ff429 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -504,16 +504,16 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, return mptcp_pm_dump_addr(msg, cb); } -static int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_set_flags(struct genl_info *info) { if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_set_flags(skb, info); - return mptcp_pm_nl_set_flags(skb, info); + return mptcp_userspace_pm_set_flags(info); + return mptcp_pm_nl_set_flags(info); } int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) { - return mptcp_pm_set_flags(skb, info); + return mptcp_pm_set_flags(info); } void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d86887004781e9020061394c350e4710b68cc22f..c2101f7ca31e648aa72ff0890ba3a0801c1bf674 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1951,12 +1951,12 @@ static int mptcp_nl_set_flags(struct net *net, return ret; } -int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_set_flags(struct genl_info *info) { struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP | MPTCP_PM_ADDR_FLAG_FULLMESH; - struct net *net = sock_net(skb->sk); + struct net *net = genl_info_net(info); struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; struct nlattr *attr; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 80d75df18b039dc60ca5c4432da44a1a9dbf33f1..4fa3935c5b477dcb50260b3a041b987d5d83b9f0 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -564,7 +564,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info return err; } -int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) +int mptcp_userspace_pm_set_flags(struct genl_info *info) { struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; struct mptcp_pm_addr_entry rem = { .addr = { .family = AF_UNSPEC }, }; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index fe9bd483d6a067a3cacedea1e893e54fd2e1198b..1ac531fb2c70b7b5c7487e3f5aa5313c5e01aa37 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1031,8 +1031,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 Thu Jan 16 16:51:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13942001 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71D5D244F81; Thu, 16 Jan 2025 16:55:11 +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=1737046511; cv=none; b=tpWcSRDWqblKEOYTmbw72B7knQg4eVMaZa5kvzCoimy0pQpdR9euAGHzmyEmdXjITp4ErYxfYT1HHSCaIdvvT+aKMfm3ARdm35hqGxXVw/AKz1i1c6xiy2bbdTQb1OK0ufojko1O9YU5zWO4dQw73Ydzsg4/G7AV1NwIf0wY7vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046511; c=relaxed/simple; bh=gBNXX9ppG946EXfwDDL/S6hzfb1PJK8Xt2CCfsMNeRs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YTSG0g1KeECqYwgyNmOwc+5alThrtl4X7nzL+IrgFAkyAD58R3QOgesTwFQLMmPVd3+6WI8PtGSjpF8ShTEDGRxEDzz8wrRxgZnF3KvLAi56yPZ8SKWV43q9zsFrjFiheB2lfXiHFtC9ucZi2XmseHIKghHRZKT1SfWpfzc5EVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GY3SF4nR; 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="GY3SF4nR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E347C4CED6; Thu, 16 Jan 2025 16:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046511; bh=gBNXX9ppG946EXfwDDL/S6hzfb1PJK8Xt2CCfsMNeRs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GY3SF4nRAaQoCrhdZJdCtmQoRgvUvgDIExB3fS2syIbRA/tWsNjmy4iOplHrVrom3 s02s8KN32kN4vJtDVlEUAFpyzcqUtH47cTdbDfE0TND6u3O2GKx0a1mm4QnGs1oqvL F7Cm7413thEjnjBn5lJIggM+ZeZ6eYYd0sdJSdL1pY6WhA0Agn8GH3941uLhnwU9Ys XNddZN4c2+UXORxjjIx19vr4UGTIU9g3gkANZiU1VnV+JiMqHp0vhkuta1JkpmTZTi pt0w9v8D8upcG63BJOJyLmTaIT8yKuficBSGfRTlYZfR5oDY/uEkAJ3DSN/bEcq38t adNia9Q6qqVDg== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:36 +0100 Subject: [PATCH net-next 14/15] mptcp: pm: change rem type of set_flags Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-14-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@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/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnHSjysYDrQAoRYgqp+2ChhXg62V7R3EQbUH PsoVsRQ7IGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xwAKCRD2t4JPQmmg c7CHD/9VsOHKqR7735lpKiBhUId9f4FpLwDNeaTHAdt4lGFVKD0Ehi9e/3q8/h9Wsx0BbXUk7sy rSev7iaD1r3uv80JBJv4X4nUr5SP/vypgJS80m7UQkklFI7mMoUkTxU4CNuaGFJ3jFzQLaG1IVv fqf6dEkWHsKn/4VIBzS6n1NIdzQTRSQmmI9C8xwMRhzpVGRX+VW3bCgu+pi4B/uc0AKKY9vDMD8 gc3k4bY84aoVz2pbEeFLkvfByphwbF/+qdU+rfkYRWOAOeVbfTKLpvK04Fcw+0SG6rK/lMBVTg7 EsNHANTRc+WmiIWGub1P9WKTpCFKpqVY7X7je0OGHIkQ0lJZOL2amcc1vWn1tXtWSYxQfCcOrhR mycoV2VYxCfToJe2S5fVLfuXyrJpGCPH2Z/mC1MP6x1VGha8YHS/LQegvlWWuu0XGjvVqYM6FEA LgihIe5MbmDOCjSbKMpL6Zq9dFnkhvfqI6FccreAOBvRU/h0KD8fD4HdOMQcxmFduxyV31UvWVy vekwO763lwSwqGs+yDnqmGMONn+w41Gjpga7jGMbBZ5Js+R+E8erGxI8KMVKbxwxZFg65lXSJOj p545cRMXwkjmstaf6AGRmqk3Tfj8+4Twd6CQFIqqcXuAOC6G4Jkjv7Lh263IOagjZBTAYrImSsv V/GCXEXKsEVCpIw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang Generally, in the path manager interfaces, the local address is defined as an mptcp_pm_addr_entry type address, while the remote address is defined as an mptcp_addr_info type one: (struct mptcp_pm_addr_entry *local, struct mptcp_addr_info *remote) But the set_flags() interface uses two mptcp_pm_addr_entry type parameters. This patch changes the second one to mptcp_addr_info type and use helper mptcp_pm_parse_addr() to parse it instead of using mptcp_pm_parse_entry(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 4fa3935c5b477dcb50260b3a041b987d5d83b9f0..1af70828c03c21d03a25f3747132014dcdc5c0e8 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -567,7 +567,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info int mptcp_userspace_pm_set_flags(struct genl_info *info) { struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; - struct mptcp_pm_addr_entry rem = { .addr = { .family = AF_UNSPEC }, }; + struct mptcp_addr_info rem = { .family = AF_UNSPEC, }; struct mptcp_pm_addr_entry *entry; struct nlattr *attr, *attr_rem; struct mptcp_sock *msk; @@ -598,11 +598,11 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) } attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; - ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem); + ret = mptcp_pm_parse_addr(attr_rem, info, &rem); if (ret < 0) goto set_flags_err; - if (rem.addr.family == AF_UNSPEC) { + if (rem.family == AF_UNSPEC) { NL_SET_ERR_MSG_ATTR(info->extack, attr_rem, "invalid remote address family"); ret = -EINVAL; @@ -623,7 +623,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) spin_unlock_bh(&msk->pm.lock); lock_sock(sk); - ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup); + ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem, bkup); release_sock(sk); /* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */ From patchwork Thu Jan 16 16:51:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13942002 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A38A244FBF; Thu, 16 Jan 2025 16:55:14 +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=1737046514; cv=none; b=uARAydlFtEikKZTIO2pquL3EvGqjEOxBbwFA7E2RdJ5ETuHp9hW4zBuuB8qCptcepcm8gr0h3vOCQuSomuTiR0ZnsH0mp/8yJ2l+NQiHZskHWtE7QF6ip4sxqt4n5JSgtnG7R2f1Y6o9i7qjqt79814GsuXVAPW/LIw0C3NWcG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737046514; c=relaxed/simple; bh=qpx/nK/kNfYWU2WE0IRnrCNR49g6pC5ohkkPOmplINc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XhaEfEWTiZVlCPu/zNEIoxT8qWeu7qaIJICCWP5Y12Rt/V05CltJLVnk3jXHruHwM5x41JM8v7KbIq7JAgyfbI24Yy7e9RYAwChqJMv2D75q288uT44smjFmTR7aIQN9ytCZRCholer1zzBteTp8/bXEH2NtgUso2n9pGVSoQKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nHQJGdOE; 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="nHQJGdOE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1F6CC4CEE2; Thu, 16 Jan 2025 16:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737046514; bh=qpx/nK/kNfYWU2WE0IRnrCNR49g6pC5ohkkPOmplINc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nHQJGdOEGSVEEHhi717mXTMu62ceHjcPpK27ua/wywsKv2NQuugyXAwrXpkjquy+1 cY1jWB7AQb4X73w82JSrsf2z4OlyI7BBMlZt+ORJTCZBIAvSVdqpPQfEC7XDW4MDdF Q3bSp2eWJzwEq1MelGYLgjTYbTUG9ZIq6/b5Bt+D+opRh9naShhaOzQnfNBGxirFd4 r0GcFTl1hY0MlCauu6fbYgnP4PYc9GzyEmJBpCy3Kx3mP5z+TuUHoyAG00RUQrpskV fkqN4F5SUDRA7SDasOQ/N3uQVcIwpOwK4ZsvGKktddmSbRbyMfNuiynJTVmejIED+N 6Oiy6KKmeeJZQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 16 Jan 2025 17:51:37 +0100 Subject: [PATCH net-next 15/15] mptcp: pm: add local parameter for set_flags Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-15-c0b43f18fe06@kernel.org> References: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> In-Reply-To: <20250116-net-next-mptcp-pm-misc-cleanup-2-v1-0-c0b43f18fe06@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7567; i=matttbe@kernel.org; h=from:subject:message-id; bh=86fR+WPYPbsLnT25WiPo1DWMfkniQLE3jYOhbnPN5Dk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBniTnHxdeTowXg3HNuwF5lfWLUBeRK8dGX+XOfb 7TGfL9c1qeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4k5xwAKCRD2t4JPQmmg c+2JEACrnKd34lRZ8nqLX8MCexaFT8Zu0j6XTB8Y0ICjEHb2makWJNdvfftnGJjJHBbbrnA0F3Q 9YSsTLubz2N7ksG2g0D117UjqrmrdMzeOY3NrOF6isjWZcAZfijKo/iku77zxXnYAMtCraHpipd xSkn7zG90c6lZ1DKIyNXwZVSTHuAhVfPycS4wX90k53nvNOIGFoR7IrYXFLaPEVJz9XXHBDs5er rTVShDyxffOtJRcC5BvFPi2cWJLDQhyiRnRNqWNb2CJ4kPXl6lUuaKVMpclc2KzpjSXruB0L+2t eGFcA1UKISmRAM4ri1KhXdnoJvgrYvnGCeOOlGpR/jW9rE9iW2CfUAUTZbhH1tPRYLNCDKkuD4i 5v23/MzpFP8PzMk/jaarQ+8rOFGltzUjh+Ljqpsrn2jKoJOFsqBPREdBSeuyJ6uAaslYcmwPWPV XVKgr3yQRcCYfpW9Ky+3/Ht7BiyPt2kta5vn/Yuw/AjEOfvf7W4b8ZhxFBqnqT9q5P9GBnl6CKf DEm8+TekKB9zgCknAfaSGaIrMPdy6VqTGas6fwuC+pHIko0E9ns4mdDwptzxg4pbtcU3y8TcQad /zK6EOZDJYgLDVUnbVkU0rh7wfsA3/0IbPuImRk2Ie6cSng91Kzhw55QnwMSn8IDs2ghG6Xvemy 59VVCMuV629DQHw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Geliang Tang This patch updates the interfaces set_flags to reduce repetitive code, adds a new parameter 'local' for them. The local address is parsed in public helper mptcp_pm_nl_set_flags_doit(), then pass it to mptcp_pm_nl_set_flags() and mptcp_userspace_pm_set_flags(). Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 16 ++++++++++++++-- net/mptcp/pm_netlink.c | 35 +++++++++++++---------------------- net/mptcp/pm_userspace.c | 19 +++++++------------ net/mptcp/protocol.h | 6 ++++-- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index c213f06bc70234ad3cb84d43971f6eb4aa6ff429..b1f36dc1a09113594324ef0547093a5447664181 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -506,9 +506,21 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, static int mptcp_pm_set_flags(struct genl_info *info) { + struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; + struct nlattr *attr_loc; + int ret = -EINVAL; + + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)) + return ret; + + attr_loc = info->attrs[MPTCP_PM_ATTR_ADDR]; + ret = mptcp_pm_parse_entry(attr_loc, info, false, &loc); + if (ret < 0) + return ret; + if (info->attrs[MPTCP_PM_ATTR_TOKEN]) - return mptcp_userspace_pm_set_flags(info); - return mptcp_pm_nl_set_flags(info); + return mptcp_userspace_pm_set_flags(&loc, info); + return mptcp_pm_nl_set_flags(&loc, info); } int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index c2101f7ca31e648aa72ff0890ba3a0801c1bf674..fef01692eaed404e272359df691264f797240d10 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1951,62 +1951,53 @@ static int mptcp_nl_set_flags(struct net *net, return ret; } -int mptcp_pm_nl_set_flags(struct genl_info *info) +int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local, + struct genl_info *info) { - struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; + struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP | MPTCP_PM_ADDR_FLAG_FULLMESH; struct net *net = genl_info_net(info); struct mptcp_pm_addr_entry *entry; struct pm_nl_pernet *pernet; - struct nlattr *attr; u8 lookup_by_id = 0; u8 bkup = 0; - int ret; - - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR)) - return -EINVAL; pernet = pm_nl_get_pernet(net); - attr = info->attrs[MPTCP_PM_ATTR_ADDR]; - ret = mptcp_pm_parse_entry(attr, info, false, &addr); - if (ret < 0) - return ret; - - if (addr.addr.family == AF_UNSPEC) { + if (local->addr.family == AF_UNSPEC) { lookup_by_id = 1; - if (!addr.addr.id) { + if (!local->addr.id) { NL_SET_ERR_MSG_ATTR(info->extack, attr, "missing address ID"); return -EOPNOTSUPP; } } - if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) + if (local->flags & MPTCP_PM_ADDR_FLAG_BACKUP) bkup = 1; spin_lock_bh(&pernet->lock); - entry = lookup_by_id ? __lookup_addr_by_id(pernet, addr.addr.id) : - __lookup_addr(pernet, &addr.addr); + entry = lookup_by_id ? __lookup_addr_by_id(pernet, local->addr.id) : + __lookup_addr(pernet, &local->addr); if (!entry) { spin_unlock_bh(&pernet->lock); NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found"); return -EINVAL; } - if ((addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && + if ((local->flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { spin_unlock_bh(&pernet->lock); NL_SET_ERR_MSG_ATTR(info->extack, attr, "invalid addr flags"); return -EINVAL; } - changed = (addr.flags ^ entry->flags) & mask; - entry->flags = (entry->flags & ~mask) | (addr.flags & mask); - addr = *entry; + changed = (local->flags ^ entry->flags) & mask; + entry->flags = (entry->flags & ~mask) | (local->flags & mask); + *local = *entry; spin_unlock_bh(&pernet->lock); - mptcp_nl_set_flags(net, &addr.addr, bkup, changed); + mptcp_nl_set_flags(net, &local->addr, bkup, changed); return 0; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 1af70828c03c21d03a25f3747132014dcdc5c0e8..277cf092a87042a85623470237a8ef24d29e65e6 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -564,9 +564,9 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info return err; } -int mptcp_userspace_pm_set_flags(struct genl_info *info) +int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local, + struct genl_info *info) { - struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, }; struct mptcp_addr_info rem = { .family = AF_UNSPEC, }; struct mptcp_pm_addr_entry *entry; struct nlattr *attr, *attr_rem; @@ -575,8 +575,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) struct sock *sk; u8 bkup = 0; - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR) || - GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) + if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE)) return ret; msk = mptcp_userspace_pm_get_sock(info); @@ -586,11 +585,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) sk = (struct sock *)msk; attr = info->attrs[MPTCP_PM_ATTR_ADDR]; - ret = mptcp_pm_parse_entry(attr, info, false, &loc); - if (ret < 0) - goto set_flags_err; - - if (loc.addr.family == AF_UNSPEC) { + if (local->addr.family == AF_UNSPEC) { NL_SET_ERR_MSG_ATTR(info->extack, attr, "invalid local address family"); ret = -EINVAL; @@ -609,11 +604,11 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) goto set_flags_err; } - if (loc.flags & MPTCP_PM_ADDR_FLAG_BACKUP) + if (local->flags & MPTCP_PM_ADDR_FLAG_BACKUP) bkup = 1; spin_lock_bh(&msk->pm.lock); - entry = mptcp_userspace_pm_lookup_addr(msk, &loc.addr); + entry = mptcp_userspace_pm_lookup_addr(msk, &local->addr); if (entry) { if (bkup) entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP; @@ -623,7 +618,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) spin_unlock_bh(&msk->pm.lock); lock_sock(sk); - ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem, bkup); + ret = mptcp_pm_nl_mp_prio_send_ack(msk, &local->addr, &rem, bkup); release_sock(sk); /* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */ diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 1ac531fb2c70b7b5c7487e3f5aa5313c5e01aa37..a80bb6ef5c5469c4c4ce59ee37d0358d20fff8d9 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1031,8 +1031,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);