psample: adjust size if rate_as_probability is set
Subsystems (3)
PATCH 1/1 psample: adjust size if rate_as_probability is set
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.
--- net/psample/psample.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/psample/psample.c +6 -3
@@ -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,
Signature · 1 line
2.47.1
Quoted 8 lines · Adrian Moreno
If
PSAMPLE_ATTR_SAMPLE_PROBABILITYflag 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 <[email protected]>---
Quoted 30 lines
net/psample/psample.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)net/psample/psample.c +6
-3@@ -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,
Quoted 7 lines · Adrian Moreno
If
PSAMPLE_ATTR_SAMPLE_PROBABILITYflag 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 <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 17 Dec 2024 12:37:39 +0100 you wrote:
If
PSAMPLE_ATTR_SAMPLE_PROBABILITYflag 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 <[email protected]>[...]
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html