Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp458549lqg; Fri, 1 Mar 2024 10:10:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX2+pChcy3yLs3JYg118QDNwmPKx9fe+v3zPapoljakJgcnyN0vIMap7DiezGCxlR5HIQz7uzqP2anWKd2h6Kv1we3jDoykK6AxjYwc7w== X-Google-Smtp-Source: AGHT+IGwwhKPSpmqwKCKD2a7kSrL/zpysYzguO7DGGhgdL1lsqLNDLxnElNRh9OwN9Fj9plBYutq X-Received: by 2002:a05:6a00:124e:b0:6e5:9a0a:8b8d with SMTP id u14-20020a056a00124e00b006e59a0a8b8dmr2785935pfi.18.1709316601162; Fri, 01 Mar 2024 10:10:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709316601; cv=pass; d=google.com; s=arc-20160816; b=a/fgTSO6WLwK1q/uKRUOBKAcS4nbr/106AMs40TOuXiPNjVBR6w31N3h935tfQsP6M aMBEAE34LoXyvoGGUo8jJliTwbsskYWDUkHRx/1F+8STgAXubV56U5VQtWShdWRzGAs2 8bxJqNLQhqmFyj60U5u5qTlEEUARfcUz2bXl6EdekOdfIxXLdWbEWPsoNdtDPmbZqAE8 Q0roV6h9KixeAIYaglqsagCBAwUDtwBzSC7SP/pXfm2iLIFxzxZyaJoV1RjKB5PQR6jd lqTlmGCo+llOk4SGOGKUkuhVyybH07tfnUHrG72KDyyCUm58O6WxelOq5qNGb4Y/jwAO e4+A== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88853-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j2-20020a056a00234200b006e53edd5486si3947446pfj.315.2024.03.01.10.09.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:10:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88853-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88853-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AB583B240E7 for ; Fri, 1 Mar 2024 17:45:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C72A36AFB; Fri, 1 Mar 2024 17:44:14 +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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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); -- 2.43.0