* [PATCH net] psample: adjust size if rate_as_probability is set
@ 2024-12-17 11:37 Adrian Moreno
2024-12-17 13:27 ` Aaron Conole
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Adrian Moreno @ 2024-12-17 11:37 UTC (permalink / raw)
To: netdev
Cc: Adrian Moreno, Yotam Gigi, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Ido Schimmel,
Eelco Chaudron, Aaron Conole, linux-kernel
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>
---
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,
--
2.47.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] psample: adjust size if rate_as_probability is set
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
2024-12-17 14:39 ` Ido Schimmel
2024-12-19 3:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Aaron Conole @ 2024-12-17 13:27 UTC (permalink / raw)
To: Adrian Moreno
Cc: netdev, Yotam Gigi, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Ido Schimmel, Eelco Chaudron,
linux-kernel
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,
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] psample: adjust size if rate_as_probability is set
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
@ 2024-12-17 14:39 ` Ido Schimmel
2024-12-19 3:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2024-12-17 14:39 UTC (permalink / raw)
To: Adrian Moreno
Cc: netdev, Yotam Gigi, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Eelco Chaudron, Aaron Conole,
linux-kernel
On Tue, Dec 17, 2024 at 12:37:39PM +0100, Adrian Moreno wrote:
> 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: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] psample: adjust size if rate_as_probability is set
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
2024-12-17 14:39 ` Ido Schimmel
@ 2024-12-19 3:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-19 3:30 UTC (permalink / raw)
To: Adrian Moreno
Cc: netdev, yotam.gi, davem, edumazet, kuba, pabeni, horms, idosch,
echaudro, aconole, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 17 Dec 2024 12:37:39 +0100 you wrote:
> 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>
>
> [...]
Here is the summary with links:
- [net] psample: adjust size if rate_as_probability is set
https://git.kernel.org/netdev/net/c/5eecd85c77a2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-19 3:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-12-17 14:39 ` Ido Schimmel
2024-12-19 3:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).