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: validate skb->napi_id in RX tracepoints

Since commit 2bd82484bb4c ("xps: fix xps for stacked devices"),
skb->napi_id shares storage with sender_cpu. RX tracepoints using
net_dev_rx_verbose_template read skb->napi_id directly and can therefore
report sender_cpu values as if they were NAPI IDs.

For example, on the loopback path this can report 1 as napi_id, where 1
comes from raw_smp_processor_id() + 1 in the XPS path:

# bpftrace -e 'tracepoint:net:netif_rx_entry{ print(args->napi_id); }'
# taskset -c 0 ping -c 1 ::1

Report only valid NAPI IDs in these tracepoints and use 0 otherwise.

Fixes: 2bd82484bb4c ("xps: fix xps for stacked devices")
Signed-off-by: Kohei Enju <kohei@enjuk.jp>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20260420105427.162816-1-kohei@enjuk.jp
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kohei Enju and committed by
Jakub Kicinski
3bfcf396 478ed6b7

+3 -1
+3 -1
include/trace/events/net.h
··· 10 10 #include <linux/if_vlan.h> 11 11 #include <linux/ip.h> 12 12 #include <linux/tracepoint.h> 13 + #include <net/busy_poll.h> 13 14 14 15 TRACE_EVENT(net_dev_start_xmit, 15 16 ··· 209 208 TP_fast_assign( 210 209 __assign_str(name); 211 210 #ifdef CONFIG_NET_RX_BUSY_POLL 212 - __entry->napi_id = skb->napi_id; 211 + __entry->napi_id = napi_id_valid(skb->napi_id) ? 212 + skb->napi_id : 0; 213 213 #else 214 214 __entry->napi_id = 0; 215 215 #endif