Re: [PATCH net-next v2 04/10] devlink: allow to use devlink index as a command handle

From
Jiri Pirko <jiri@resnulli.us>
Date
2026-03-02 10:23:21
Also in
linux-doc, linux-rdma, netdev
Reply to
Jakub Kicinski, 2026-02-28
Sat, Feb 28, 2026 at 11:48:46PM +0100, kuba@kernel.org wrote:
On Wed, 25 Feb 2026 14:34:16 +0100 Jiri Pirko wrote:
quoted
+	if (attrs[DEVLINK_ATTR_INDEX]) {
+		index = nla_get_uint(attrs[DEVLINK_ATTR_INDEX]);
+		devlink = devlinks_xa_lookup_get(net, index);
+		if (!devlink)
+			return ERR_PTR(-ENODEV);
+		goto found;
+	}
+
 	if (!attrs[DEVLINK_ATTR_BUS_NAME] || !attrs[DEVLINK_ATTR_DEV_NAME])
 		return ERR_PTR(-EINVAL);
If both INDEX and BUS_NAME + DEV_NAME are provided we should check
that they point to the same device? Or reject user space passing both?
I implemented reject. I don't see much of value of allowing both. The
code that would do the checking is too much for this hypothetical case.
Thread (21 messages) 21 messages, 2 authors, last reply 2026-03-02
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help