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: add user cookie

Add a user cookie to the sample metadata so that sample emitters can
provide more contextual information to samples.

If present, send the user cookie in a new attribute:
PSAMPLE_ATTR_USER_COOKIE.

Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Link: https://patch.msgid.link/20240704085710.353845-2-amorenoz@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Adrian Moreno and committed by
Jakub Kicinski
093b0f36 064fbc4e

+11 -1
+2
include/net/psample.h
··· 25 25 out_tc_occ_valid:1, 26 26 latency_valid:1, 27 27 unused:5; 28 + const u8 *user_cookie; 29 + u32 user_cookie_len; 28 30 }; 29 31 30 32 struct psample_group *psample_group_get(struct net *net, u32 group_num);
+1
include/uapi/linux/psample.h
··· 19 19 PSAMPLE_ATTR_LATENCY, /* u64, nanoseconds */ 20 20 PSAMPLE_ATTR_TIMESTAMP, /* u64, nanoseconds */ 21 21 PSAMPLE_ATTR_PROTO, /* u16 */ 22 + PSAMPLE_ATTR_USER_COOKIE, /* binary, user provided data */ 22 23 23 24 __PSAMPLE_ATTR_MAX 24 25 };
+8 -1
net/psample/psample.c
··· 386 386 nla_total_size(sizeof(u32)) + /* group_num */ 387 387 nla_total_size(sizeof(u32)) + /* seq */ 388 388 nla_total_size_64bit(sizeof(u64)) + /* timestamp */ 389 - nla_total_size(sizeof(u16)); /* protocol */ 389 + nla_total_size(sizeof(u16)) + /* protocol */ 390 + (md->user_cookie_len ? 391 + nla_total_size(md->user_cookie_len) : 0); /* user cookie */ 390 392 391 393 #ifdef CONFIG_INET 392 394 tun_info = skb_tunnel_info(skb); ··· 487 485 goto error; 488 486 } 489 487 #endif 488 + 489 + if (md->user_cookie && md->user_cookie_len && 490 + nla_put(nl_skb, PSAMPLE_ATTR_USER_COOKIE, md->user_cookie_len, 491 + md->user_cookie)) 492 + goto error; 490 493 491 494 genlmsg_end(nl_skb, data); 492 495 genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,