* Re: [PATCH] ipv6: addrconf: regenerate missing host route on RTM_NEWADDR
2026-11-18 6:28 [PATCH] ipv6: addrconf: regenerate missing host route on RTM_NEWADDR Shuai Liu
@ 2026-11-22 6:52 ` netdev-bot+sashiko
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-11-22 6:52 UTC (permalink / raw)
To: 847807867
Cc: netdev, dsahern, idosch, edumazet, davem, kuba, pabeni, horms,
syzbot+af16ddc8fd22a1d135f8
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 3
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).
- [High] The patch leaves the root cause named in its own commit message
unfixed.
- [Medium] ipv6: addrconf: __ipv6_ifa_notify() inserts routes while IPv6
is stopped
- [Low] The commit message says the patch will "regenerate the host route
with fixup_permanent_addr()".
- [Low] The two callers of fixup_permanent_addr() handle its failure
differently.
- [Low] The new call in __ipv6_ifa_notify() does not check
IFA_F_PERMANENT before calling fixup_permanent_addr().
--
ipv6: addrconf: regenerate missing host route on RTM_NEWADDR
This patch changes RTM_NEWADDR handling in __ipv6_ifa_notify(). When an
address on an up device has no ifp->rt, the host route is now regenerated
with fixup_permanent_addr() instead of only printing a warning. It targets
addresses kept by keep_addr_on_down after addrconf_ifdown() ran because
the MTU dropped below IPV6_MIN_MTU.
Closes: https://syzkaller.appspot.com/bug?extid=af16ddc8fd22a1d135f8
> Instead of only warning, regenerate the host route with
> fixup_permanent_addr() when RTM_NEWADDR arrives for an address
> without ifp->rt on an up device, keeping the warning only for the
> allocation failure case.
[Severity: Low]
This isn't a bug, but fixup_permanent_addr() does more than regenerate
the host route:
net/ipv6/addrconf.c:fixup_permanent_addr() {
...
if (!(ifp->flags & IFA_F_NOPREFIXROUTE)) {
addrconf_prefix_route(&ifp->addr, ifp->prefix_len,
ifp->rt_priority, idev->dev, 0, 0,
GFP_KERNEL);
}
if (ifp->state == INET6_IFADDR_STATE_PREDAD)
addrconf_dad_start(ifp);
...
}
Could the commit message say that RTM_NEWADDR handling can now install a
non-expiring prefix route and start DAD for PREDAD addresses? It could
also mention that the failure handling here differs from
addrconf_permanent_addr(), which deletes the address when the fixup
fails.
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 4b0cb7d23541d..70230ffdc077f 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -6357,17 +6357,17 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
[ ... ]
> - if (ifp->rt && !rcu_access_pointer(ifp->rt->fib6_node)) {
> - ip6_ins_rt(net, ifp->rt);
> - } else if (!ifp->rt && (ifp->idev->dev->flags & IFF_UP)) {
> - pr_warn("BUG: Address %pI6c on device %s is missing its host route.\n",
> - &ifp->addr, ifp->idev->dev->name);
> + if (!ifp->rt && (ifp->idev->dev->flags & IFF_UP)) {
[Severity: Medium]
Can this reinstall routes on an interface where IPv6 has been stopped?
The only check here is IFF_UP. addrconf_ifdown(dev, false) can stop
IPv6 on lo while lo stays IFF_UP. That happens when the MTU drops
below IPV6_MIN_MTU in the NETDEV_CHANGEMTU case, or when lo comes up
with a too small MTU in the NETDEV_UP case.
In that state rt6_disable_ip() has flushed the routes and IF_READY is
cleared. Kept addresses are left in PREDAD with ifp->rt == NULL.
addrconf_ifdown() only calls addrconf_del_dad_work(). That uses
cancel_delayed_work(), which does not wait for a dad_work item that is
already running and blocked on rtnl_net_lock().
On NETDEV_UP for lo, addrconf_permanent_addr() calls
fixup_permanent_addr(), and addrconf_dad_start() queues such a work
item. This happens before the MTU check calls addrconf_ifdown(). The
NETDEV_CHANGEMTU path can race with a pending dad_work in the same
way.
Once the lock is released, addrconf_dad_work() sees PREDAD and calls
addrconf_dad_begin(). The early completion branch runs before the
!(idev->if_flags & IF_READY) check. It is taken for IFF_LOOPBACK or
IFF_NOARP devices, for IFA_F_NODAD addresses, and when accept_dad is
below 1. The resulting call chain is:
addrconf_dad_begin()
addrconf_dad_completed()
ipv6_ifa_notify(RTM_NEWADDR, ifp)
__ipv6_ifa_notify()
fixup_permanent_addr()
ip6_ins_rt()
Before this patch that sequence only printed the warning. With the
patch, doesn't it allocate a new host route and insert it together
with a prefix route? The device's MTU is still below IPV6_MIN_MTU and
its idev is not IF_READY. As far as I can see, nothing removes these
routes until the next addrconf_ifdown(). The prefix route is also the
non-expiring one from fixup_permanent_addr(), even if the address has
since been given a finite lifetime.
Should the regeneration also require IF_READY on ifp->idev? Or should
addrconf_dad_begin() bail out for a !IF_READY idev before it takes
the early completion branch?
[Severity: High]
The commit message says recovery "never happens when IPv6 is stopped
through the NETDEV_CHANGEMTU path", but this change doesn't touch that
path. Is the kept address recovered when the MTU is restored? Or does
recovery only happen if some later event produces RTM_NEWADDR for it?
The keep path in addrconf_ifdown() leaves the address like this:
net/ipv6/addrconf.c:addrconf_ifdown() {
...
ifa->state = INET6_IFADDR_STATE_PREDAD;
if (!(ifa->flags & IFA_F_NODAD))
ifa->flags |= IFA_F_TENTATIVE;
rt = ifa->rt;
ifa->rt = NULL;
...
}
IF_READY is cleared as well, and rt6_disable_ip() has already flushed
the host and prefix routes.
When the MTU goes back to IPV6_MIN_MTU or above, the NETDEV_CHANGEMTU
case in addrconf_notify() finds the existing idev and only does this:
if (idev) {
rt6_mtu_change(dev, dev->mtu);
WRITE_ONCE(idev->cnf.mtu6, dev->mtu);
break;
}
A later NETDEV_CHANGE that takes the idev from !IF_READY to IF_READY
only calls addrconf_dad_run(idev, false). That call skips PREDAD
addresses:
if ((ifp->flags & IFA_F_TENTATIVE &&
ifp->state == INET6_IFADDR_STATE_DAD) || restart) {
So the only way to reach the new fixup_permanent_addr() call seems to be
addrconf_dad_run(idev, true). That needs an IFF_NOARP change while
IF_READY is already set, which is the second toggle in the syzbot
reproducer.
Without that toggle, wouldn't every permanent address kept across the
MTU dip stay tentative, with no host route and no prefix route, until lo
is brought down and up or disable_ipv6 is toggled? This only needs
CAP_NET_ADMIN in a netns: set keep_addr_on_down, drop lo's MTU below
1280, then restore it.
Would it be better to restore the kept permanent addresses in the
NETDEV_CHANGEMTU path when the MTU returns on an idev that
addrconf_ifdown() stopped? That would mean addrconf_permanent_addr()
plus the IF_READY and DAD handling, instead of recovering from
__ipv6_ifa_notify().
> + if (fixup_permanent_addr(net, ifp->idev, ifp))
[Severity: Low]
Should this also check IFA_F_PERMANENT? The only other caller,
addrconf_permanent_addr(), passes only permanent addresses:
if (ifp->flags & IFA_F_PERMANENT)
list_add_tail(&ifp->if_list_aux, &tmp_addr_list);
and fixup_permanent_addr() installs the prefix route with expires set
to 0.
A kept address with rt == NULL can lose IFA_F_PERMANENT before
RTM_NEWADDR fires:
1. A permanent address on lo is kept across an MTU dip, so rt is NULL
and the state is PREDAD.
2. ip -6 addr change ... valid_lft N preferred_lft N runs.
inet6_rtm_newaddr() clears IFA_F_PERMANENT, and inet6_addr_modify()
re-adds the prefix route with RTF_EXPIRES. The address is tentative,
so no notify is sent and rt stays NULL.
3. An IFF_NOARP toggle while IF_READY is set restarts DAD:
addrconf_dad_completed()->__ipv6_ifa_notify()->fixup_permanent_addr()
4. addrconf_prefix_route(..., 0, 0) then hits the duplicate route branch
in fib6_add_rt2node():
if (!(rt->fib6_flags & RTF_EXPIRES)) {
fib6_clean_expires(iter);
fib6_may_remove_gc_list(info->nl_net, iter);
...
Doesn't this make the prefix route of a finite-lifetime address
non-expiring? The route is still removed when the address is deleted or
expires, so only the route lifetime is wrong.
> + pr_warn("BUG: Address %pI6c on device %s is missing its host route.\n",
> + &ifp->addr, ifp->idev->dev->name);
[Severity: Low]
Here, fixup_permanent_addr() can only fail when addrconf_f6i_alloc()
fails, because addrconf_prefix_route() returns void. Does an allocation
failure still warrant a message that starts with "BUG:" and is not
ratelimited?
The other caller handles the same failure differently:
net/ipv6/addrconf.c:addrconf_permanent_addr() {
...
if (fixup_permanent_addr(net, idev, ifp) < 0) {
net_info_ratelimited("%s: Failed to add prefix route for address %pI6c; dropping\n",
idev->dev->name, &ifp->addr);
in6_ifa_hold(ifp);
ipv6_del_addr(ifp);
}
...
}
Keeping the address here matches the commit message and the behaviour
before the patch. Deleting it from __ipv6_ifa_notify() would not be
safe, because addrconf_dad_completed() keeps using ifp afterwards. So
the concern is only the log text.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/tencent_F3B718D78486FB80B4040B92FC5BD3076E06%40qq.com
^ permalink raw reply [flat|nested] 2+ messages in thread