Re: [PATCH net-next v2 2/2] ipv6: preserve ip6mr_get_route() error in rt6_fill_node()

From: netdev-bot+sashiko

Date: Mon Nov 16 2026 - 08:55:15 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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] The patch does not deliver the 'actual failure reason' its
commit message promises.
- [Low] The patch fixes a user-visible wrong errno (RTM_GETROUTE returns
EMSGSIZE, 'Message too long', instead of the underlying…

--

ipv6: preserve ip6mr_get_route() error in rt6_fill_node()

With this patch, rt6_fill_node() returns the negative error from
ip6mr_get_route() to the caller. Before, it always returned -EMSGSIZE.
Attribute put failures still return -EMSGSIZE.

> Suggested-by: Hangbin Liu <liuhangbin@xxxxxxxxxx>
> Signed-off-by: Wenbo Sun <sunwenbo@xxxxxxxxxxxxxxxxxxxx>

[Severity: Low]
This fixes an errno that userspace can see, but there is no Fixes: tag.
It also isn't clear whether the patch is aimed at net or net-next.

The -EMSGSIZE that hides ip6mr_get_route() failures goes back to
commit 7bc570c8b4f75d ("[IPV6] MROUTE: Support multicast forwarding.").
Commit fd61c6ba313de6 ("net: ipv6: remove nowait arg to rt6_fill_node")
simplified that branch and kept it.

If this is meant for net, should it carry a Fixes: tag? If it is meant
as a net-next change to an errno visible to userspace, could the commit
message say so?

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index cb8cfd8b5c8b7..fc4f4c1cda583 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c

[ ... ]

> @@ -5864,12 +5865,14 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
> #ifdef CONFIG_IPV6_MROUTE
> if (ipv6_addr_is_multicast(&rt6_dst->addr) &&
> atomic_read(&net->ipv6.devconf_all->mc_forwarding)) {
> - int err = ip6mr_get_route(net, skb, rtm, portid);
> + int ret = ip6mr_get_route(net, skb, rtm, portid);
>
> - if (err == 0)
> + if (ret == 0)
> return 0;
> - if (err < 0)
> + if (ret < 0) {
> + err = ret;
> goto nla_put_failure;
> + }

[Severity: Medium]
Does this actually give userspace the real failure reason?

inet6_rtm_getroute() is the only caller that passes a non-zero iif. It
builds the reply skb without ever setting skb->dev:

net/ipv6/route.c:inet6_rtm_getroute() {
...
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
...
skb_dst_set(skb, &rt->dst);
...
}

With skb->dev NULL, ip6mr_get_route() skips the (*,G) lookup. It then
returns -ENODEV every time there is no (S,G) cache entry:

net/ipv6/ip6mr.c:ip6mr_get_route() {
...
cache = ip6mr_cache_find(mrt, &rt->rt6i_src.addr, &rt->rt6i_dst.addr);
if (!cache && skb->dev) {
...
if (!cache) {
...
dev = skb->dev;
if (!dev || (vif = ip6mr_find_vif(mrt, dev)) < 0) {
rcu_read_unlock();
return -ENODEV;
}
...
}

So when mc_forwarding is enabled, RTM_GETROUTE for any multicast (S,G)
with no MFC entry now fails with "No such device". This happens whether
or not the iif is a registered MIF. It also happens even though
inet6_rtm_getroute() has just found the device with
dev_get_by_index_rcu().

The "ip -6 route get ff0e::1 from 2001:db8::3 iif d0" test in the
commit message seems to show this case: the device d0 exists, but the
reply is still "No such device".

inet6_rtm_getroute() already returns the same errno when the iif
ifindex doesn't exist:

dev = dev_get_by_index_rcu(net, iif);
if (!dev) {
rcu_read_unlock();
err = -ENODEV;
goto errout;
}

Because of that, userspace can't tell a missing interface from a
missing multicast cache entry.

The commit message says:

"(for example -ENODEV, -ENOENT, -ENOMEM, or -ENOBUFS)"

-ENOMEM and -ENOBUFS only come from the alloc_skb() and
ip6mr_cache_unresolved() branch, and that branch needs a non-NULL
skb->dev. Can any caller reach them?

In practice the values that can occur look like:

-ENODEV
-ENOENT (no table, or mr_fill_mroute() on an unresolved entry)
-EMSGSIZE
-EINVAL (from the mr_fill_mroute() stub)

For comparison, inet_rtm_getroute() in net/ipv4/route.c does set the
device:

skb->dev = dev;

That lets ipmr_get_route() handle the (*,G) lookup and the unresolved
queue.

Should inet6_rtm_getroute() set skb->dev the same way? That would also
mean handling the async unresolved-queue path. Otherwise, should the
commit message be corrected, possibly with an extack message added?

> } else
> #endif
> if (nla_put_u32(skb, RTA_IIF, iif))

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112094630.197244-1-sunwenbo%40cmss.chinamobile.com