net: psample: fix flag being set in wrong skb

A typo makes PSAMPLE_ATTR_SAMPLE_RATE netlink flag be added to the wrong
sk_buff.

Fix the error and make the input sk_buff pointer "const" so that it
doesn't happen again.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Fixes: 7b1b2b60c6 ("net: psample: allow using rate as probability")
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
Link: https://patch.msgid.link/20240710171004.2164034-1-amorenoz@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Adrian Moreno 2024-07-10 19:10:04 +02:00 committed by Jakub Kicinski
parent c9741a03dc
commit 8341eee81c
2 changed files with 9 additions and 6 deletions

View File

@ -38,13 +38,15 @@ struct sk_buff;
#if IS_ENABLED(CONFIG_PSAMPLE) #if IS_ENABLED(CONFIG_PSAMPLE)
void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, void psample_sample_packet(struct psample_group *group,
u32 sample_rate, const struct psample_metadata *md); const struct sk_buff *skb, u32 sample_rate,
const struct psample_metadata *md);
#else #else
static inline void psample_sample_packet(struct psample_group *group, static inline void psample_sample_packet(struct psample_group *group,
struct sk_buff *skb, u32 sample_rate, const struct sk_buff *skb,
u32 sample_rate,
const struct psample_metadata *md) const struct psample_metadata *md)
{ {
} }

View File

@ -360,8 +360,9 @@ static int psample_tunnel_meta_len(struct ip_tunnel_info *tun_info)
} }
#endif #endif
void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, void psample_sample_packet(struct psample_group *group,
u32 sample_rate, const struct psample_metadata *md) const struct sk_buff *skb, u32 sample_rate,
const struct psample_metadata *md)
{ {
ktime_t tstamp = ktime_get_real(); ktime_t tstamp = ktime_get_real();
int out_ifindex = md->out_ifindex; int out_ifindex = md->out_ifindex;
@ -498,7 +499,7 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
goto error; goto error;
if (md->rate_as_probability) if (md->rate_as_probability)
nla_put_flag(skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY); nla_put_flag(nl_skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY);
genlmsg_end(nl_skb, data); genlmsg_end(nl_skb, data);
genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0, genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,