Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp535064lqc; Fri, 8 Mar 2024 05:12:02 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU/r+kZKJIhGItQ21pdgdmByiBxDtWgYPlIcMB7kjtTvex0qzPcJAm8TIizH+Y5+Lu0ADJfg9XVQ1WlRVTj3jvvu29xMtgaSGOr3A86Ow== X-Google-Smtp-Source: AGHT+IGdtATv6ukSEc78zn0/0iSEWIbXOEuWKDabg8nxK9oQdW3qIglIIG2rV13b/4h+SqbgTFHx X-Received: by 2002:a05:6a00:3908:b0:6e4:766f:be with SMTP id fh8-20020a056a00390800b006e4766f00bemr23246501pfb.21.1709903522638; Fri, 08 Mar 2024 05:12:02 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p22-20020a639516000000b005e428bea40esi16458416pgd.0.2024.03.08.05.12.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 05:12:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="U+gaKhe/"; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-97040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97040-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3094C285215 for ; Fri, 8 Mar 2024 13:12:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B98702209E; Fri, 8 Mar 2024 13:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U+gaKhe/" Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5196F10A34; Fri, 8 Mar 2024 13:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709903512; cv=none; b=cV9gBuSG32ZDh9Al/87XOR0w3PtXtrUqnj25cVj62ku08rdSKpQKamqb4CrSqZkc+GftTg9RMDhPdUY1iYnQnUXR8eyny1+ksxOVOLdnCQt/yrpZ8IU5yIijfogDwoQPrqKaGP5mqndUbgMmXfVTUsgT+ULkpQGAi1J/b+41sGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709903512; c=relaxed/simple; bh=JW/jVIaU96o6BFKFV+Hpp8LRCawyJhrKD/asgcBfzSo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=bYI7J9o6xrHT27pnovgNbLoyV3amntE+9LNxu3Jfwhexs5zfXMxcLiECjabwJVXCRZb9Ho+xDfuio5prNmjPVrZC6ZNeXCF4EqV8hwEobFJKVhW02HmzFTncrVU/W159fLSyNr9bedaThMm3GFEEoNqy+PcPYa6uPWndHH3T+1o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U+gaKhe/; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a458eb7db13so303529566b.2; Fri, 08 Mar 2024 05:11:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709903509; x=1710508309; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dGq+jgqU3Fs7LfeBp/kruC5Fh0mzhcdDwgbZAEOMazM=; b=U+gaKhe/3zHcNn5raQK6c8B0UkhGbdlf7dIZzp4BI87RNe3cBp1mUfGQrdcseIqYHd 2f8Ze1YI9kYFCGFKWgTWvV2cVMOhYyMTuwpPNY5ORV0658zc6ts66Qcm0xdWj8J6Jlkq 0+KYkNw+3VTacB48rhQPWZpuo4xRLkExwbUZ6AQCrsYhxa59PJFRKCTwxag46desVU+s 7kmtxyvLznlNODsz19UwqV31Rtw9BjUKcXQzDFVLHXDzTIkVPfdraYUCZZVUE85Zxu27 Rf7xAgOBdH93tOmwjZW2LNg6+xN4H1OGEJHsMQ0vPhuo6JX4rJXpwyYS2GEaZULKGCmA b2rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709903509; x=1710508309; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dGq+jgqU3Fs7LfeBp/kruC5Fh0mzhcdDwgbZAEOMazM=; b=n6Svp8yPXfutnsKARkJ68D7WKwtiVKvg/OkM8QtdKvEl+zGvOSt7L6Iwryy9ZHtNAI Tx0RrBvJ3YPT7DyDfuzEOB23NkPjHVXEODdbUSZ/Yy1dpPuLD/KoA0Yczj2RIFaG+xkn E81hCHT5L4etFlMtpS3kKVkEdHryOaXN0Oxzm9/+L96p2QeRWVwEAJ7+KeZNmlJVaMtl H8OCY6axDJEeEImj2R1e+6GJOF1TXFfp1m+dQmZycR1u4ClsC5KwIxresZrNJ9ujf6aM 6AWoDTpHZSqyE8SwT/x6dBbxHXgkTVf6DJE62mSH9FLDFcZPRtrS7q0B7pPuxTWtyLt5 lLiw== X-Forwarded-Encrypted: i=1; AJvYcCXWYHZgfDovyxQPJwNJaesZlo034mlA14ow3c99xuf4UT1dZFHgvTcxHc5IaHkCuvRO7bQ+z1EMJ0+6rZclEdU01MKc/75KU91o4/fBpa7O6e3BlG1wTepH3zh+VjADtZj0Jbch X-Gm-Message-State: AOJu0Yw1oCp3i4buvb6/7iKknqbrLBK/uf1aTytxdxIHlD8O138X0g3K F307Xp/y+1PWtaKtyv/4G0g6WJqXRuW8cHm8QdesUcrgeHaW+Z7kCMsbvMR9l+WE3O+7MRXbAWy n91wlIn/DVcq4DkzoWX0nwd1qZhE= X-Received: by 2002:a17:906:bc54:b0:a43:f182:66c4 with SMTP id s20-20020a170906bc5400b00a43f18266c4mr14960738ejv.17.1709903509558; Fri, 08 Mar 2024 05:11:49 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Jason Xing Date: Fri, 8 Mar 2024 21:11:12 +0800 Message-ID: Subject: Re: [PATCH net-next v2] net/packet: Add getsockopt support for PACKET_COPY_THRESH To: Eric Dumazet Cc: Juntong Deng , willemdebruijn.kernel@gmail.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 8, 2024 at 8:56=E2=80=AFPM Eric Dumazet w= rote: > > On Fri, Mar 8, 2024 at 1:43=E2=80=AFPM 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, struc= t net_device *dev, > > } > > if (po->tp_version <=3D 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_rc= vbuf) { > > if (skb_shared(skb)) { > > copy_skb =3D 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 =3D 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 =3D READ_ONCE(po->vnet_hdr_sz); > > break; > > + case PACKET_COPY_THRESH: > > + val =3D READ_ONCE(pkt_sk(sk)->copy_thresh); > > + break; > > case PACKET_VERSION: > > val =3D 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