Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp540784lqc; Fri, 8 Mar 2024 05:21:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV7UfXQFW6JfxyOHBcJ3IgB2jdk9z2BMIMErLF2HrU1lDzfGxDb4Fx2cDAErfgAhpV+jSvf4Yzpq5NQQk/wuD+6dQv7xsDLce+C1VfBRA== X-Google-Smtp-Source: AGHT+IH0SXbd6JQrcqNmqUl6LRaWbPLn6MXxPuDt0JFBUZg1HxvkrvRp8j1QHnW0jywwhUVk9chd X-Received: by 2002:a17:90a:d591:b0:299:3236:734 with SMTP id v17-20020a17090ad59100b0029932360734mr19992598pju.42.1709904059618; Fri, 08 Mar 2024 05:20:59 -0800 (PST) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s1-20020a17090a5d0100b0029b5636560esi3657940pji.65.2024.03.08.05.20.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 05:20:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97064-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=pvAUTXi5; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-97064-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97064-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com 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 9BA89B222E1 for ; Fri, 8 Mar 2024 13:20:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B23983BBE3; Fri, 8 Mar 2024 13:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b="pvAUTXi5" Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01olkn2080.outbound.protection.outlook.com [40.92.64.80]) (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 B3B2822EFB; Fri, 8 Mar 2024 13:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.64.80 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709903979; cv=fail; b=iguObbDmgFA888Wok0bNJRsaOnSE1R5ELFuYxf8qD520Vi0WTLpXtXk7Lo3Kqbb7p/AsWwHhFhyoDuGa1OcCBFbkjiSieImyCT9GQ0GNgBArO6qEVn19lTxA7ZPa6nQAtuD7KIWLjGvUm6iehjHCmK2oih50VSAQddGQVrhc0x8= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709903979; c=relaxed/simple; bh=maLG+lG4BRYhGffDIseQcJKOUkhdiXnxgEcXBmXV9fs=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=ryNpp3YJdB6lP6IAAEdLXV6uu56gVqsVgckWtG9cPXRdkY2JWzBJMIpmYHaGNRZQ0jFBd9iekkbEduUMt5paJK0kTcyp9XcjDSZJGAPRZJ4iFn2NDqxKyRnS0PX+mCYXGBOqxlq7bDp5khELwY0rKx+pORIvFUZ5IDwW9WF9aZY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com; spf=pass smtp.mailfrom=outlook.com; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b=pvAUTXi5; arc=fail smtp.client-ip=40.92.64.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OoQRR5WBhLnu2N7xuJ+AlxH0je3KJpS3ffJRCv4WlcaRmRg9Z7nzhmSoOPByi/QbeiKPe5U/jvNNVvO2bieBt7psmmM43fuZq85s0lsI8MpzOhg7AJsEPZL66PHLMDd5jrGh8+ehBXYptXtFBEmY6ByWcCzfrZvHnnWmJRqjN3DrRxfbpt28/SpNymh8O+ZnpsVN5ac+arPgFmycJkCxOlrfaDj3NIow7eD9RKoOGu/hnX02gu97PDgwljgzFY88SMmOWOC3yq1HKRpR041gly0QdjI3ya97XOVowTpuJDYDNzqDLL55NO62YM+UBOi2IHfL3Dmr8fJ6eeSXNyZOgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7MarknDqVVjnz3Vkpmsh4xt8Y2KFGhU5h4Euke8bn4I=; b=hE8phGWMdX5CPhAWsvbOmf5ch6Bi8n0hv2OiLIDJmYwT0KFvgsF+75leSvUBWLThJqbdkTco33BTEZwqdRwK7UmgxZh12QPH66pPFjN1M307O8M4gwWvr2fprSjzZxnm2jen4CXLKWAoVNKRPJu+jc6+7M6E+GZPkyegZgKs+qiQyT6lBSzNAvHjVjQiqdHzEmM8nNA1hl4YUp0cZYK3ZW4rZhpYu5i8Oq9SqzNuY6F4cBJibOYenM3NLboaSm0ElLvuyGIBCy28B5gLcrgCVS4LlJW0uJy6eluaei3vMZcAgaZCizfiELng1tSWETbLx92QJYgZ4kZrhMRBb2kycQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7MarknDqVVjnz3Vkpmsh4xt8Y2KFGhU5h4Euke8bn4I=; b=pvAUTXi52aa1zaSwwO46av9LokWk8AgIa4eMdRWgizCpvdndXuVIc4t6CI8+OkuG/WhoFOovESkQAscbMXfk/vYpHK5VrpwEHtu3QjWX9fKKXPk3pYtmnXlJC1wgkGQ0+XJKnNbAxlnAlt49K3FrdC1tSpThEeDhx6cjkgnbSjQuN2ytxy0g4Mt1qbR0eBvnEtk5BxZvDRVusuUMzFlu8m8rkAcW/e9F/JcgOFi39l1c6YtacQUALzIc59tw/RUXhAyOy+vhRu61kSnB3001v3KSJfw89dfLsGcR6p5+gQUcgLRb52ZUWxEUtnTSziA86pMweDEKDvOb2PzlphtVkw== Received: from AM6PR03MB5848.eurprd03.prod.outlook.com (2603:10a6:20b:e4::10) by DU2PR03MB7941.eurprd03.prod.outlook.com (2603:10a6:10:2d8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Fri, 8 Mar 2024 13:19:35 +0000 Received: from AM6PR03MB5848.eurprd03.prod.outlook.com ([fe80::58d5:77b7:b985:3a18]) by AM6PR03MB5848.eurprd03.prod.outlook.com ([fe80::58d5:77b7:b985:3a18%7]) with mapi id 15.20.7362.028; Fri, 8 Mar 2024 13:19:34 +0000 Message-ID: Date: Fri, 8 Mar 2024 21:19:34 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v2] net/packet: Add getsockopt support for PACKET_COPY_THRESH To: Jason Xing , Eric Dumazet Cc: willemdebruijn.kernel@gmail.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Juntong Deng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TMN: [QtxF1Z3AwTERGqEDf7wPjvrAy8u6PRLW] X-ClientProxiedBy: LO4P265CA0134.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c4::6) To AM6PR03MB5848.eurprd03.prod.outlook.com (2603:10a6:20b:e4::10) X-Microsoft-Original-Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR03MB5848:EE_|DU2PR03MB7941:EE_ X-MS-Office365-Filtering-Correlation-Id: d4445de5-4482-454f-e199-08dc3f7265b0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YzpIXBIpBaPiQX/AvfPQTryR55qKYw+nc7fZcMEa24wlPs8wcseLvCpGoEee96IqpBZ3WJdc31qo9LzOypa8lYiijzc3X4wHtsZ3MjosyNxddqudeL+0biBZDZFTyFakSMQcHTQy6wvtgJHvxxJ58SmiHLNBVaO5enYn9VZET/+iPw5twdJUD6T4bS33KXtMX2QUbCnr1hqVtaXAAePyy9d8qsTCQK+IbHGf3s50Zsa86eZJvytFQNEn0LfeBYE32JcIlcsmOzDzVoa1F4nOoc30SS1T6K+CqzijwCIKKlSFLh4h9u1qQuLQ+9CzhdhzmfKt4iRVssZ9jddbKBLcNnvxd4veou8IiOxi4vEnhAnpzmkfS+BKP6D4UZ0Xw1I5DTHauILIwIFP8Dhx1shbjW+vfuVgpQMbPg1gYbMCeAJCrRJdiCZEEr/zOjGjV5jjk5VeJVE3DHwTLwm4HmXuEK0rcMBlPg2atF29y7Xm2lsQrwHlwNmEl6jALU1rz+XCcYja5icvmnt4f218t6OVdYwoSjiihwmyUz+6LGp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atorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4445de5-4482-454f-e199-08dc3f7265b0 X-MS-Exchange-CrossTenant-AuthSource: AM6PR03MB5848.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 13:19:34.6296 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR03MB7941 On 2024/3/8 21:11, Jason Xing wrote: > On Fri, Mar 8, 2024 at 8:56 PM Eric Dumazet wrote: >> >> On Fri, Mar 8, 2024 at 1:43 PM Juntong Deng wrote: >>> >>> Currently getsockopt does not support PACKET_COPY_THRESH, >>> and we are unable to get the value of PACKET_COPY_THRESH >>> socket option through getsockopt. >>> >>> This patch adds getsockopt support for PACKET_COPY_THRESH. >>> >>> In addition, this patch converts access to copy_thresh to >>> READ_ONCE/WRITE_ONCE. >>> >>> Signed-off-by: Juntong Deng >>> --- >>> V1 -> V2: Use READ_ONCE/WRITE_ONCE. >>> >>> net/packet/af_packet.c | 7 +++++-- >>> 1 file changed, 5 insertions(+), 2 deletions(-) >>> >>> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c >>> index 0db31ca4982d..61270826b9ac 100644 >>> --- a/net/packet/af_packet.c >>> +++ b/net/packet/af_packet.c >>> @@ -2318,7 +2318,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, >>> } >>> if (po->tp_version <= TPACKET_V2) { >>> if (macoff + snaplen > po->rx_ring.frame_size) { >>> - if (po->copy_thresh && >>> + if (READ_ONCE(po->copy_thresh) && >>> atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { >>> if (skb_shared(skb)) { >>> copy_skb = skb_clone(skb, GFP_ATOMIC); >>> @@ -3836,7 +3836,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, sockptr_t optval, >>> if (copy_from_sockptr(&val, optval, sizeof(val))) >>> return -EFAULT; >>> >>> - pkt_sk(sk)->copy_thresh = val; >>> + WRITE_ONCE(pkt_sk(sk)->copy_thresh, val); >>> return 0; >>> } >>> case PACKET_VERSION: >>> @@ -4090,6 +4090,9 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, >>> case PACKET_VNET_HDR_SZ: >>> val = READ_ONCE(po->vnet_hdr_sz); >>> break; >>> + case PACKET_COPY_THRESH: >>> + val = READ_ONCE(pkt_sk(sk)->copy_thresh); >>> + break; >>> case PACKET_VERSION: >>> val = po->tp_version; >>> break; >>> -- >>> 2.39.2 >>> >> >> I think you forgot to change net/packet/diag.c pdiag_put_info() >> > > Ah, he updated his patch so soon even without taking a break. > > I just replied to the v1 thread with three changes made. > > Juntong, you could check your v1 patch thread and you will see the > missing point. > > Thanks, > Jason Hi Jason, Thanks, I have fixed this in the v3 patch.