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

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 <michal.kubiak@intel.com>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Link: https://patch.msgid.link/20240704085710.353845-3-amorenoz@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Adrian Moreno and committed by
Jakub Kicinski
03448444 093b0f36

+12
+12
net/sched/act_sample.c
··· 167 167 { 168 168 struct tcf_sample *s = to_sample(a); 169 169 struct psample_group *psample_group; 170 + u8 cookie_data[TC_COOKIE_MAX_SIZE]; 170 171 struct psample_metadata md = {}; 172 + struct tc_cookie *user_cookie; 171 173 int retval; 172 174 173 175 tcf_lastuse_update(&s->tcf_tm); ··· 190 188 /* on ingress, the mac header gets popped, so push it back */ 191 189 if (skb_at_tc_ingress(skb) && tcf_sample_dev_ok_push(skb->dev)) 192 190 skb_push(skb, skb->mac_len); 191 + 192 + rcu_read_lock(); 193 + user_cookie = rcu_dereference(a->user_cookie); 194 + if (user_cookie) { 195 + memcpy(cookie_data, user_cookie->data, 196 + user_cookie->len); 197 + md.user_cookie = cookie_data; 198 + md.user_cookie_len = user_cookie->len; 199 + } 200 + rcu_read_unlock(); 193 201 194 202 md.trunc_size = s->truncate ? s->trunc_size : skb->len; 195 203 psample_sample_packet(psample_group, skb, s->rate, &md);