diff mbox series

[net-next] netdevsim: Only use sampling truncation length when valid

Message ID 20210422135050.2429936-1-idosch@idosch.org (mailing list archive)
State Accepted
Commit a9b5d871abc417cf65a05a9ba50c6b81a6e427eb
Delegated to: Netdev Maintainers
Headers show
Series [net-next] netdevsim: Only use sampling truncation length when valid | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Ido Schimmel April 22, 2021, 1:50 p.m. UTC
From: Ido Schimmel <idosch@nvidia.com>

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 <idosch@nvidia.com>
---
 drivers/net/netdevsim/psample.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Jakub Kicinski April 22, 2021, 4:14 p.m. UTC | #1
On Thu, 22 Apr 2021 16:50:50 +0300 Ido Schimmel wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> 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 <idosch@nvidia.com>

Acked-by: Jakub Kicinski <kuba@kernel.org>

> +	md->trunc_size = psample->trunc_size ? psample->trunc_size : len;

nit:  ... = psample->trunc_size ? : len;  ?
Ido Schimmel April 22, 2021, 4:21 p.m. UTC | #2
On Thu, Apr 22, 2021 at 09:14:26AM -0700, Jakub Kicinski wrote:
> On Thu, 22 Apr 2021 16:50:50 +0300 Ido Schimmel wrote:
> > From: Ido Schimmel <idosch@nvidia.com>
> > 
> > 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 <idosch@nvidia.com>
> 
> Acked-by: Jakub Kicinski <kuba@kernel.org>

Thanks!

> 
> > +	md->trunc_size = psample->trunc_size ? psample->trunc_size : len;
> 
> nit:  ... = psample->trunc_size ? : len;  ?

Yea, I don't find this form too readable and always prefer the one I
used when it fits in a single line :)
Jakub Kicinski April 22, 2021, 4:26 p.m. UTC | #3
On Thu, 22 Apr 2021 19:21:37 +0300 Ido Schimmel wrote:
> > > +	md->trunc_size = psample->trunc_size ? psample->trunc_size : len;  
> > 
> > nit:  ... = psample->trunc_size ? : len;  ?  
> 
> Yea, I don't find this form too readable and always prefer the one I
> used when it fits in a single line :)

Fair enough.
patchwork-bot+netdevbpf@kernel.org April 22, 2021, 8:30 p.m. UTC | #4
Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Thu, 22 Apr 2021 16:50:50 +0300 you wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> 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 <idosch@nvidia.com>
> 
> [...]

Here is the summary with links:
  - [net-next] netdevsim: Only use sampling truncation length when valid
    https://git.kernel.org/netdev/net-next/c/a9b5d871abc4

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

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);