Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp545191lqc; Fri, 8 Mar 2024 05:28:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWyEGTDzHhlpnEAyYdfXfAdNsQ1VK4ZS3G8C5WCGpsBCSqGuyR22QMflzxaRuj4JGMyw3CBXvD71nfzYo723HNtK56IJJ1ACvYna6R2Zw== X-Google-Smtp-Source: AGHT+IFPpG3s0rKcMZtxrpBZRjWB31BPlFf3XmHTP2bXG4TQg+siH/jtwCLjaYT3qdtDCwiuO7yR X-Received: by 2002:a81:60c5:0:b0:609:f57b:4937 with SMTP id u188-20020a8160c5000000b00609f57b4937mr4425352ywb.18.1709904495629; Fri, 08 Mar 2024 05:28:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709904495; cv=pass; d=google.com; s=arc-20160816; b=g+HiPjRL2BVhiZnaibBI3jf4CsZwmG+wgs7dt3fmTq8zFWbnJTmYC2S9DSf8yfxpBi qGZ1ro7l+MCgmh4liQkS8B37r4AnxczF69LtupDFSuJC5stv3qlk1PxdTjv4C63tSHh6 CCmPCE7XGmazKMf6q6HL1fWfS6T4WLrwIVlQ6TAooZWhYEicKk8r2oMR+fkNc1O/hUyF 6a5sLM7tYQrRUH4Des+9KOIgJuV7javm45fYDLqwgQK2BnHaGPk1KWa0UcyJ8GdzKvoy rDlpLok/q9K26yZKZtnYNFsvqzFum+4q0nBBWOVnMPs4YghVVE5rBoukj46yisrzxt4l I9eg== 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=kuKXTIvJNfdKUyXVvaiWe2kMamo2ZJzl393Ve5lqrIg=; fh=9m20jKLevMcpZPZJbNyjYO8lm3erh0gVtwIfWlYE27o=; b=YjpjBt8a32acNy75gFc3Wu1eNX//9XKB4g1ULEoRKeBvNePgdIO9pFyYdm7acv3f6P 3b5Mqca58Bt4fAa/r2kl0dtx5vuxDJeivCQdijkp4wgycCcDmHpcuzySlw3pjlRubxhR qvsQjYX26C2OGpk8YXunX1lmlby9MvrGG3NTzPdt6RQlqd8JI/rZgXVIeagdsCwwVS0Y eks+OztKUN8GO4Lus//4eUIp8WAOM369tDNhEDbrBKHkQM/ZtmG+hsNLz2LDmySvSvsj YUVrJLoEmX+RCXzt6dXb7lbrR+wxZ5A30fJpQk4R4Iojy11PCcb3ufV/pMuVUuxmoGEL XeYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=W+Oq4h2P; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-97085-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97085-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g6-20020ac87f46000000b0042f129c97b4si5198817qtk.261.2024.03.08.05.28.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 05:28:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97085-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=W+Oq4h2P; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-97085-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97085-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 39E8A1C21247 for ; Fri, 8 Mar 2024 13:28:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23CA7376F5; Fri, 8 Mar 2024 13:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W+Oq4h2P" Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 9A05717EF; Fri, 8 Mar 2024 13:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709904484; cv=none; b=ZR9qr95VGXW75MXFX/ojhFLIVJ1d7ikeb3iPKK096wnf0WkEMWUZ5kGte0PCgoucebYFEf/L3S64JKHrSp8wFkkCIqO8XM8DZMyDKXOYujofMoKT3xexSgMi74QK+ofP7/cG48vVxkJPDoarEFPE+KS4CeoYFK58iUNnW5Uek9U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709904484; c=relaxed/simple; bh=hhKhXs9ZdVSehKaqBwJ8DY9Txa1P8L0TLTB+9MUW46w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=bsragfGSF7Ore3PmRO0U7V3IFt7zRO76mhi2nnYB6qH2X2Lf92vPu9F6uSyj2O22KuJsFDq4qA2K/Ltcg2aWfct1HoseFbaGOg5YqHYWvUDrRLNCv454WFpm+0Fcrzyg3AHS3p5aSu0Q8oRrRbAP35umpL/cS2TpPJP2E+oEEzE= 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=W+Oq4h2P; arc=none smtp.client-ip=209.85.218.43 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-f43.google.com with SMTP id a640c23a62f3a-a44e3176120so288107166b.1; Fri, 08 Mar 2024 05:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709904481; x=1710509281; 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=kuKXTIvJNfdKUyXVvaiWe2kMamo2ZJzl393Ve5lqrIg=; b=W+Oq4h2PwAdon7TynwZlu3cOMDeJTxS9sBiwk9A6XKYio0bZ7uxTpLT73fbRz2CC4G mbdWyN11XbCdOfdY2E/yAiLT2H4bXXi8CfVxGklK8DCxpd8W/TJisw4dVIX8MW1/AeIt Ap6PIXmdbzeYY2lsozMRNSsZF4oOs28IlBSCy/RvE5zd8p6wVOTdJ4V2MDugiTq7IY+1 C+nTLzOa4RykEjMe2EOFhBQ8ZnXBNDLmQ+u1wj1uvZeTTTYMTXFHqG+RcyEIPfH0Z6Lb 9lAaU2Fw9ti36YuJL60lM3ZKDZNZWfoHsBaRdxjp70rbrnk8ZW/FBZSMsSPzw2tnrKTq ZTrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709904481; x=1710509281; 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=kuKXTIvJNfdKUyXVvaiWe2kMamo2ZJzl393Ve5lqrIg=; b=GXPn8jR0XQ9ymHfw+SoKcqCfmSKPfp8CWYL0DHxj9FwITzewXgEuzsIYrd+dxLtwo0 5jH9H/bSQ2fnY3lHtUl7JO8w04Z2HZMtjfxna/IrDbpMiAn9maJyqZcpuT7ejQx6LK/E 7jwbIQZ55lUenMZMWFCOZsJbwcSKjSBuFecMJftiV5sxknLW+PHAntVQxh+3loPGkaxU kBOS1puttN1RdqvZJArdiOpMwxPorOBfPfL4/kpTQI3dsO7ODFjkQbmKxk9GOjEFNmeJ 7Ulq/zPyXkVl719WLCa/QWLDZo3N/yKiWotkgq3cRyEqeZzNmsXPHcTNeMVykoBta3Cf QTvw== X-Forwarded-Encrypted: i=1; AJvYcCXEeUKF5AWUYAqv/JIrlWYMBp9z3RJV0YwBF9nblw938zn1aP1VLfKPDMSRUZFfyg43xb7WgH9FL6uRf2Kv+vSlFaga+sDeGyOzM4IqKKk/bJqlsWNGQOLWeUtgLioxeq2JlrrD X-Gm-Message-State: AOJu0YzKlUn+smgPJkVV4R/2a2XHhV2DSG7nMGHxisQtT03/hxxRUQBh csxtbNF1AYFZz3tz8ephve/yP1tX3udzrUwmIypno2BkMIlVlWXPfaQcOUYfN+TCtIMWRCXgOay baRfFJmxndpkDCq1IvPR+eGxW2C0= X-Received: by 2002:a17:906:39da:b0:a44:e2e0:bda8 with SMTP id i26-20020a17090639da00b00a44e2e0bda8mr12604487eje.0.1709904480790; Fri, 08 Mar 2024 05:28:00 -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:27:24 +0800 Message-ID: Subject: Re: [PATCH net-next v2] net/packet: Add getsockopt support for PACKET_COPY_THRESH To: Juntong Deng Cc: Eric Dumazet , 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 9:19=E2=80=AFPM Juntong Deng wrote: > > On 2024/3/8 21:11, Jason Xing wrote: > > On Fri, Mar 8, 2024 at 8:56=E2=80=AFPM Eric Dumazet wrote: > >> > >> 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, str= uct 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= _rcvbuf) { > >>> if (skb_shared(skb)) { > >>> copy_skb =3D skb_clone(skb, = GFP_ATOMIC); > >>> @@ -3836,7 +3836,7 @@ packet_setsockopt(struct socket *sock, int leve= l, 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 *soc= k, 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 > > Hi Jason, > > Thanks, I have fixed this in the v3 patch. The patch itself looks good to me. But next time please do not post the patch too often, you have to wait around 24 hour at least. We need to obey the rule. Then you have plenty of time to collect/rethink about those suggestions... Thanks, Jason