Skip to content

Commit af3525d

Browse files
committed
net: warn during dump if NAPI list is not sorted
Dump continuation depends on the NAPI list being sorted. Broken netlink dump continuation may be rare and hard to debug so add a warning if we notice the potential problem while walking the list. Reviewed-by: Michal Swiatkowski <[email protected]> Reviewed-by: Joe Damato <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 460b528 commit af3525d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

net/core/netdev-genl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,21 @@ netdev_nl_napi_dump_one(struct net_device *netdev, struct sk_buff *rsp,
263263
struct netdev_nl_dump_ctx *ctx)
264264
{
265265
struct napi_struct *napi;
266+
unsigned int prev_id;
266267
int err = 0;
267268

268269
if (!(netdev->flags & IFF_UP))
269270
return err;
270271

272+
prev_id = UINT_MAX;
271273
list_for_each_entry(napi, &netdev->napi_list, dev_list) {
272274
if (napi->napi_id < MIN_NAPI_ID)
273275
continue;
276+
277+
/* Dump continuation below depends on the list being sorted */
278+
WARN_ON_ONCE(napi->napi_id >= prev_id);
279+
prev_id = napi->napi_id;
280+
274281
if (ctx->napi_id && napi->napi_id >= ctx->napi_id)
275282
continue;
276283

0 commit comments

Comments
 (0)