Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 7b1b2b60c63f ("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>

authored by

Adrian Moreno and committed by
Jakub Kicinski
8341eee8 c9741a03

+9 -6
+5 -3
include/net/psample.h
··· 38 38 39 39 #if IS_ENABLED(CONFIG_PSAMPLE) 40 40 41 - void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, 42 - u32 sample_rate, const struct psample_metadata *md); 41 + void psample_sample_packet(struct psample_group *group, 42 + const struct sk_buff *skb, u32 sample_rate, 43 + const struct psample_metadata *md); 43 44 44 45 #else 45 46 46 47 static inline void psample_sample_packet(struct psample_group *group, 47 - struct sk_buff *skb, u32 sample_rate, 48 + const struct sk_buff *skb, 49 + u32 sample_rate, 48 50 const struct psample_metadata *md) 49 51 { 50 52 }
+4 -3
net/psample/psample.c
··· 360 360 } 361 361 #endif 362 362 363 - void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, 364 - u32 sample_rate, const struct psample_metadata *md) 363 + void psample_sample_packet(struct psample_group *group, 364 + const struct sk_buff *skb, u32 sample_rate, 365 + const struct psample_metadata *md) 365 366 { 366 367 ktime_t tstamp = ktime_get_real(); 367 368 int out_ifindex = md->out_ifindex; ··· 499 498 goto error; 500 499 501 500 if (md->rate_as_probability) 502 - nla_put_flag(skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY); 501 + nla_put_flag(nl_skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY); 503 502 504 503 genlmsg_end(nl_skb, data); 505 504 genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,