Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp967840pxv; Fri, 25 Jun 2021 02:26:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9TKwqskcIUQNE11HhFM0HiSqgEz7jxZjHAG5Kcy0qP4lAiOgNaksY8wEWjLiYopEDEfqi X-Received: by 2002:a17:906:748b:: with SMTP id e11mr9824199ejl.297.1624613203053; Fri, 25 Jun 2021 02:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624613203; cv=none; d=google.com; s=arc-20160816; b=KwaeMBVir7fBaN3xIsHfvUIXdB/35Nf5b10HwZ2M2UfT88xoEnVgXg1dIfj2PqdYzU LNCq7Qwqy9aOt6uHJUTOIAnUKejE/Epo+c+GKzq64Ny9xIhmuOIvBzWm1HV813d8eLik LE0Rnyka/ouxH19k+FP8zN9qCW3PdWSB1+ehIaltbY8F+1kIS3T4igJFGODEK1djIxN3 Dfp63oldEhNkmR/EMHwMFpHHnwUl74xY7K5ZXS1qq/lj6LrQJYB20jn+5lT/DErdDt0u uBHvvryuJcw9wxtD2N3c4l8p59H6PZgNYPYBu5jkYCHzXEUr3mb/f6K9D9c/dnK8OGKi 96sQ== 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=FSW8x4ihKmjfx6FpIwJBeVSgMNN136RMej5VM7Gn/JU=; b=HSN/PRNcwy/1lcUiJxsPxl/S7n0xxrJMe35QVDzv2AnavWTUCYWOzxQATPkVrsdAYv GH+IwZcLB1BeZxXF7voNjkEEx/MnNz0b3qZ/n2DRDKKZyT2jKOfWQIeIdVCVKxsyZ1FT TFZG+gWDfmhIBQt3aO4ckrQBns/XJ2jN2aHZRPQd5MaKRDQgOAmYCbGboKVuC7CS2uHs OOi/bSfDuFKt9Cu9+nCXHdi3lqnTiLQrL0QPIxAk/4yn8jbDDrJp5M/HlQsR6aeQUlkc j9z4ePeQsRqz2ji4oaZXansYyYS3FBNg+9dSlV4ZOJ+o7iEyS2siCkW3ocAKN6zaR4MD bsXQ== 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 cw18si5405343edb.180.2021.06.25.02.26.19; Fri, 25 Jun 2021 02:26:43 -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 S231607AbhFYJ1N (ORCPT + 99 others); Fri, 25 Jun 2021 05:27:13 -0400 Received: from inva020.nxp.com ([92.121.34.13]:33084 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbhFYJ1D (ORCPT ); Fri, 25 Jun 2021 05:27:03 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id EAE181A21AA; Fri, 25 Jun 2021 11:24:41 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 8451B1A045A; Fri, 25 Jun 2021 11:24:41 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 2A827183AC8A; Fri, 25 Jun 2021 17:24:39 +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, v4, 07/11] mptcp: setsockopt: convert to mptcp_setsockopt_sol_socket_timestamping() Date: Fri, 25 Jun 2021 17:35:09 +0800 Message-Id: <20210625093513.38524-8-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210625093513.38524-1-yangbo.lu@nxp.com> References: <20210625093513.38524-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. --- 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