From: Hangbin Liu <hangbin.liu@linux.dev>
To: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
Cc: netdev-bot+sashiko@kernel.org, David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Hangbin Liu <liuhangbin@kylinos.cn>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
1342116488@qq.com
Subject: Re: [PATCH net-next v3 1/2] ipv6: check mc_forwarding before calling ip6mr_get_route()
Date: Mon, 23 Nov 2026 14:17:02 +0800 [thread overview]
Message-ID: <20261123061702.GJ10218@Liu-laptop> (raw)
In-Reply-To: <20261120032219.18091-1-sunwenbo@cmss.chinamobile.com>
On Fri, Nov 20, 2026 at 11:22:19AM +0800, Wenbo Sun wrote:
> Thank you for the detailed review on v3 1/2. We reproduced and verified each
> of the findings in a User-Mode Linux (UML) environment (`CONFIG_IPV6_MROUTE=y`)
> and prepared a focused single-patch v4 to address them:
>
> 1. Root-Cause Analysis & Local UML Reproduction of v3 1/2 Findings:
>
> Base UML topology:
> ip link add d0 type veth peer name d1
> ip link set d0 up && ip link set d1 up
> ip -6 addr add 2001:db8::2/64 dev d0
> ip -6 addr add ff0e::1 dev d0 autojoin
>
> (a) [High] Routable multicast query when mc_forwarding=1:
> In `inet6_rtm_getroute()`, `skb->dev` is never set on the newly
> allocated reply skb, and `ip6mr_get_route()` looks up
> `ip6mr_cache_find(mrt, &rt->rt6i_src.addr, &rt->rt6i_dst.addr)`, where
> `rt` is the per-CPU route copied from `f6i->fib6_dst` (`ff00::/8`).
> We reproduced this in UML by opening an `AF_INET6` `SOCK_RAW`
> (`IPPROTO_ICMPV6`) socket, enabling `MRT6_INIT`, registering `d0` via
> `MRT6_ADD_MIF`, and adding `(S=2001:db8::3, G=ff0e::1)` via
> `MRT6_ADD_MFC`:
> MRT6_ADD_MIF(mifi=0, pifi=3) OK
> MRT6_ADD_MFC(S=2001:db8::3, G=ff0e::1) OK
> mc_forwarding=1
> $ ip -6 route get ff0e::1 from 2001:db8::3 iif d0
> RTNETLINK answers: No such device
> ip_exit=512
> Because `ip6mr_get_route()` checks `(::, ff00::)` instead of the
> queried `(S,G)` and `skb->dev` is NULL, it misses even when the MFC
> entry exists. Making `mc_forwarding=1` MFC queries work requires
> passing `(src, dest)` and handling `skb->dev` / `skb_realloc_headroom()`
> across `inet6_rtm_getroute()` and `ip6mr_get_route()`, which we now
> explicitly state as out of scope in the commit message and drop patch
> 2/2 in v4 so we do not alter the uAPI errno to -ENODEV prematurely.
>
> (b) [Medium 1] Regression when a multicast query matches a non-multicast
> route (e.g. `::/0`):
> In v3, replacing `ipv6_addr_is_multicast(&rt6_dst->addr)` with
> `ipv6_addr_is_multicast(mc_dst)` caused queries matching a non-multicast
> FIB route (when `ff00::/8` is absent, such as on `lo`, an l3mdev
> master, or after deleting `ff00::/8`) to enter `ip6mr_get_route()` when
> `mc_forwarding=1`.
> Reproduced on v3 in UML:
> # ip -6 route del multicast ff00::/8 dev d0 table local
> # ip -6 route add ::/0 dev d0
> # (with MRT6_INIT / mc_forwarding=1):
> $ ip -6 route get ff0e::1 from 2001:db8::3 iif d0
> RTNETLINK answers: No such device
> ip_exit=512
>
> (c) [Medium 2] `RTM_F_FIB_MATCH` (`fibmatch`) missing link-local exclusion:
> In `inet6_rtm_getroute()`, the `fibmatch` branch calls `rt6_fill_node()`
> with `dst = NULL, dest = NULL`. In v3, `mc_dst` fell back to
> `&rt6_dst->addr` (`ff00::`, scope 0), so link-local `fibmatch` queries
> still entered `ip6mr_get_route()` when `mc_forwarding=1` (whereas IPv4
> `fibmatch` uses `fib_dump_info()` and never calls `ipmr_get_route()`).
> Reproduced on v3 in UML (with `MRT6_INIT` / `mc_forwarding=1`):
> $ ip -6 route get fibmatch ff02::1 from 2001:db8::3 iif d0
> RTNETLINK answers: No such device
> ip_exit=512
>
> (d) [Low] Fixes tag / net vs net-next:
> Because this patch aligns long-standing non-crash route-get reporting
> semantics with IPv4 (while full `mc_forwarding=1` MFC lookup in
> `ip6mr_get_route()` remains a separate effort), we keep targeting
> net-next without a Fixes tag, and have softened the commit message
> accordingly.
>
> 2. Concrete Fix in v4 & UML Verification Results:
>
> In v4, we converge the series into a single patch that checks `dest != NULL`
> (so `fibmatch` queries always emit the matched FIB6 entry and `RTA_IIF`),
> keeps `ipv6_addr_is_multicast(&rt6_dst->addr)` (avoiding the non-multicast
> route regression), and tests `ipv6_addr_type(dest)` against
> `(IPV6_ADDR_LOOPBACK | IPV6_ADDR_LINKLOCAL)`:
>
> if (dest && ipv6_addr_is_multicast(&rt6_dst->addr) &&
> !(ipv6_addr_type(dest) &
> (IPV6_ADDR_LOOPBACK | IPV6_ADDR_LINKLOCAL)) &&
> atomic_read(&net->ipv6.devconf_all->mc_forwarding))
>
> Verified on v4 in UML (`FAILURES=0, TEST_EXIT_CODE=0`):
> - Test 1 (`mc_forwarding=0`, `ff0e::1` with `iif d0`):
> `ff0e::1 dev d0 proto kernel metric 256 iif d0 pref medium` (PASS)
> - Test 2 (`mc_forwarding=1`, link-local `ff02::1` with `iif d0`):
> `multicast ff02::1 dev d0 proto kernel metric 256 iif d0 pref medium` (PASS)
> - Test 3 (`mc_forwarding=1`, interface-local `ff01::1` with `iif d0`):
> `multicast ff01::1 dev d0 proto kernel metric 256 iif d0 pref medium` (PASS)
> - Test 4 (`mc_forwarding=1`, `fibmatch` for `ff02::1` and `ff0e::1` with
> `iif d0`):
> `multicast ff00::/8 dev d0 table local proto kernel metric 256 iif d0 pref medium`
> (`ip_exit=0`, PASS)
> - Test 5 (`mc_forwarding=1`, `ff0e::1` matching `::/0` after removing
> `ff00::/8`):
> `ff0e::1 from 2001:db8::3 dev d0 proto boot src 2001:db8::2 metric 1024 iif d0 pref medium`
> (`ip_exit=0`, PASS)
> - Test 6 (IPv6 unicast with `iif`, IPv6 multicast without `iif`, IPv4
> multicast with `iif` regressions): all PASS.
>
> Thanks,
> Wenbo
>
I think it worth to add a selftest to cover these testings.
Thanks
Hangbin
next prev parent reply other threads:[~2026-11-23 6:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 1:47 [PATCH net-next v3 0/2] ipv6: fix rt6_fill_node() multicast route query handling Wenbo Sun
2026-11-16 1:47 ` [PATCH net-next v3 1/2] ipv6: check mc_forwarding before calling ip6mr_get_route() Wenbo Sun
2026-11-19 13:49 ` netdev-bot+sashiko
2026-11-20 3:22 ` Wenbo Sun
2026-11-23 6:17 ` Hangbin Liu [this message]
2026-11-16 1:47 ` [PATCH net-next v3 2/2] ipv6: preserve ip6mr_get_route() error in rt6_fill_node() Wenbo Sun
2026-11-19 13:49 ` netdev-bot+sashiko
2026-11-20 3:22 ` Wenbo Sun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123061702.GJ10218@Liu-laptop \
--to=hangbin.liu@linux.dev \
--cc=1342116488@qq.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@kylinos.cn \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sunwenbo@cmss.chinamobile.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®