]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: don't dump Tx and uninitialized NAPIs
authorJakub Kicinski <kuba@kernel.org>
Fri, 3 Jan 2025 18:32:07 +0000 (10:32 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 7 Jan 2025 12:07:31 +0000 (13:07 +0100)
We use NAPI ID as the key for continuing dumps. We also depend
on the NAPIs being sorted by ID within the driver list. Tx NAPIs
(which don't have an ID assigned) break this expectation, it's
not currently possible to dump them reliably. Since Tx NAPIs
are relatively rare, and can't be used in doit (GET or SET)
hide them from the dump API as well.

Fixes: 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20250103183207.1216004-1-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/core/netdev-genl.c

index b0772d135efbe7fb9817990073376089cfa91950..125b660004d38ffe3175422c033acd5e4cbffa03 100644 (file)
@@ -176,8 +176,7 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi,
        if (!hdr)
                return -EMSGSIZE;
 
-       if (napi->napi_id >= MIN_NAPI_ID &&
-           nla_put_u32(rsp, NETDEV_A_NAPI_ID, napi->napi_id))
+       if (nla_put_u32(rsp, NETDEV_A_NAPI_ID, napi->napi_id))
                goto nla_put_failure;
 
        if (nla_put_u32(rsp, NETDEV_A_NAPI_IFINDEX, napi->dev->ifindex))
@@ -272,6 +271,8 @@ netdev_nl_napi_dump_one(struct net_device *netdev, struct sk_buff *rsp,
                return err;
 
        list_for_each_entry(napi, &netdev->napi_list, dev_list) {
+               if (napi->napi_id < MIN_NAPI_ID)
+                       continue;
                if (ctx->napi_id && napi->napi_id >= ctx->napi_id)
                        continue;