Message ID | 20240424135109.3524355-6-amorenoz@redhat.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: openvswitch: Add sample multicasting. | expand |
On Wed, Apr 24, 2024 at 03:50:52PM +0200, Adrian Moreno wrote: > If the action has a user_cookie, pass it along to the sample so it can > be easily identified. > > Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
On Wed, Apr 24, 2024 at 9:54 AM Adrian Moreno <amorenoz@redhat.com> wrote: > > If the action has a user_cookie, pass it along to the sample so it can > be easily identified. > > Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com> cheers, jamal > --- > net/sched/act_sample.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c > index a69b53d54039..5c3f86ec964a 100644 > --- a/net/sched/act_sample.c > +++ b/net/sched/act_sample.c > @@ -165,9 +165,11 @@ TC_INDIRECT_SCOPE int tcf_sample_act(struct sk_buff *skb, > const struct tc_action *a, > struct tcf_result *res) > { > + u8 cookie_data[TC_COOKIE_MAX_SIZE] = {}; > struct tcf_sample *s = to_sample(a); > struct psample_group *psample_group; > struct psample_metadata md = {}; > + struct tc_cookie *user_cookie; > int retval; > > tcf_lastuse_update(&s->tcf_tm); > @@ -189,6 +191,16 @@ TC_INDIRECT_SCOPE int tcf_sample_act(struct sk_buff *skb, > if (skb_at_tc_ingress(skb) && tcf_sample_dev_ok_push(skb->dev)) > skb_push(skb, skb->mac_len); > > + rcu_read_lock(); > + user_cookie = rcu_dereference(a->user_cookie); > + if (user_cookie) { > + memcpy(cookie_data, user_cookie->data, > + user_cookie->len); > + md.user_cookie = cookie_data; > + md.user_cookie_len = user_cookie->len; > + } > + rcu_read_unlock(); > + > md.trunc_size = s->truncate ? s->trunc_size : skb->len; > psample_sample_packet(psample_group, skb, s->rate, &md); > > -- > 2.44.0 >
diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index a69b53d54039..5c3f86ec964a 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -165,9 +165,11 @@ TC_INDIRECT_SCOPE int tcf_sample_act(struct sk_buff *skb, const struct tc_action *a, struct tcf_result *res) { + u8 cookie_data[TC_COOKIE_MAX_SIZE] = {}; struct tcf_sample *s = to_sample(a); struct psample_group *psample_group; struct psample_metadata md = {}; + struct tc_cookie *user_cookie; int retval; tcf_lastuse_update(&s->tcf_tm); @@ -189,6 +191,16 @@ TC_INDIRECT_SCOPE int tcf_sample_act(struct sk_buff *skb, if (skb_at_tc_ingress(skb) && tcf_sample_dev_ok_push(skb->dev)) skb_push(skb, skb->mac_len); + rcu_read_lock(); + user_cookie = rcu_dereference(a->user_cookie); + if (user_cookie) { + memcpy(cookie_data, user_cookie->data, + user_cookie->len); + md.user_cookie = cookie_data; + md.user_cookie_len = user_cookie->len; + } + rcu_read_unlock(); + md.trunc_size = s->truncate ? s->trunc_size : skb->len; psample_sample_packet(psample_group, skb, s->rate, &md);
If the action has a user_cookie, pass it along to the sample so it can be easily identified. Signed-off-by: Adrian Moreno <amorenoz@redhat.com> --- net/sched/act_sample.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)