Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp524258lqc; Fri, 8 Mar 2024 04:56:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXO747XRVluT9AWNigNzuru06cB9xMyRe9+AVb6KNlwJ/PVpAjXQF/Z0UbbwghV0EjIXZHs4P4wB4cQUixdFV2tck4GkHPCWVInAuVAaQ== X-Google-Smtp-Source: AGHT+IErt1cOEAu2X0RIFQz7f7yr1pqo+9WzuiuIpX07UqiDLrXyKaei4xq10VoGx7cRcSdVGRGN X-Received: by 2002:a17:906:4818:b0:a45:2fc4:f25d with SMTP id w24-20020a170906481800b00a452fc4f25dmr10610284ejq.12.1709902595221; Fri, 08 Mar 2024 04:56:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709902595; cv=pass; d=google.com; s=arc-20160816; b=JdB4/kdr4G/5v6rRlsJrKN4rmE1gOAo3vxgU9Dzej4oDlvS+ZJ0u/XpnHXPbgwI9Jg 36YueCRLQ9Cpp3Wx+PuxvVb/B0pDfWOzgJ8N0p1GNdKGC71LUSjcaz1M9ixuv4JMhqlK ILgKpRYz0joeAt82t0/mZjn9GPBkgFBzPtU4pBPKTBDHghAgduKU4H12XZx6a1Lp6nYd K47iFgOzIeTvg+skD3dkAz4gtTocx1K2C5CBpC+UQzI3mhIrQy5hh93aAKVXohCWbxIn gyubfuhJu3s1LlPcM4u+kG7ZgcbncYDXiY20/XA9OYFt3lxHYPsCEIteWC5tu1d8k0ON +K6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Fm7PqN6wle515KaphgyHt1Rh7fhbY7+uyNPBKeWIyoI=; fh=EeM5FX28VdFWKMFMair4D/4m99abdkExRvIghTNVDtY=; b=OIRo/iuLF8KJbep3Zj41i8WYsA0ya4ufhYZjGZrEi0aK+eFh0+sz7pPkHfMuzZcOji lUgT9TTIW+NPt5dyQrW2looPoBG/HMI5WUMpvDxCnDoTSoinhFdZamurW32lW1fh9pRj lD4HV258Aw9U3AlyJpnP0iAjG+GeY4n5MOzZtQwBhfyTaeliWjOEu9+o8ry6YxzG0TMI W3Logtk9RCEpE0NNdrMCPI0GKb2u3QqfpH6fBwZi29uWCwhDTJKYDn+N0lqCb4241dWV faQr3gOxulSCnu6NDwpOW+LR0rZsCMNnEy9cs94eNkrUQsA8AUeJCTO3lCKo1/GbYh+T Tt2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=h+O1OCD1; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-97032-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97032-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hv8-20020a17090760c800b00a45f357c6c0si332241ejc.59.2024.03.08.04.56.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 04:56:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97032-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=h+O1OCD1; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-97032-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97032-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id EDA8B1F22C8E for ; Fri, 8 Mar 2024 12:56:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE6B51CD06; Fri, 8 Mar 2024 12:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="h+O1OCD1" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 534ED1AAD7 for ; Fri, 8 Mar 2024 12:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902585; cv=none; b=lO6UXyIdMUw+PKE9bIPNAE6x60pmHgWUlzp0fgcalYp1R9dBtlYMwMdLqtx3xAZQc/xfW4Uy7/Mr82SDn9MxHJSBJ26R3RTjOOw10bqJAoWeobBV5QUh2IWdJDxfhWNAvDSELBOEQA9bLCdP52RSFw/p3dXNeE5vIOO8PAACopI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709902585; c=relaxed/simple; bh=UQUx+vJYLbayg51PRY1tgXR0gHlN5v3xj0mWADHAYHc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=g5p1iXtQjs1C4rczBuaWsUj8l3Etrvj1ROPA75qHfz61LmDJ4M9OFSTwATv3Na5D5nnEXbRtMVXX1+4dKBL9YIA+1QZD4sNcz5pay2gGI8+pcTRDSMJvw9GIEyiRvDq3fKPJVeXZ/7dDubEKVLFGrEtzzRi7wwLj6IAULkFxuoI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=h+O1OCD1; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5682df7917eso7822a12.0 for ; Fri, 08 Mar 2024 04:56:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709902583; x=1710507383; 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=Fm7PqN6wle515KaphgyHt1Rh7fhbY7+uyNPBKeWIyoI=; b=h+O1OCD1LOvqUPBkRGARXHJloXsEiK/AXLRT9SqyM+sOxS5GMwHsC1gpqzm0GQFHu7 WSextPxSiIxyAo6v5QyW1fw2YhwjUtkjAFmqz4TPwQ5mfqsuiszeWhru1xp8ti6RMZE2 eJaHuhYwV/t0gX5iMGubKtPr70mHLzH5ehnC1QvhaJ+swG3XJNcEwvxGaP+H3AL7/H2H LW49x9hUgljiMyKXbiqeHbqIIXZh2kei+M/2QS60Vdv9BRLH2PdtV4aLbtPLMtDvA1iS kvo2I/PQz1G0u+dndkvllMxhe5wsV67qx7xOpuW1xgtoIOVNQe7g3UOUV8+3JzEHGTvy wGXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709902583; x=1710507383; 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=Fm7PqN6wle515KaphgyHt1Rh7fhbY7+uyNPBKeWIyoI=; b=rvhAWM8Xs0mvWTuVI1T69cGuS42Mwp8mmP2iaLnA66CqfkMJl8mP6LtMxdn/fCGsge KJenspkqRjhYcox/3ljtWmBqKcZ2dtrqaEuMwzC+cQ8iMhPHhvUFBnQjyuBvJr8+zO7P KJQ3Z7I/whr+++frOFe3JDWc1XSj2WXsCOaXdxzw3a5eYArmpXdKAGgW0B5fiu4dc3RK RalQoK1nt6YT07kB0x03P669FfgPeLZzBW2jXIbg1E2sG2NHtSG/IudEaMb+AvJ+dJM9 t2ySpL2yaJ1k1ckxpL9R+gCC6T1q1ssxTRNeLnL+szyPoZAxlYxl5phyqVWCEecFghqd 4F/Q== X-Forwarded-Encrypted: i=1; AJvYcCXVKE760n81nowCAJ789gmqkvMimP4qgEFKtpsvpsQVmU+hq3vUKn6AcwkKas0Abx7TbBv5pAo0N0dOzbMKNmw/AaVZchWjFmAuBTUD X-Gm-Message-State: AOJu0YyiMcOnEN/r363U55ArQ+yjxJaScQxfoLQpdBCZyv+BreSX8lVu 9+ZXdsi9T3KDFceF6SFbUcsGIqMDnFxdahS3PXQpQR5n6/m/WGyJFBmmnUrf7CbyCBL+cQWDQbe Qx9E9yF7jbVST20q6e74nOFXCaaBBszFdYo55 X-Received: by 2002:a05:6402:2022:b0:568:271a:8c0f with SMTP id ay2-20020a056402202200b00568271a8c0fmr201480edb.7.1709902582518; Fri, 08 Mar 2024 04:56:22 -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: Eric Dumazet Date: Fri, 8 Mar 2024 13:56:11 +0100 Message-ID: Subject: Re: [PATCH net-next v2] net/packet: Add getsockopt support for PACKET_COPY_THRESH To: Juntong Deng Cc: 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 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, struct = 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_rcvb= uf) { > if (skb_shared(skb)) { > copy_skb =3D skb_clone(skb, GFP_A= TOMIC); > @@ -3836,7 +3836,7 @@ packet_setsockopt(struct socket *sock, int level, i= nt 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, i= nt 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()