Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp424020lqo; Fri, 10 May 2024 04:19:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4+rV9bqDKR+2/eRPWPS1p4a70+NET3VsLAOqi4f+i5pVSeI3Dm35zGczwBK1Nw5Lbr45CzOX3Lhjo/NSgvL3X8rRqa7K/YHBvB2OiLQ== X-Google-Smtp-Source: AGHT+IGm91tfa3kuxf0wgbdQzmLpHaSQfu2y9iCTDnFr6ipZZ9SCuNr/skhBIHs74Jt+N+y7gRkv X-Received: by 2002:ac8:5f4b:0:b0:43a:7bb9:c3dd with SMTP id d75a77b69052e-43dfdac07c5mr24187221cf.16.1715339996426; Fri, 10 May 2024 04:19:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715339996; cv=pass; d=google.com; s=arc-20160816; b=r/Vhl3LtRhkrem+SvVgtdilqfWYPoogyivk/60DcLPF2EIuNUuxQ6xgxz5Jv7dkblv s17GxympXUtDdkeVrGG461YvMYDZJKtdTKdp0VTMbS6QEs+xKRtB1aQkMsd7bUI5qpvC bX1DHpsoO7MNGSm+SQu2Iig7RD6x4xVlYgGR3JmkS4pLujpbPm3RtgP2eE7pADewhzcZ e8gxIPkIUpZrCaNqRpQAN6PW1e7+EFZsAguEFH9TwsZyjZq2pR+H2HLnuSZR96HizODc Zn/N5I7AQlSmGpq8hf52FcbcEkhFYyX7IO6OkRoyDrKIXvYtwnRV9II5oqEa9aXPI4U3 rwlQ== 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=Y8JEYZW4EN86q7ItEzI6xJGUHOHM9BToOiy+45uX7h8=; fh=quEeNqdtSTihk0Sjr9Tsd/2OdzTTR5adQM8Csz/bJ2A=; b=w6SiXNdpebg3drHWArGlwPprGXNUxsW03VqLx7hijzX/NSGw1qaMLh1FYvKwO/hUQm MlpL6W+GVK8pYyYmCqGmwyT2rCwLBWKF4LZalEt3k+NycE3VFwEWGXjc62ndzHXwHRZl yxYkp2RWLoVVXP/37Ry4AlKh23asy/IZK6UkT5HB1v9pNSx8HDweATlqoRhM68wIsAD6 lvPfJDsPl5q3qnx5xTDp9mMxiR5bqD2TCpbVGK/PAbPSWLNwQNVd2+2U4/Mu39/dEqju DMAbP1LE682B7JRax8bT7AdPbxokKMtUSlLdxzJi3wRDGWET9BgECEtlxcwxysMcR4Ub NpWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="EHa//+Rm"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-175639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df56e9fdcsi30607991cf.775.2024.05.10.04.19.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 04:19:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="EHa//+Rm"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-175639-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175639-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2BD191C21628 for ; Fri, 10 May 2024 11:19:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E10117083F; Fri, 10 May 2024 11:19:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EHa//+Rm" 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 6C52D170820; Fri, 10 May 2024 11:19: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=1715339944; cv=none; b=htr/kQKmbMj2xz4aAADX95ae3hkepjjlSZav5Alps0WHUzmobYxqXNnLBKOWT9m1dRnT8WbTgA3henpcaZQqcnlVaGWDGy+N49WWHfkjFzEA5f4zBx2JmGA75PCijSmwSVuQfyLNGA5gEIsY5y7Ssqn+q0FWqTSLz5CPhTidhKg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715339944; c=relaxed/simple; bh=pINmx7wjasMIzKOzIYi//6CSOIrW7PFU3u6Ef24zc9I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AxZJ4fYWzLLSi1X5Z3af8zkE7N3EYlHxhIXG0Ab4q67dMP6VQJBTU7ijEDC/csDxNs+YVcCB69IKqdby9teFWn4b5f9S2s1vlVy6dXFsBB3qh/RsA4xQuoVLrmgWJ3nN/i6d6BwD8YbzXojqShOA0s3Ix9zKtHUHDt8TvWGSXEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EHa//+Rm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C6B3C32781; Fri, 10 May 2024 11:19:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715339943; bh=pINmx7wjasMIzKOzIYi//6CSOIrW7PFU3u6Ef24zc9I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EHa//+Rmb9cn8zOi/ZXRzswfG6jB2dAFNCce7FVetQwXVsX63XR6/B4qHXlnCN1iP PQCeyLU4UI6Qk4SN2AxV09E1l0R99tDL1f8gk644A2McCFgsiHWn6KP2P4sfVoaNAb 0Ruu0t6DLQpv4KcDOF3RiEp3Ox4wo/s5AjjQ6MGPDFqcyp8AJvfW5Ga7/ErVKHwqDI acF5ZRFEKctrH81FHdRLomzVreWR5w5mKaQ0d/0rnS7CV4ncZ3mnOyh89DWQ1nMVxW ciL4Ii2mQS9mLWN3QQtbZsN+YbmzqqbX6J1JTsNm6wEhyz4KqHE8Rp9cYf7YMbD7Ia mbPJNtvAcLdUA== From: "Matthieu Baerts (NGI0)" Date: Fri, 10 May 2024 13:18:33 +0200 Subject: [PATCH net-next 3/8] mptcp: sockopt: info: stop early if no buffer 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: <20240510-upstream-net-next-20240509-misc-improvements-v1-3-4f25579e62ba@kernel.org> References: <20240510-upstream-net-next-20240509-misc-improvements-v1-0-4f25579e62ba@kernel.org> In-Reply-To: <20240510-upstream-net-next-20240509-misc-improvements-v1-0-4f25579e62ba@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Westphal 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=1188; i=matttbe@kernel.org; h=from:subject:message-id; bh=pINmx7wjasMIzKOzIYi//6CSOIrW7PFU3u6Ef24zc9I=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmPgKcH1RuhQuyv02ND9Fv6tMewkMKpuR9jyHCj W+eN0IGmNOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZj4CnAAKCRD2t4JPQmmg czetEADP6o+iepSNJOR6IvzfH6OZitnn2NkgObMiX9GYsoNlivJSa8H9GnhY02y/dp1D752Rw/3 6W2Z9V8HEEr9Ot5taL8BeTq+E29h2svpLufGn+eIPi6QsdqwItEj3h5P5SlYJO/X86KtxeG2bvQ +VplqCDQQHHFm0w6Vvb3v1ChyX1xwgqEQsBU3YPm4D7GIfJl/893gdQ8PHER+zTW1bsep7N5p1C MGetQY/zFJdtBMO7yYhD7XsQf/YpgK9nu2zDjZjqlSRvV+2erk6X9f01l9voU9jmrWZCKMLgLbZ e4SLqXl7wC2oFlqNvG9mMeOfCU67TDOJNHBtOto41lP6EuLkJSt/sDUHxnKaUT76MGpQodw7vkz 7qONNGC7WQIqSpPwBiC+2z0QPeOP7y1FYKcZStEuVzftC9BXOQYZpRCxrJV+6OtIzVGoNLYfGnl 8yZFKKL1Qw8yJphAitItwYMOsYuTgz0U0IEufRggX4fqaBZRlWkg2eVdl2MRZZOltCnkbrfPHv/ qVBj05h6jYvT2zaqrOdHwoDNdgKaOicfVo2VUJ+CyM7WE2raiu7qEvobYhhSRaxE3VzWNXeIN1+ 1Ad3karsAmZHV02qUcjcwwWqxqe77HCpaOyV0ORDJV/ZplZ4WsLbk1MKjNSAmSrl+ZbDAtxnYIF 6rI5krGOW0MMMmQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Up to recently, it has been recommended to use getsockopt(MPTCP_INFO) to check if a fallback to TCP happened, or if the client requested to use MPTCP. In this case, the userspace app is only interested by the returned value of the getsocktop() call, and can then give 0 for the option length, and NULL for the buffer address. An easy optimisation is then to stop early, and avoid filling a local buffer -- which now requires two different locks -- if it is not needed. Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/sockopt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 63a3edc75857..cc9ecccf219d 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -999,6 +999,10 @@ static int mptcp_getsockopt_info(struct mptcp_sock *msk, char __user *optval, in if (get_user(len, optlen)) return -EFAULT; + /* When used only to check if a fallback to TCP happened. */ + if (len == 0) + return 0; + len = min_t(unsigned int, len, sizeof(struct mptcp_info)); mptcp_diag_fill_info(msk, &m_info); -- 2.43.0