From patchwork Tue Mar 4 07:16:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14000077 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1EEE1FCCF6 for ; Tue, 4 Mar 2025 07:16:27 +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=1741072588; cv=none; b=Sge524BC4l277wpF9K2E9lVaBx5JqmmwFeQnAhukT1Vmd+89cZf8605frQffhOP9zguPkrnTDJY48Vtrp5GdunEI/ANI5nTnan3O4jzn4yAfX8uuztjx3eF7TsHFK844JRFkdJnSY2SJb7vRWzXXNPTp7Y17pvwutu+2ErXLfsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741072588; c=relaxed/simple; bh=XqgnWgMv/XgsuZQzX/zcofXdmTonkUB2TbiHqAVnZtY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B+l3WP2VYo9H/Kl3vyS7Qhu6UHYTqsG4KiVNhIU+IgzZtOf/SYPBXgeXDA8LLNXefSDWwIRH2vPDFjrgbkF8yfnj9dpWLFPtMdpklMV08uGJoE51M3nv4JAy7roUe82qCEEtl3uqXhBIDXtkZ4kJ/GQNDoPPiMc031OD8zrwhJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r3hgKG5e; 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="r3hgKG5e" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB248C4CEE8; Tue, 4 Mar 2025 07:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741072587; bh=XqgnWgMv/XgsuZQzX/zcofXdmTonkUB2TbiHqAVnZtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r3hgKG5e+JNH/ftnKA8d0WK212ON49s8tBYlivX/DJBozLoGWO91TFE29jGnPN+2u 2mhiukc7288X90SHRjzpneBb+3J/1Nj0fMyf+u+IzRpLRu4ZkLCB+aLhvBsLf8NuQl r+8Cf54aAN3N/UWimo0/8G8MTyKIpIYZfmAKwWzhDkfsle0sZA4ThyTeW46aOACGLJ wglE2BlStO2TgZ2aFqrDDe9dbKB/D/mXmhv/1qcaLlU0QywsFAsry8ZydRXSRSLLFY iggP9LGsrpIp7gxrZ+mQyjtK8Vxjv1HV9ZskqAmTdxCUcOhJyG8PGxauxj7LfVt1sA JuKo55uzEV7dw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v1 1/2] mptcp: pm: in-kernel: use kmemdup helper Date: Tue, 4 Mar 2025 15:16:16 +0800 Message-ID: <52adeb78ddc4d78345fffa31b6926b59906dc8c4.1741072099.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Instead of using kmalloc() or kzalloc() to allocate an entry and then immediately duplicate another entry to the newly allocated one, kmemdup() helper can be used to simplify the code. Signed-off-by: Geliang Tang --- net/mptcp/pm_kernel.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 62ae68abb2cb..806a9b5b3c07 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -710,11 +710,10 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, return ret; /* address not found, add to local list */ - entry = kmalloc(sizeof(*entry), GFP_ATOMIC); + entry = kmemdup(skc, sizeof(*skc), GFP_ATOMIC); if (!entry) return -ENOMEM; - *entry = *skc; entry->addr.port = 0; ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true, false); if (ret < 0) @@ -817,13 +816,12 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) return -EINVAL; } - entry = kzalloc(sizeof(*entry), GFP_KERNEL_ACCOUNT); + entry = kmemdup(&addr, sizeof(addr), GFP_KERNEL_ACCOUNT); if (!entry) { GENL_SET_ERR_MSG(info, "can't allocate addr"); return -ENOMEM; } - *entry = addr; if (entry->addr.port) { ret = mptcp_pm_nl_create_listen_socket(skb->sk, entry); if (ret) { From patchwork Tue Mar 4 07:16:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 14000078 X-Patchwork-Delegate: matthieu.baerts@tessares.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB8E61FCD0B for ; Tue, 4 Mar 2025 07:16:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741072589; cv=none; b=QzuXEwVtq/WKgTWRiQWZMGi496bAA4Ts52rvSy/qKd76rZLwoagKrpE8IDudLGTcokpr2wQoG9z/0Fw9FJn8aePs6Nba15m4NNN99xSYLx40BN4CFFP2+CxgFjR7ryEw54LlyTJtnUhh7Nr1bfqIiZH34nZ3zus/ZuO0W1SjugU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741072589; c=relaxed/simple; bh=TDW9QKyXUIkWBx5kgnb5kR50lq3izZWsmoF+n6hArnI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fp9ZxHaC+AFhg4dKNZbLQ1HrxqaSN0rNAI6H/YKDyb6W/nAoIVlnntllF6qlrJk0Jry8pkgQpEW/EaeeNDhYaQrSeQtKYFF8kRAiz2oQYTiHU3LNoiZNJTL3nyYeiQuLGHcyYr8iQGqY9eLoES6Z1uGPx6fXC6bXUzYJ5XR+X3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CYLMFQr3; 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="CYLMFQr3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1544AC4CEE5; Tue, 4 Mar 2025 07:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741072589; bh=TDW9QKyXUIkWBx5kgnb5kR50lq3izZWsmoF+n6hArnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CYLMFQr3oaEzBVjFWiQqbEvE+dAlyZVqO+pdN1beIhuIAMse5/SClcln4mXU3P7Z7 5Jr5VyyCYcSv1QozMRAQWFXB3JmB+wPptfazVi1U5eIomfm/XYduRmJHCoM+JkWG72 goSpANW1qZ+lqb8IvRf3fTPO8EbwYaPSLb2dF95RGH3LoRGFC1+1DONRM67Xe686iA kEI96l148qXPRq7eoUJdhgD4FJdLxjJTAhIuchUChdgdE+X35GauTw64UIO6SsmbxI tLTEWw1j3BDO4YknweHTgVrFg+Qh0Kh9zjFzeytnkFwUCyFqJSAbysk3xcsMcWIAT7 Nng9s2PkweF2g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v1 2/2] mptcp: pm: use pm variable instead of msk->pm Date: Tue, 4 Mar 2025 15:16:17 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang The variable "pm" has been defined in mptcp_pm_fully_established() and mptcp_pm_data_reset() as "sk->pm", so use "pm" directly instead of using "sk->pm". Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 8e6a325a3898..04a156395aad 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -511,13 +511,13 @@ void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk) * be sure to serve this event only once. */ if (READ_ONCE(pm->work_pending) && - !(msk->pm.status & BIT(MPTCP_PM_ALREADY_ESTABLISHED))) + !(pm->status & BIT(MPTCP_PM_ALREADY_ESTABLISHED))) mptcp_pm_schedule_work(msk, MPTCP_PM_ESTABLISHED); - if ((msk->pm.status & BIT(MPTCP_PM_ALREADY_ESTABLISHED)) == 0) + if ((pm->status & BIT(MPTCP_PM_ALREADY_ESTABLISHED)) == 0) announce = true; - msk->pm.status |= BIT(MPTCP_PM_ALREADY_ESTABLISHED); + pm->status |= BIT(MPTCP_PM_ALREADY_ESTABLISHED); spin_unlock_bh(&pm->lock); if (announce) @@ -1009,7 +1009,7 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk) WRITE_ONCE(pm->addr_signal, 0); WRITE_ONCE(pm->remote_deny_join_id0, false); pm->status = 0; - bitmap_fill(msk->pm.id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); + bitmap_fill(pm->id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); } void mptcp_pm_data_init(struct mptcp_sock *msk)