From: Joe Damato jdamato@fastly.com
[ Upstream commit f71c549b26a33fd62f1e9c7deeba738bfc73fbfc ]
Previously, nsim_rcv was not marking the NAPI ID on the skb, leading to applications seeing a napi ID of 0 when using SO_INCOMING_NAPI_ID.
To add to the userland confusion, netlink appears to correctly report the NAPI IDs for netdevsim queues but the resulting file descriptor from a call to accept() was reporting a NAPI ID of 0.
Signed-off-by: Joe Damato jdamato@fastly.com Link: https://patch.msgid.link/20250424002746.16891-2-jdamato@fastly.com Signed-off-by: Jakub Kicinski kuba@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
Perfect! Now I fully understand the issue. The test at line 74-77 shows the exact problem: if `napi_id == 0`, it's considered a failure because SO_INCOMING_NAPI_ID should return a valid NAPI ID, not 0. Based on my comprehensive analysis, here's my assessment: **YES** ## Detailed Analysis This commit should be backported to stable kernel trees because it fixes a **critical functional bug** that affects userspace applications and testing infrastructure. ### **Root Cause Analysis** The commit addresses a missing `skb_mark_napi_id(skb, &rq->napi)` call in the `nsim_rcv()` function of the netdevsim driver. Here's what was happening: 1. **The Bug**: Before this fix, packets processed through `nsim_rcv()` did not have their NAPI ID properly marked on the skb structure 2. **The Impact**: When userspace applications called `getsockopt(SO_INCOMING_NAPI_ID)`, they received 0 instead of the actual NAPI ID 3. **The Flow**: ``` skb gets queued → nsim_rcv() processes it → skb->napi_id = 0 (not set) → netif_receive_skb() → protocol stack → sk_mark_napi_id(sk, skb) → sk->sk_napi_id = 0 → getsockopt(SO_INCOMING_NAPI_ID) returns 0 ``` ### **Why This Qualifies for Stable Backporting** #### **1. Functional Regression/Bug Fix** - **Clear Bug**: Missing `skb_mark_napi_id()` call causes SO_INCOMING_NAPI_ID to return invalid values - **Well-Defined Fix**: Single line addition that follows established patterns in other network drivers - **No Side Effects**: The change only adds the missing NAPI ID marking, with no architectural implications #### **2. Critical Infrastructure Impact** - **Testing Infrastructure**: netdevsim is the primary virtual driver for kernel networking tests - **CI/Testing Failure**: The included selftest `/linux/tools/testing/selftests/drivers/net/napi_id_helper.c` specifically fails when NAPI ID is 0 (lines 74-77) - **Broken SO_INCOMING_NAPI_ID**: This socket option is fundamental for busy polling and advanced networking applications #### **3. User-Visible Impact** - **Applications Broken**: Any userspace application using SO_INCOMING_NAPI_ID with netdevsim gets incorrect results - **Performance Tools**: Network performance testing and benchmarking tools that rely on NAPI ID information fail silently - **Silent Failure**: Applications don't crash but exhibit degraded performance or incorrect behavior #### **4. Meets Stable Criteria** - ✅ **Important bugfix**: Fixes broken SO_INCOMING_NAPI_ID functionality - ✅ **Small and contained**: Single line addition + header include - ✅ **No architectural changes**: Follows existing patterns in the codebase - ✅ **Minimal regression risk**: Only adds missing functionality, doesn't change existing behavior - ✅ **Clear impact**: Affects testing infrastructure and userspace applications #### **5. Code Pattern Consistency** Looking at the similar commit examples and other network drivers in the kernel tree, ALL proper NAPI implementations call `skb_mark_napi_id()` during packet reception. This fix brings netdevsim in line with established networking subsystem patterns. ### **Comparison with Similar Commits** This commit is most similar to **Similar Commit #4** which was marked for backporting because it fixed a functional bug in netdev-genl (missing RCU lock). Both: - Fix missing functionality in networking code - Have clear user-visible impact - Are small, contained changes - Address infrastructure/testing concerns ### **Conclusion** This is a clear **functional bug fix** that restores expected SO_INCOMING_NAPI_ID behavior in netdevsim. The fix is minimal, safe, and addresses a significant regression in testing infrastructure and userspace applications. It should definitely be backported to stable trees.
drivers/net/netdevsim/netdev.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index a41dc79e9c2e0..233f81f68014d 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -28,6 +28,7 @@ #include <net/pkt_cls.h> #include <net/rtnetlink.h> #include <net/udp_tunnel.h> +#include <net/busy_poll.h>
#include "netdevsim.h"
@@ -355,6 +356,7 @@ static int nsim_rcv(struct nsim_rq *rq, int budget) break;
skb = skb_dequeue(&rq->skb_queue); + skb_mark_napi_id(skb, &rq->napi); netif_receive_skb(skb); }