From patchwork Thu Apr 22 13:50:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 426183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA6BEC433ED for ; Thu, 22 Apr 2021 13:51:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AEA56142F for ; Thu, 22 Apr 2021 13:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236428AbhDVNw1 (ORCPT ); Thu, 22 Apr 2021 09:52:27 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:45575 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236459AbhDVNwZ (ORCPT ); Thu, 22 Apr 2021 09:52:25 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 8E7A95C00DC; Thu, 22 Apr 2021 09:51:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 22 Apr 2021 09:51:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=P6tEnDufyu4Ld4het a43rN/h/1A4rvYoxNQMG/kr4NI=; b=wtRHVdSAzfm2ddaT7r8CJtqcQYCml17lX T7AL//SUFTCkJB36u97mBlf6KpZJQPd82KZCrVHhP2ZHVuUr6TH07UL2o/Qcb1YS z0CpOcSWYIDTlpEyRcG5fjjm9s4mlJm94npR+yBDPT8uts6QerDfB5/KCXvg0kh6 sI9zVbrUpbB43/sD97NbAgW5idQMORuRafC8mYFPfgpoW4+NFx3RGtoH7N/OkVQm 5K2wwQDSsCzjFO7paqChaF+UkzEnZRD8F0XlYO9e61uliHfpdqVVaO6MqtdwDx0r 0r9sEN/FG440j/YfSomqIobRvI6qFyecq2si4nKU13p82ZqmPvMQA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddutddgjedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiughoshgt hhdrohhrgheqnecuggftrfgrthhtvghrnhepteevgefhvefggfffkeeuffeuvdfhueehhe etffeikeegheevfedvgeelvdffudfhnecukfhppeekgedrvddvledrudehfedrudekjeen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehiughosh gthhesihguohhstghhrdhorhhg X-ME-Proxy: Received: from shredder.lan (igld-84-229-153-187.inter.net.il [84.229.153.187]) by mail.messagingengine.com (Postfix) with ESMTPA id E919924005B; Thu, 22 Apr 2021 09:51:45 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next] netdevsim: Only use sampling truncation length when valid Date: Thu, 22 Apr 2021 16:50:50 +0300 Message-Id: <20210422135050.2429936-1-idosch@idosch.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ido Schimmel When the sampling truncation length is invalid (zero), pass the length of the packet. Without the fix, no payload is reported to user space when the truncation length is zero. Fixes: a8700c3dd0a4 ("netdevsim: Add dummy psample implementation") Signed-off-by: Ido Schimmel --- drivers/net/netdevsim/psample.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/netdevsim/psample.c b/drivers/net/netdevsim/psample.c index 5ec3bd7f891b..f0c6477dd0ae 100644 --- a/drivers/net/netdevsim/psample.c +++ b/drivers/net/netdevsim/psample.c @@ -79,9 +79,10 @@ static struct sk_buff *nsim_dev_psample_skb_build(void) } static void nsim_dev_psample_md_prepare(const struct nsim_dev_psample *psample, - struct psample_metadata *md) + struct psample_metadata *md, + unsigned int len) { - md->trunc_size = psample->trunc_size; + md->trunc_size = psample->trunc_size ? psample->trunc_size : len; md->in_ifindex = psample->in_ifindex; md->out_ifindex = psample->out_ifindex; @@ -120,7 +121,7 @@ static void nsim_dev_psample_report_work(struct work_struct *work) if (!skb) goto out; - nsim_dev_psample_md_prepare(psample, &md); + nsim_dev_psample_md_prepare(psample, &md, skb->len); psample_sample_packet(psample->group, skb, psample->rate, &md); consume_skb(skb);