Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] In `devlink_nl_get_pre_dumpit()` (net/devlink/dev.c), `cb->min_dump_alloc` is set to the largest size estimate of any… -- devlink: make room for many nested instances in a dev message This commit sizes the DEVLINK_CMD_GET doit reply and the NEW/DEL notification so they include the handles of all nested devlink instances. For the dump, it adds a start callback that sets min_dump_alloc to the largest estimated message size among the instances. It also makes devlink dumps fail with -EMSGSIZE when an instance does not fit in an empty skb. Closes: https://lore.kernel.org/netdev/2026…@redhat.com
> diff --git a/net/devlink/dev.c b/net/devlink/dev.c > index b7e5aebf13be5..07fad82d9e1c1 100644 > --- a/net/devlink/dev.c > +++ b/net/devlink/dev.c > @@ -156,6 +156,21 @@ static int devlink_nl_nested_fill(struct sk_buff *msg, struct devlink *devlink) > return 0; > } > > +static size_t devlink_nl_dev_msg_size(struct devlink *devlink, size_t size) > +{ > + unsigned long rel_index; > + void *unused; > + > + xa_for_each(&devlink->nested_rels, rel_index, unused) > + size += devlink_rel_devlink_handle_size(rel_index); > + return size; > +} > + > +static size_t devlink_nl_dev_dump_size(struct devlink *devlink) > +{ > + return devlink_nl_dev_msg_size(devlink, 512); > +} > +
[ ... ]
> @@ -240,13 +257,34 @@ int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info) > return genlmsg_reply(msg, info); > } > > +int devlink_nl_get_pre_dumpit(struct netlink_callback *cb) > +{ > + struct net *net = sock_net(cb->skb->sk); > + struct devlink *devlink; > + unsigned long index; > + > + /* no instance lock, the size is only a hint for the first dump skb */ > + devlinks_xa_for_each_registered_get(net, index, devlink) { > + cb->min_dump_alloc = max(cb->min_dump_alloc, > + devlink_nl_dev_dump_size(devlink)); > + devlink_put(devlink); > + } > + return 0; > +}
[Severity: Medium] Can this make "devlink dev show" fail for readers with a page-sized buffer, in setups where it worked before this patch? min_dump_alloc ends up as the largest estimate over all instances in the netns. netlink_dump() then uses it for every skb of the dump, not only the first one: net/netlink/af_netlink.c:netlink_dump() { ... alloc_min_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE); max_recvmsg_len = READ_ONCE(nlk->max_recvmsg_len); if (alloc_min_size < max_recvmsg_len) { alloc_size = max_recvmsg_len; ... if (!skb) { alloc_size = alloc_min_size; ... skb_reserve(skb, skb_tailroom(skb) - alloc_size); ... } So once one instance's estimate goes over 4096, every dump skb is sized above a page. Each skb is packed with as many messages as fit, including skbs that only carry small instances with no nested devlinks. The estimate is also noticeably higher than what actually gets put. The 512 byte base in devlink_nl_dev_dump_size() is about 240 bytes more than the rest of the message (~270 bytes). devlink_nl_nested_handle_size() always counts a u64 DEVLINK_ATTR_INDEX and DEVLINK_ATTR_NETNS_ID. The put side looks like this: net/devlink/devl_internal.h:devlink_nl_put_handle() { ... if (nla_put_uint(msg, DEVLINK_ATTR_INDEX, devlink->index)) return -EMSGSIZE; ... } devlink->index is a u32, so it gets a 4 byte payload. devlink_nl_put_nested_handle() only adds the netns id when the netns differs. That is about 12 bytes of slack per same-netns handle. As a rough example, take an ice PF with about 70 SF devlinks ("auxiliary" and "ice.sf.N", about 44 bytes per handle). Its real message is about 272 + 44 * 70 = 3350 bytes, which even fit the old NLMSG_DEFAULT_SIZE buffer. Its estimate is about 512 + 56 * 70 = 4430 bytes. The SF instances are in the same netns, at about 250 bytes per message. So about 17 of them get packed into one 4430 byte skb, and iproute2 gets ENOSPC on the first recv. Before the patch, alloc_size was max_recvmsg_len (4096) and every message fit. Would it make sense to raise min_dump_alloc only for the skb that needs it? Or could the estimate be tightened so it does not cross a page when the real message does not? For the larger counts this patch targets (more than ~80 SFs, and later 256 VFs), the devlink_nl_get_doit() reply is now delivered, but it is larger than a page. So iproute2 gets ENOSPC instead of EMSGSIZE. The dump also now fails outright. Before, it listed the instances that come before the large one. Given the Closes: tag, should the commit message say that iproute2 still can't show these setups?
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40intel.com