From patchwork Fri Mar 1 17:43:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 208981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp39844dyc; Fri, 1 Mar 2024 09:45:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCqJuHr8HITg+s8ihZcZemZtEmZJ+mnyAmGHK3FMZkQFLtd43guundQWu9YRgCXtqqO+J9XkzLefCoM565zExiLuv6hg== X-Google-Smtp-Source: AGHT+IFbmamE2q7kqWF8PrmAVrJomJFN7qPseCEAYIieqhsnLKIPxO2hXMnSm6WrpyVAmt4PHJHe X-Received: by 2002:a05:6402:b86:b0:566:806a:6f9e with SMTP id cf6-20020a0564020b8600b00566806a6f9emr1684091edb.28.1709315110859; Fri, 01 Mar 2024 09:45:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709315110; cv=pass; d=google.com; s=arc-20160816; b=hMArvWYGgj6YNaHe7pEuewUYWczswewkzVlKroFLN6JPW8EslBJKV8YnMJ3q+cIH0b yMS9KCKUN3Jrg3wgKYd8OyaY3tKkaBTxmQX6xk8Zy3MYHyFdlLruODoFFfyPUSIx1IJD bj+py4qchR0eZeBYEjEiFTSHUy1Ro4LvBgqRvbXmMyuhMYOSKvLGClyBxEwAyF1Kb1Gd Mj0+eN6ijNx0UV8JUUv/NxKs95pquWSufiMdk/uJfYCQHpnOcXGh2Cj/Z08zrlFEHr/e Lcq7HBc5YFUWgz405wl9VnYScUKG7dL9X30bp6VwvdFpa3dpguLZNARqgoIHw6eRZxmH Z8rw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=gCc12B07E2gZBfMhSlPti6S/kMb6am8w7H7jjle8Ji4=; fh=dtfL7SHUWpoNkavaEIKFixF3/eMo8TZTrybXzF4g82Y=; b=NqWPBxhqxrZXSIZ1w6nxcvohl9BhvORIIjoW8WTYaFyUFcUXJ0Vl7+gUOOakL/Dsu6 8Ko2+XmPiY4RtFtfakTpsUsk3DI4VQKYiPDQYQV4Hl3beX1I/Bwk7dk3yvCNhePGtauF 2ammHmDokvt8WvrwGqeNmIbJcLI05Rj6uBIQywYRkUFpmHEsPfnrKf8OgefFIANxpQKN DeniY7WexzKHtt6DsQCOg9nHI3YnONaJ30pvN4CnpyOw0pmHNfKAJ0A5CM9LYoCAKgWV fgcl2v9o0035M30nnVWUofK90Zo6coiuWBE3BqyQc+MYRBZhHU8ur9CaVE3E1cDCWmRa g4gQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g6irTJYs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88853-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88853-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s20-20020a508d14000000b00565ac6ebb29si1560376eds.653.2024.03.01.09.45.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 09:45:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88853-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g6irTJYs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88853-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88853-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 795671F27E52 for ; Fri, 1 Mar 2024 17:45:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F11B738DFA; Fri, 1 Mar 2024 17:44:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g6irTJYs" 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 4DDCD28389; Fri, 1 Mar 2024 17:44:12 +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=1709315053; cv=none; b=WlSKbMgsitMqILxFUuW8Zv1qGoPWx9K8+sERxK7XAUkj/TJYYDpVzgiThuplQxJBsRv0hr4yESoHRhN4w8cUGqQZqZzXL47yKACjeT4NG6Yn+kWXDJW8NHIZK8xxHZlJhBV41SaiYys0E5swNLf7jc9v+qeoOCcnJf4fo1Er49g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709315053; c=relaxed/simple; bh=G4kAB8OZ4MXCOBDWMFPMABLVdbV5Sbsejmq3eie/oIU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IZiaFzzhaaN/qKC/lFgEKcZgtDOxsyc8J3UGvL6+XNEmMXrHXubz8X7um4KGFJCgwYinobJ028GzUrU5t827aY9yqCMATGeAG24lNwNDtdsR6LzvdD7mZmkfGOiEgCTc0IROLJQ3EhW2tmkNTFqvz2bkGrwTdhjkyNVrFXxsJZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g6irTJYs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0946C433F1; Fri, 1 Mar 2024 17:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709315052; bh=G4kAB8OZ4MXCOBDWMFPMABLVdbV5Sbsejmq3eie/oIU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g6irTJYsG0b1tftibIKmtpbKQSaVOC6edt9F0Gh4EBRb6L61mta5ykc3wHFcSJHOt /zFXXm1SwL2xfZrjY3V0mQI2BNlHkJ02WgEJAHSS8yVholtMCZ2DMcnvfEtodYemUF zAMmf0l2VkSsSoIuhslQxpr7D8uq1h6T10eCT+hHPpCajn3Y04eoq83blnhFVW2NGh oPaL+BDGQUi06hi1SdNCtZGP6x8lWzVM79s0oL3/suf7Z5jOSgcwXpN2RzG0cEedk7 6c6zV1r41RWO4/5EBu7qCCnt/ZWFIScA+HWgV7tLh/zEr9uKEP+bJbhqkzRHx9YVRx 1Zqby5PaxjRqA== From: "Matthieu Baerts (NGI0)" Date: Fri, 01 Mar 2024 18:43:45 +0100 Subject: [PATCH net-next 2/4] mptcp: avoid some duplicate code in socket option handling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240301-upstream-net-next-20240301-mptcp-tcp_notsent_lowat-v1-2-415f0e8ed0e1@kernel.org> References: <20240301-upstream-net-next-20240301-mptcp-tcp_notsent_lowat-v1-0-415f0e8ed0e1@kernel.org> In-Reply-To: <20240301-upstream-net-next-20240301-mptcp-tcp_notsent_lowat-v1-0-415f0e8ed0e1@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1525; i=matttbe@kernel.org; h=from:subject:message-id; bh=IwTtMaxyL6SadOk3ggccjuN2dObjnXMFlizaf9po/Wg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBl4hPlUHL6w2XO8GVf5jqnDctIoZ1udQhRC431z Tk1U6TC1P+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZeIT5QAKCRD2t4JPQmmg c32uD/9zGka6Yv9dpXPEI6gmxJNd1lT7LUCuHuISOAwZPPtRx5ducsTozslymNZpaD37awTOQf4 0H9nybMJgpk3L8pKWXOxarezbtaDtpkU5iRqCAJGyTqxEzZy6aT2quD0OK5PaZpLVvTe0pNIrpY L+Abifgo+I9pSoKXLXGUqZahC87khx871/a3CgemfsA+CaXNsUTGDlJqsm9f8U7khQn4MUYLHrA mbQDANMoZnRhRbLolqMlE3ctTTMM1SMygwsnCge/cfBzEjSHzf1/i8Vd5E8gZTAvcFazFXs+GI1 CaVRgmevHH/idjnCrvmK27wqw0eevbEvqaE5UPooXbkkAHcUq2MVS6+JxrUN6kf/DEIBd/FXNa7 nnf6zCVb4Jgq4QS/yq42u1bMbFc6xPwWmbj7Jbf5Vtq/pN0+PikB5avJBr6L4IqB2yYymINoFKx QLTyEpSpEbWP238mHxnwAa4A5y6xCE4C8o2dQA7tYHwFZSUIA0l+Wmu620ITU8+dMOwgMsu1dit tBWzLV9w1JjM8x+MOmmMNiajYDG+11iSwlJb1XWaRqNlrNfMaBPMjZBiVJKwES8UjtFT6CKMI6m cZNF6WVXZBwO3Ld6aqNAEnlzTRSDe+akEMYlcCdm4UwtDJdWzkaxcWeuRwWoD7lyQdOelCUHJDJ AizY525FFU8ZRQA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792346801582092340 X-GMAIL-MSGID: 1792346801582092340 From: Paolo Abeni The mptcp_get_int_option() helper is needless open-coded in a couple of places, replace the duplicate code with the helper call. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/sockopt.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index da37e4541a5d..ac37f6c5e2ed 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -629,13 +629,11 @@ static int mptcp_setsockopt_sol_tcp_cork(struct mptcp_sock *msk, sockptr_t optva { struct mptcp_subflow_context *subflow; struct sock *sk = (struct sock *)msk; - int val; + int val, ret; - if (optlen < sizeof(int)) - return -EINVAL; - - if (copy_from_sockptr(&val, optval, sizeof(val))) - return -EFAULT; + ret = mptcp_get_int_option(msk, optval, optlen, &val); + if (ret) + return ret; lock_sock(sk); sockopt_seq_inc(msk); @@ -659,13 +657,11 @@ static int mptcp_setsockopt_sol_tcp_nodelay(struct mptcp_sock *msk, sockptr_t op { struct mptcp_subflow_context *subflow; struct sock *sk = (struct sock *)msk; - int val; + int val, ret; - if (optlen < sizeof(int)) - return -EINVAL; - - if (copy_from_sockptr(&val, optval, sizeof(val))) - return -EFAULT; + ret = mptcp_get_int_option(msk, optval, optlen, &val); + if (ret) + return ret; lock_sock(sk); sockopt_seq_inc(msk);