Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp963564lqd; Thu, 25 Apr 2024 01:51:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWlJXSNlJWuVGJiHI/IsIj32YOeq/bPyqLTNMXm3JV3eLy8V32sgfoTYnFYs0jYZP0MovYeizSObDdFX0uarP5m2QGfLWQA3SI2p+q5ug== X-Google-Smtp-Source: AGHT+IFOagyEE/DEtrXy8nUtvLRcLHNC1SjUlt+w69UtxHV9YZXN9dcUCx5a7q0HWK13lgcbWbCD X-Received: by 2002:a05:6402:35d3:b0:572:145a:77cd with SMTP id z19-20020a05640235d300b00572145a77cdmr5205636edc.2.1714035112440; Thu, 25 Apr 2024 01:51:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714035112; cv=pass; d=google.com; s=arc-20160816; b=NexasT2aLu+7IMONjsdBOOcGLi5FyN80FgW3EFiTBdEOPVBkrfJTIQWEqsxKgpua+r 3Mb6A+j+c9k8vzzHWc60GPH04CDvr5gJSq43BXfzv6vTr85wpo9aORe3MWzD2vwaW5GV ffvsEb9w+Y8rrscwNKceVtmM9dQHVPGOl0YxIlb1Gw1J/6WDvVJgnJuB6WrxjCUlFPvx eDVYDRoJUUx5sY9fXIv3//+MPE/UVf8iAiKdkSZWttLOWAKVitrt77t97cs8PQMvXQjg 45E4yvrw+7AYKz/zLGE0K6k7VxZQ+hq3kUQM5DWg4WvlZ4DWU3SHoTPK+a7tZQMy7Gwj oVfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature; bh=SLXYBozdGuze8fwEhSYkE2RdoqPWTdv6MrJs350+i6I=; fh=6gfqqwcP11VraeDS3vpZnvB5nfVGVrG/kjcPOfyhVpo=; b=ReNFqqzo00eOpH1d+9wyi+CzrwNqJR3WHcb77OK9z8dAABahN4sSGw9RTHoyEoJajS G/uyNP6zjqT6HhXx063WKAp5GxR+gukyT+DrTwd0hwJJFP818PucI8Y1TFd+0ABei5yI jnXKowVN4qe/gtGDTR5txkPFDzrD5eyYSgrwL6moWsENgoId99hwTan4ZJDlHR/Ko+sr sPwXzlFMBtoCVLKv/GTsNs8mBkGju5HN5Z/uA6LL735IbteF+eFQopDAVyX+DBBrCwX+ 6Q3f5e+2qRE5RPZvcdXiVdTXmtgD4OEUJmQk/lhQnWuoayXoyoVXB2n157oYuVM3QNnE oP9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=VwRq2FIJ; arc=pass (i=1 dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-158130-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158130-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z13-20020a50eb4d000000b00572468414d0si186567edp.445.2024.04.25.01.51.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 01:51:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158130-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=VwRq2FIJ; arc=pass (i=1 dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-158130-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158130-linux.lists.archive=gmail.com@vger.kernel.org" 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 60ACF1F22933 for ; Thu, 25 Apr 2024 07:33:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 610546D1B2; Thu, 25 Apr 2024 07:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VwRq2FIJ" Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.147]) (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 BDD433A268; Thu, 25 Apr 2024 07:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714030385; cv=none; b=gmdLxEUVVbx9C5yOo+3NoxE2K6i+NFzcBm/CpuPuotjCwDjN5JuaRJu6yPylQgiHo5SUNS8HNXhD5BA6AoNwQ2FQntvqb0P2mQ3CItwGemge+MFsWquCif5uFkV0Aaql0pppTH+iuo8hLvExF4B+glHG7AYHHc8eupF6sPXdbJQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714030385; c=relaxed/simple; bh=EnEiQRFJoJpZqIEia4zGx+kZs4v4yYeavFjjY/vEY8o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JIVppWkC+262zIEve99Pw3Um46EBWJJyiqe+s93csQuq7ggt0F04LCvp14Tq7uWhd1Mkxzq95RTzKVUdgFndHPbB8VmamDZ9dYzLpnFe/aKmrZC6TwMFbFAN5QQ0erOLRBXkkUDD0YhrKQ1R4vWJt7QX+/vq7rDdc3JCSnAz5Z0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=idosch.org; spf=none smtp.mailfrom=idosch.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VwRq2FIJ; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=idosch.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=idosch.org Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id AD1941380130; Thu, 25 Apr 2024 03:33:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 25 Apr 2024 03:33:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1714030382; x=1714116782; bh=SLXYBozdGuze8fwEhSYkE2RdoqPW Tdv6MrJs350+i6I=; b=VwRq2FIJYnOWzzcbNm9ISw77YEfS0U5O1dGEVXOlC7DK iQJroVwQeFxiTMLbtwquAyzPH43vTkpyIW/nJt7+ufRHxNdWY89m3JUngdPNyi1f 0opldTLAqVK+z96J9NqeacHdOh4XMm8DMMeLnSkD6HtwDIOXDhTicbroJfR/q8S4 K7k4x3N0gKHZFtUXVgNK9lYdmC1We+jdeux6DwpNwqlMFeiXadvnIOt8x5AMFYiE LdUtszFBWzQGQHXYnO6EEecJ9DvmQPvD+GPnezxJID7QBdCcmI8Iyn8A2MPt3pxW aorn09OcynIPIZsbvlTfJHqDCfmuxIWsR+4fLh4yEQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeliedguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefkugho ucfutghhihhmmhgvlhcuoehiughoshgthhesihguohhstghhrdhorhhgqeenucggtffrrg htthgvrhhnpedvudefveekheeugeeftddvveefgfduieefudeifefgleekheegleegjeej geeghfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hiughoshgthhesihguohhstghhrdhorhhg X-ME-Proxy: Feedback-ID: i494840e7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 25 Apr 2024 03:33:01 -0400 (EDT) Date: Thu, 25 Apr 2024 10:32:54 +0300 From: Ido Schimmel To: Adrian Moreno Cc: netdev@vger.kernel.org, aconole@redhat.com, echaudro@redhat.com, horms@kernel.org, i.maximets@ovn.org, Yotam Gigi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 3/8] net: psample: add user cookie Message-ID: References: <20240424135109.3524355-1-amorenoz@redhat.com> <20240424135109.3524355-4-amorenoz@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240424135109.3524355-4-amorenoz@redhat.com> On Wed, Apr 24, 2024 at 03:50:50PM +0200, Adrian Moreno wrote: > @@ -579,6 +580,15 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, > goto error; > } > #endif > + if (md->user_cookie && md->user_cookie_len) { > + int nla_len = nla_total_size(md->user_cookie_len); > + struct nlattr *nla; > + > + nla = skb_put(nl_skb, nla_len); > + nla->nla_type = PSAMPLE_ATTR_USER_COOKIE; > + nla->nla_len = nla_attr_size(md->user_cookie_len); > + memcpy(nla_data(nla), md->user_cookie, md->user_cookie_len); > + } Did you consider using nla_put() instead? diff --git a/net/psample/psample.c b/net/psample/psample.c index 92db8ffa2ba2..ea59ca46b119 100644 --- a/net/psample/psample.c +++ b/net/psample/psample.c @@ -589,15 +589,10 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, goto error; } #endif - if (md->user_cookie && md->user_cookie_len) { - int nla_len = nla_total_size(md->user_cookie_len); - struct nlattr *nla; - - nla = skb_put(nl_skb, nla_len); - nla->nla_type = PSAMPLE_ATTR_USER_COOKIE; - nla->nla_len = nla_attr_size(md->user_cookie_len); - memcpy(nla_data(nla), md->user_cookie, md->user_cookie_len); - } + if (md->user_cookie && md->user_cookie_len && + nla_put(nl_skb, PSAMPLE_ATTR_USER_COOKIE, md->user_cookie_len, + md->user_cookie)) + goto error; genlmsg_end(nl_skb, data); psample_nl_obj_desc_init(&desc, group->group_num);