public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Aaron Conole <aconole@redhat.com>
To: Adrian Moreno <amorenoz@redhat.com>
Cc: netdev@vger.kernel.org,  Yotam Gigi <yotam.gi@gmail.com>,
	 "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	 Simon Horman <horms@kernel.org>,
	 Ido Schimmel <idosch@nvidia.com>,
	 Eelco Chaudron <echaudro@redhat.com>,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] psample: adjust size if rate_as_probability is set
Date: Tue, 17 Dec 2024 08:27:02 -0500	[thread overview]
Message-ID: <f7ty10etp7d.fsf@redhat.com> (raw)
In-Reply-To: <20241217113739.3929300-1-amorenoz@redhat.com> (Adrian Moreno's message of "Tue, 17 Dec 2024 12:37:39 +0100")

Adrian Moreno <amorenoz@redhat.com> writes:

> If PSAMPLE_ATTR_SAMPLE_PROBABILITY flag is to be sent, the available
> size for the packet data has to be adjusted accordingly.
>
> Also, check the error code returned by nla_put_flag.
>
> Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> ---

Reviewed-by: Aaron Conole <aconole@redhat.com>

>  net/psample/psample.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/net/psample/psample.c b/net/psample/psample.c
> index a0ddae8a65f9..25f92ba0840c 100644
> --- a/net/psample/psample.c
> +++ b/net/psample/psample.c
> @@ -393,7 +393,9 @@ void psample_sample_packet(struct psample_group *group,
>  		   nla_total_size_64bit(sizeof(u64)) +	/* timestamp */
>  		   nla_total_size(sizeof(u16)) +	/* protocol */
>  		   (md->user_cookie_len ?
> -		    nla_total_size(md->user_cookie_len) : 0); /* user cookie */
> +		    nla_total_size(md->user_cookie_len) : 0) + /* user cookie */
> +		   (md->rate_as_probability ?
> +		    nla_total_size(0) : 0);	/* rate as probability */
>  
>  #ifdef CONFIG_INET
>  	tun_info = skb_tunnel_info(skb);
> @@ -498,8 +500,9 @@ void psample_sample_packet(struct psample_group *group,
>  		    md->user_cookie))
>  		goto error;
>  
> -	if (md->rate_as_probability)
> -		nla_put_flag(nl_skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY);
> +	if (md->rate_as_probability &&
> +	    nla_put_flag(nl_skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY))
> +		goto error;
>  
>  	genlmsg_end(nl_skb, data);
>  	genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,


  reply	other threads:[~2024-12-17 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17 11:37 [PATCH net] psample: adjust size if rate_as_probability is set Adrian Moreno
2024-12-17 13:27 ` Aaron Conole [this message]
2024-12-17 14:39 ` Ido Schimmel
2024-12-19  3:30 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7ty10etp7d.fsf@redhat.com \
    --to=aconole@redhat.com \
    --cc=amorenoz@redhat.com \
    --cc=davem@davemloft.net \
    --cc=echaudro@redhat.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yotam.gi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox