Re: [PATCH v1 1/1] mctp: fix mctp_dump_addrinfo due to unincremented ifindex

From: Eric Dumazet
Date: Fri Jun 06 2025 - 13:24:33 EST


On Fri, Jun 6, 2025 at 9:28 AM Peter Yin <peteryin.openbmc@xxxxxxxxx> wrote:
>
> From: Peter Yin <peter.yin@xxxxxxxxxxxx>
>
> The mctp_dump_addrinfo() function uses mcb->ifindex to track resume
> progress when dumping MCTP device address information via netlink.
> However, if mcb->ifindex is not updated after each iteration,
> the dump restarts from the same net_device repeatedly, resulting
> in an infinite loop.
>
> This patch updates mcb->ifindex to dev->ifindex + 1 after
> a successful call to mctp_dump_dev_addrinfo(), ensuring that
> subsequent dump callbacks resume from the correct device.
>
> This fixes the netlink dump hang observed during sequential
> `ip mctp addr show` or similar operations.
>
> Fixes: 2d20773 ("mctp: no longer rely on net->dev_index_head[]")
> Signed-off-by: Peter Yin <peteryin.openbmc@xxxxxxxxx>
> ---
> net/mctp/device.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/mctp/device.c b/net/mctp/device.c
> index 4d404edd7446..ddde938c7123 100644
> --- a/net/mctp/device.c
> +++ b/net/mctp/device.c
> @@ -142,9 +142,9 @@ static int mctp_dump_addrinfo(struct sk_buff *skb, struct netlink_callback *cb)
> if (rc < 0)
> break;
> mcb->a_idx = 0;
> + mcb->ifindex = dev->ifindex+1;

I do not understand this patch.

for_each_netdev_dump() already has such an operation.