When CONFIG_IPV6_MROUTE is enabled, rt6_fill_node() calls ip6mr_get_route() whenever an input interface is specified and the destination address is multicast. However, when multicast routing is not enabled in the network namespace (i.e. mc_forwarding is 0), there is typically no matching (S,G) multicast routing cache entry, and skb->dev is NULL in the query skb allocated by inet6_rtm_getroute(). As a result, ip6mr_get_route() returns -ENODEV, which causes rt6_fill_node() to jump to nla_put_failure and report -EMSGSIZE ("RTNETLINK answers: Message too long") to userspace. In contrast, the IPv4 counterpart rt_fill_info() checks IPV4_DEVCONF_ALL_RO(net, MC_FORWARDING) before calling ipmr_get_route(), so queries with mc_forwarding disabled fall back to emitting RTA_IIF and normal route attributes. This discrepancy was identified with the assistance of an LLM-based code review comparing IPv4 and IPv6 multicast route get handling, confirmed on a UML kernel where "ip -6 route get from iif " returned -EMSGSIZE on an unpatched kernel, and verified after the change that multicast route get with iif succeeds while unicast and non-iif multicast queries continue to work as expected. Check atomic_read(&net->ipv6.devconf_all->mc_forwarding) before calling ip6mr_get_route() in rt6_fill_node() so that queries with multicast forwarding disabled report RTA_IIF and normal route attributes, matching IPv4 behavior. Built with W=1 on UML, x86_64 allmodconfig, and x86_64 allyesconfig with zero new warnings or errors. Signed-off-by: Wenbo Sun Reviewed-by: Hangbin Liu --- net/ipv6/route.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 2eb884558c24..6dd4a70f6490 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -5862,7 +5862,8 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb, #endif if (iif) { #ifdef CONFIG_IPV6_MROUTE - if (ipv6_addr_is_multicast(&rt6_dst->addr)) { + 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); if (err == 0) -- 2.33.0