Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp112777pxv; Wed, 30 Jun 2021 01:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrdXy1CMzc/AnH7fuJIdveJGXC9EKLnThc2XCILS2R/7r51rdXFz86LwE0dJk6KZcbRwzK X-Received: by 2002:a05:6402:14ca:: with SMTP id f10mr45433495edx.141.1625040267856; Wed, 30 Jun 2021 01:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625040267; cv=none; d=google.com; s=arc-20160816; b=JhwUIR4c/p9VhIzHOm0QX1W9dNenZFV6k5nxSCW+QtJYEZPGaW99JWFNq5/YVk04kP ACc4mS0GETo0P9JaKqPCbNgCGY6sso5FyzT1nt0MM1PaWVTG1N2RIOa7US4NvngfXJk9 Xc3Fij69veZ59bq/XneV7+N4ge26TX9rL/S6f1rJ3rqNr+VXnkhIiso2ZXLnRVrjgAvZ briMYjTfrPp7DUebOVyU8FwvFjeMtj4DMwrm/4P944vkCGiwRHKzGM3jVpwjGBuHyk13 zX0oxX7TCnl2vEjZij6WNMREEnAt2zbvWsJ8tLFH1T8E/7HLnRaWSUSpD38NIprV80ED o//g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=B41xg/ra729UMTigEV74M3nlVY0ZZ3warkts4HmOeX8=; b=T1pkHfbocH5qaepJoLwWMbrcc4TLOcGAvVHpRFzh4CMtE4ksdx/AwT6GqQ/1njFC9A My6CFUc1QVQZR33iMUoghF/1ZAVUamX/TSsDWzPFIuoaCH7In9gOYag9pw2FtzgYmvzc P4e0H63iaiO8qJ3VuIpbc2Arg/QIGvnnUUnSKjlNpsoF7zTx7lTbKNZC9JO5MdGx9ifv sob+yX0Xcz0qBkWNgqihHVCmxFJ3rdWTaKvFrzTKCRKt/qHp/1kEhlLHAteJO2uLBn4l dUytm0MvkIlcHkSiVQ3vXWTHgly29bVAlENpDYtb94r/uGa+wtBCV4c0qD0OY6mQEcLS vpAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si19339746ejj.20.2021.06.30.01.04.04; Wed, 30 Jun 2021 01:04:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233756AbhF3IEV (ORCPT + 99 others); Wed, 30 Jun 2021 04:04:21 -0400 Received: from inva021.nxp.com ([92.121.34.21]:59842 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233368AbhF3ID7 (ORCPT ); Wed, 30 Jun 2021 04:03:59 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id EC90B20062A; Wed, 30 Jun 2021 10:01:29 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 84F8920264F; Wed, 30 Jun 2021 10:01:29 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 399F2183AC72; Wed, 30 Jun 2021 16:01:27 +0800 (+08) From: Yangbo Lu To: netdev@vger.kernel.org Cc: Yangbo Lu , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, mptcp@lists.linux.dev, Richard Cochran , "David S . Miller" , Jakub Kicinski , Mat Martineau , Matthieu Baerts , Shuah Khan , Michal Kubecek , Florian Fainelli , Andrew Lunn , Rui Sousa , Sebastien Laveze Subject: [net-next, v5, 07/11] mptcp: setsockopt: convert to mptcp_setsockopt_sol_socket_timestamping() Date: Wed, 30 Jun 2021 16:11:58 +0800 Message-Id: <20210630081202.4423-8-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210630081202.4423-1-yangbo.lu@nxp.com> References: <20210630081202.4423-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split timestamping handling into a new function mptcp_setsockopt_sol_socket_timestamping(). This is preparation for extending SO_TIMESTAMPING for PHC binding, since optval will no longer be integer. Signed-off-by: Yangbo Lu --- Changes for v4: - Added this patch. Changes for v5: - None. --- net/mptcp/sockopt.c | 57 +++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 092d1f635d27..ea38cbcd2ad4 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -157,19 +157,7 @@ static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnam struct sock *ssk = mptcp_subflow_tcp_sock(subflow); bool slow = lock_sock_fast(ssk); - switch (optname) { - case SO_TIMESTAMP_OLD: - case SO_TIMESTAMP_NEW: - case SO_TIMESTAMPNS_OLD: - case SO_TIMESTAMPNS_NEW: - sock_set_timestamp(sk, optname, !!val); - break; - case SO_TIMESTAMPING_NEW: - case SO_TIMESTAMPING_OLD: - sock_set_timestamping(sk, optname, val); - break; - } - + sock_set_timestamp(sk, optname, !!val); unlock_sock_fast(ssk, slow); } @@ -178,7 +166,8 @@ static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnam } static int mptcp_setsockopt_sol_socket_int(struct mptcp_sock *msk, int optname, - sockptr_t optval, unsigned int optlen) + sockptr_t optval, + unsigned int optlen) { int val, ret; @@ -205,14 +194,45 @@ static int mptcp_setsockopt_sol_socket_int(struct mptcp_sock *msk, int optname, case SO_TIMESTAMP_NEW: case SO_TIMESTAMPNS_OLD: case SO_TIMESTAMPNS_NEW: - case SO_TIMESTAMPING_OLD: - case SO_TIMESTAMPING_NEW: return mptcp_setsockopt_sol_socket_tstamp(msk, optname, val); } return -ENOPROTOOPT; } +static int mptcp_setsockopt_sol_socket_timestamping(struct mptcp_sock *msk, + int optname, + sockptr_t optval, + unsigned int optlen) +{ + struct mptcp_subflow_context *subflow; + struct sock *sk = (struct sock *)msk; + int val, ret; + + ret = mptcp_get_int_option(msk, optval, optlen, &val); + if (ret) + return ret; + + ret = sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname, + KERNEL_SOCKPTR(&val), sizeof(val)); + if (ret) + return ret; + + lock_sock(sk); + + mptcp_for_each_subflow(msk, subflow) { + struct sock *ssk = mptcp_subflow_tcp_sock(subflow); + bool slow = lock_sock_fast(ssk); + + sock_set_timestamping(sk, optname, val); + unlock_sock_fast(ssk, slow); + } + + release_sock(sk); + + return 0; +} + static int mptcp_setsockopt_sol_socket_linger(struct mptcp_sock *msk, sockptr_t optval, unsigned int optlen) { @@ -299,9 +319,12 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, case SO_TIMESTAMP_NEW: case SO_TIMESTAMPNS_OLD: case SO_TIMESTAMPNS_NEW: + return mptcp_setsockopt_sol_socket_int(msk, optname, optval, + optlen); case SO_TIMESTAMPING_OLD: case SO_TIMESTAMPING_NEW: - return mptcp_setsockopt_sol_socket_int(msk, optname, optval, optlen); + return mptcp_setsockopt_sol_socket_timestamping(msk, optname, + optval, optlen); case SO_LINGER: return mptcp_setsockopt_sol_socket_linger(msk, optval, optlen); case SO_RCVLOWAT: -- 2.25.1