linux/net/devlink
David Yang f1e13d23e0 devlink: Warn on resource ID collision with PARENT_TOP
ID 0 serves as the sentinel DEVLINK_RESOURCE_ID_PARENT_TOP to mark
top-level resources. While it is technically possible to use 0 as a real
resource ID, a user might be tempted to write:

enum {
    MY_RESOURCE_ID_A,  /* == DEVLINK_RESOURCE_ID_PARENT_TOP ! */
    MY_RESOURCE_ID_B,
    MY_RESOURCE_ID_C,
    MY_RESOURCE_ID_D,
    ...
};

register(..., MY_RESOURCE_ID_C, DEVLINK_RESOURCE_ID_PARENT_TOP, ...);
register(..., MY_RESOURCE_ID_D, MY_RESOURCE_ID_C, ...);
/* D is a child of C */

register(..., MY_RESOURCE_ID_A, DEVLINK_RESOURCE_ID_PARENT_TOP, ...);
register(..., MY_RESOURCE_ID_B, MY_RESOURCE_ID_A, ...);
/* Is B intentionally top-level, or is it actually a child of A? */

Add a WARN_ON() to catch this and prevent confusion.

Signed-off-by: David Yang <mmyangfl@gmail.com>
Link: https://patch.msgid.link/20260611070856.889700-6-mmyangfl@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-15 12:41:41 -07:00
..
core.c devlink: Release nested relation on devlink free 2026-06-01 19:54:52 -07:00
dev.c devlink: allow devlink instance allocation without a backing device 2026-03-14 13:08:49 -07:00
devl_internal.h devlink: Include port resources in resource dump dumpit 2026-04-08 19:55:38 -07:00
dpipe.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
health.c devlink: Fix incorrect skb socket family dumping 2026-04-08 19:34:38 -07:00
linecard.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
Makefile devlink: introduce shared devlink instance for PFs on same chip 2026-03-14 13:08:50 -07:00
netlink_gen.c devlink: Implement devlink param multi attribute nested data values 2026-06-13 16:16:58 -07:00
netlink_gen.h devlink: Add port-specific option to resource dump doit 2026-04-08 19:55:39 -07:00
netlink.c devlink: Include port resources in resource dump dumpit 2026-04-08 19:55:38 -07:00
param.c devlink: Implement devlink param multi attribute nested data values 2026-06-13 16:16:58 -07:00
port.c devlink: Add port-level resource registration infrastructure 2026-04-08 19:55:38 -07:00
rate.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
region.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
resource.c devlink: Warn on resource ID collision with PARENT_TOP 2026-06-15 12:41:41 -07:00
sb.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
sh_dev.c devlink: introduce shared devlink instance for PFs on same chip 2026-03-14 13:08:50 -07:00
trap.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00