Skip to content

Commit 0344844

Browse files
amorenozkuba-moo
authored andcommitted
net: sched: act_sample: add action cookie to sample
If the action has a user_cookie, pass it along to the sample so it can be easily identified. Reviewed-by: Michal Kubiak <[email protected]> Reviewed-by: Aaron Conole <[email protected]> Acked-by: Eelco Chaudron <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: Adrian Moreno <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 093b0f3 commit 0344844

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

net/sched/act_sample.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ TC_INDIRECT_SCOPE int tcf_sample_act(struct sk_buff *skb,
167167
{
168168
struct tcf_sample *s = to_sample(a);
169169
struct psample_group *psample_group;
170+
u8 cookie_data[TC_COOKIE_MAX_SIZE];
170171
struct psample_metadata md = {};
172+
struct tc_cookie *user_cookie;
171173
int retval;
172174

173175
tcf_lastuse_update(&s->tcf_tm);
@@ -189,6 +191,16 @@ TC_INDIRECT_SCOPE int tcf_sample_act(struct sk_buff *skb,
189191
if (skb_at_tc_ingress(skb) && tcf_sample_dev_ok_push(skb->dev))
190192
skb_push(skb, skb->mac_len);
191193

194+
rcu_read_lock();
195+
user_cookie = rcu_dereference(a->user_cookie);
196+
if (user_cookie) {
197+
memcpy(cookie_data, user_cookie->data,
198+
user_cookie->len);
199+
md.user_cookie = cookie_data;
200+
md.user_cookie_len = user_cookie->len;
201+
}
202+
rcu_read_unlock();
203+
192204
md.trunc_size = s->truncate ? s->trunc_size : skb->len;
193205
psample_sample_packet(psample_group, skb, s->rate, &md);
194206

0 commit comments

Comments
 (0)