diff mbox series

[net-next,v2] net: psample: fix flag being set in wrong skb

Message ID 20240710090742.1657606-1-amorenoz@redhat.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] net: psample: fix flag being set in wrong skb | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 18 this patch: 18
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 821 this patch: 821
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 828 this patch: 828
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Adrián Moreno July 10, 2024, 9:07 a.m. UTC
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.

Also modify OVS psample test to verify the flag is properly emitted.

Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 include/net/psample.h | 8 +++++---
 net/psample/psample.c | 7 ++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

Comments

Eelco Chaudron July 10, 2024, 9:17 a.m. UTC | #1
On 10 Jul 2024, at 11:07, Adrian Moreno wrote:

> 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.
>
> Also modify OVS psample test to verify the flag is properly emitted.
>
> Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>

Thank you for fixing this so quickly. The change looks good, and I've verified it with the OVS userspace part.

Acked-by: Eelco Chaudron <echaudro@redhat.com>

Cheers,

Eelco
Antoine Tenart July 10, 2024, 1:30 p.m. UTC | #2
Hi Adrián,

Quoting Adrian Moreno (2024-07-10 11:07:42)
> 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.
> 
> Also modify OVS psample test to verify the flag is properly emitted.

I don't see that part; although it can be sent as a follow-up and not
part of the fix.

Thanks,
Antoine

> Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> ---
>  include/net/psample.h | 8 +++++---
>  net/psample/psample.c | 7 ++++---
>  2 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/include/net/psample.h b/include/net/psample.h
> index c52e9ebd88dd..5071b5fc2b59 100644
> --- a/include/net/psample.h
> +++ b/include/net/psample.h
> @@ -38,13 +38,15 @@ struct sk_buff;
>  
>  #if IS_ENABLED(CONFIG_PSAMPLE)
>  
> -void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> -                          u32 sample_rate, const struct psample_metadata *md);
> +void psample_sample_packet(struct psample_group *group,
> +                          const struct sk_buff *skb, u32 sample_rate,
> +                          const struct psample_metadata *md);
>  
>  #else
>  
>  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)
>  {
>  }
> diff --git a/net/psample/psample.c b/net/psample/psample.c
> index f48b5b9cd409..a0ddae8a65f9 100644
> --- a/net/psample/psample.c
> +++ b/net/psample/psample.c
> @@ -360,8 +360,9 @@ static int psample_tunnel_meta_len(struct ip_tunnel_info *tun_info)
>  }
>  #endif
>  
> -void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> -                          u32 sample_rate, const struct psample_metadata *md)
> +void psample_sample_packet(struct psample_group *group,
> +                          const struct sk_buff *skb, u32 sample_rate,
> +                          const struct psample_metadata *md)
>  {
>         ktime_t tstamp = ktime_get_real();
>         int out_ifindex = md->out_ifindex;
> @@ -498,7 +499,7 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
>                 goto error;
>  
>         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_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,
> -- 
> 2.45.2
> 
>
Adrián Moreno July 10, 2024, 1:51 p.m. UTC | #3
On Wed, Jul 10, 2024 at 03:30:14PM GMT, Antoine Tenart wrote:
> Hi Adrián,
>
> Quoting Adrian Moreno (2024-07-10 11:07:42)
> > 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.
> >
> > Also modify OVS psample test to verify the flag is properly emitted.
>
> I don't see that part; although it can be sent as a follow-up and not
> part of the fix.

Yep. Sorry I was planning to add it to the fix but thought it was better
off as a follow-up. I should have removed this comment.

>
> Thanks,
> Antoine
>
> > Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
> > Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> > ---
> >  include/net/psample.h | 8 +++++---
> >  net/psample/psample.c | 7 ++++---
> >  2 files changed, 9 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/net/psample.h b/include/net/psample.h
> > index c52e9ebd88dd..5071b5fc2b59 100644
> > --- a/include/net/psample.h
> > +++ b/include/net/psample.h
> > @@ -38,13 +38,15 @@ struct sk_buff;
> >
> >  #if IS_ENABLED(CONFIG_PSAMPLE)
> >
> > -void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> > -                          u32 sample_rate, const struct psample_metadata *md);
> > +void psample_sample_packet(struct psample_group *group,
> > +                          const struct sk_buff *skb, u32 sample_rate,
> > +                          const struct psample_metadata *md);
> >
> >  #else
> >
> >  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)
> >  {
> >  }
> > diff --git a/net/psample/psample.c b/net/psample/psample.c
> > index f48b5b9cd409..a0ddae8a65f9 100644
> > --- a/net/psample/psample.c
> > +++ b/net/psample/psample.c
> > @@ -360,8 +360,9 @@ static int psample_tunnel_meta_len(struct ip_tunnel_info *tun_info)
> >  }
> >  #endif
> >
> > -void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> > -                          u32 sample_rate, const struct psample_metadata *md)
> > +void psample_sample_packet(struct psample_group *group,
> > +                          const struct sk_buff *skb, u32 sample_rate,
> > +                          const struct psample_metadata *md)
> >  {
> >         ktime_t tstamp = ktime_get_real();
> >         int out_ifindex = md->out_ifindex;
> > @@ -498,7 +499,7 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> >                 goto error;
> >
> >         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_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,
> > --
> > 2.45.2
> >
> >
>
Adrián Moreno July 10, 2024, 1:54 p.m. UTC | #4
On Wed, Jul 10, 2024 at 01:51:59PM GMT, Adrián Moreno wrote:
> On Wed, Jul 10, 2024 at 03:30:14PM GMT, Antoine Tenart wrote:
> > Hi Adrián,
> >
> > Quoting Adrian Moreno (2024-07-10 11:07:42)
> > > 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.
> > >
> > > Also modify OVS psample test to verify the flag is properly emitted.
> >
> > I don't see that part; although it can be sent as a follow-up and not
> > part of the fix.
>
> Yep. Sorry I was planning to add it to the fix but thought it was better
> off as a follow-up. I should have removed this comment.
>

I'll resend the series without that comment.

> >
> > Thanks,
> > Antoine
> >
> > > Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
> > > Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> > > ---
> > >  include/net/psample.h | 8 +++++---
> > >  net/psample/psample.c | 7 ++++---
> > >  2 files changed, 9 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/include/net/psample.h b/include/net/psample.h
> > > index c52e9ebd88dd..5071b5fc2b59 100644
> > > --- a/include/net/psample.h
> > > +++ b/include/net/psample.h
> > > @@ -38,13 +38,15 @@ struct sk_buff;
> > >
> > >  #if IS_ENABLED(CONFIG_PSAMPLE)
> > >
> > > -void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> > > -                          u32 sample_rate, const struct psample_metadata *md);
> > > +void psample_sample_packet(struct psample_group *group,
> > > +                          const struct sk_buff *skb, u32 sample_rate,
> > > +                          const struct psample_metadata *md);
> > >
> > >  #else
> > >
> > >  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)
> > >  {
> > >  }
> > > diff --git a/net/psample/psample.c b/net/psample/psample.c
> > > index f48b5b9cd409..a0ddae8a65f9 100644
> > > --- a/net/psample/psample.c
> > > +++ b/net/psample/psample.c
> > > @@ -360,8 +360,9 @@ static int psample_tunnel_meta_len(struct ip_tunnel_info *tun_info)
> > >  }
> > >  #endif
> > >
> > > -void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> > > -                          u32 sample_rate, const struct psample_metadata *md)
> > > +void psample_sample_packet(struct psample_group *group,
> > > +                          const struct sk_buff *skb, u32 sample_rate,
> > > +                          const struct psample_metadata *md)
> > >  {
> > >         ktime_t tstamp = ktime_get_real();
> > >         int out_ifindex = md->out_ifindex;
> > > @@ -498,7 +499,7 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> > >                 goto error;
> > >
> > >         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_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,
> > > --
> > > 2.45.2
> > >
> > >
> >
Adrián Moreno July 10, 2024, 1:55 p.m. UTC | #5
On Wed, Jul 10, 2024 at 01:54:58PM GMT, Adrián Moreno wrote:
> On Wed, Jul 10, 2024 at 01:51:59PM GMT, Adrián Moreno wrote:
> > On Wed, Jul 10, 2024 at 03:30:14PM GMT, Antoine Tenart wrote:
> > > Hi Adrián,
> > >
> > > Quoting Adrian Moreno (2024-07-10 11:07:42)
> > > > 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.
> > > >
> > > > Also modify OVS psample test to verify the flag is properly emitted.
> > >
> > > I don't see that part; although it can be sent as a follow-up and not
> > > part of the fix.
> >
> > Yep. Sorry I was planning to add it to the fix but thought it was better
> > off as a follow-up. I should have removed this comment.
> >
>
> I'll resend the series without that comment.
>

s/series/patch

> > >
> > > Thanks,
> > > Antoine
> > >
> > > > Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
> > > > Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> > > > ---
> > > >  include/net/psample.h | 8 +++++---
> > > >  net/psample/psample.c | 7 ++++---
> > > >  2 files changed, 9 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/include/net/psample.h b/include/net/psample.h
> > > > index c52e9ebd88dd..5071b5fc2b59 100644
> > > > --- a/include/net/psample.h
> > > > +++ b/include/net/psample.h
> > > > @@ -38,13 +38,15 @@ struct sk_buff;
> > > >
> > > >  #if IS_ENABLED(CONFIG_PSAMPLE)
> > > >
> > > > -void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> > > > -                          u32 sample_rate, const struct psample_metadata *md);
> > > > +void psample_sample_packet(struct psample_group *group,
> > > > +                          const struct sk_buff *skb, u32 sample_rate,
> > > > +                          const struct psample_metadata *md);
> > > >
> > > >  #else
> > > >
> > > >  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)
> > > >  {
> > > >  }
> > > > diff --git a/net/psample/psample.c b/net/psample/psample.c
> > > > index f48b5b9cd409..a0ddae8a65f9 100644
> > > > --- a/net/psample/psample.c
> > > > +++ b/net/psample/psample.c
> > > > @@ -360,8 +360,9 @@ static int psample_tunnel_meta_len(struct ip_tunnel_info *tun_info)
> > > >  }
> > > >  #endif
> > > >
> > > > -void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> > > > -                          u32 sample_rate, const struct psample_metadata *md)
> > > > +void psample_sample_packet(struct psample_group *group,
> > > > +                          const struct sk_buff *skb, u32 sample_rate,
> > > > +                          const struct psample_metadata *md)
> > > >  {
> > > >         ktime_t tstamp = ktime_get_real();
> > > >         int out_ifindex = md->out_ifindex;
> > > > @@ -498,7 +499,7 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> > > >                 goto error;
> > > >
> > > >         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_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,
> > > > --
> > > > 2.45.2
> > > >
> > > >
> > >
diff mbox series

Patch

diff --git a/include/net/psample.h b/include/net/psample.h
index c52e9ebd88dd..5071b5fc2b59 100644
--- a/include/net/psample.h
+++ b/include/net/psample.h
@@ -38,13 +38,15 @@  struct sk_buff;
 
 #if IS_ENABLED(CONFIG_PSAMPLE)
 
-void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
-			   u32 sample_rate, const struct psample_metadata *md);
+void psample_sample_packet(struct psample_group *group,
+			   const struct sk_buff *skb, u32 sample_rate,
+			   const struct psample_metadata *md);
 
 #else
 
 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)
 {
 }
diff --git a/net/psample/psample.c b/net/psample/psample.c
index f48b5b9cd409..a0ddae8a65f9 100644
--- a/net/psample/psample.c
+++ b/net/psample/psample.c
@@ -360,8 +360,9 @@  static int psample_tunnel_meta_len(struct ip_tunnel_info *tun_info)
 }
 #endif
 
-void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
-			   u32 sample_rate, const struct psample_metadata *md)
+void psample_sample_packet(struct psample_group *group,
+			   const struct sk_buff *skb, u32 sample_rate,
+			   const struct psample_metadata *md)
 {
 	ktime_t tstamp = ktime_get_real();
 	int out_ifindex = md->out_ifindex;
@@ -498,7 +499,7 @@  void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
 		goto error;
 
 	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_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,