Technical Root Cause Analysis
1. Overview and Functions Involved
The warning message:
IPv6: BUG: Address ::ffff:127.0.0.1 on device lo is missing its host route.
is emitted by __ipv6_ifa_notify() in net/ipv6/addrconf.c (lines 6347–6350):
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);
}
For this warning to trigger:
__ipv6_ifa_notify() is called with event == RTM_NEWADDR.
- The address structure
ifp has its route pointer ifp->rt == NULL.
- The interface
ifp->idev->dev (here lo) has the IFF_UP flag set.
2. Root Cause Mechanism
A. Acceptance of IPv4-Mapped Addresses as IPv6 Interface Addresses
When an address is assigned via Netlink (inet6_rtm_newaddr()), ipv6_add_addr() in net/ipv6/addrconf.c validates address types:
int addr_type = ipv6_addr_type(cfg->pfx);
if (addr_type == IPV6_ADDR_ANY) {
...
} else if (addr_type & IPV6_ADDR_MULTICAST && !(cfg->ifa_flags & IFA_F_MCAUTOJOIN)) {
...
} else if (!(idev->dev->flags & IFF_LOOPBACK) && !netif_is_l3_master(idev->dev) &&
addr_type & IPV6_ADDR_LOOPBACK) {
...
}
ipv6_add_addr() does not prohibit IPv4-mapped IPv6 addresses (::ffff:x.x.x.x). According to __ipv6_addr_type() in net/ipv6/addrconf_core.c:
if (addr->s6_addr32[2] == htonl(0x0000ffff))
return (IPV6_ADDR_MAPPED | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));
Because the address is categorized strictly as IPV6_ADDR_MAPPED with global scope, it is neither IPV6_ADDR_LOOPBACK (::1) nor IPV6_ADDR_LINKLOCAL (fe80::/10).
B. Retention During Interface Teardown and Clearing of ifa->rt
In net/ipv6/addrconf.c, whether an address is considered local is checked via:
static bool addr_is_local(const struct in6_addr *addr)
{
return ipv6_addr_type(addr) & (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK);
}
Because ::ffff:127.0.0.1 is IPV6_ADDR_MAPPED, addr_is_local(&ifa->addr) evaluates to false.
When addrconf_ifdown() is invoked without unregistering the device (e.g., when keep_addr_on_down is enabled, or during MTU changes where dev->mtu < IPV6_MIN_MTU on loopback: addrconf_ifdown(dev, dev != net->loopback_dev) passes unregister = false explicitly for lo):
keep = keep_addr && (ifa->flags & IFA_F_PERMANENT) &&
!addr_is_local(&ifa->addr);
spin_lock_bh(&ifa->lock);
if (keep) {
state = INET6_IFADDR_STATE_DEAD;
ifa->state = INET6_IFADDR_STATE_PREDAD;
if (!(ifa->flags & IFA_F_NODAD))
ifa->flags |= IFA_F_TENTATIVE;
rt = ifa->rt;
ifa->rt = NULL;
}
...
if (rt)
ip6_del_rt(net, rt, false);
Here, because !addr_is_local() is true for ::ffff:127.0.0.1, the address is retained on idev->addr_list. Its existing host route is deleted from the routing table and ifa->rt is cleared to NULL.
C. Triggering RTM_NEWADDR Notification While ifa->rt == NULL
When subsequent link events occur or addresses are modified while lo is IFF_UP:
- Loopback DAD Bypass: On loopback devices (
dev->flags & IFF_LOOPBACK), DAD probes are bypassed. In addrconf_dad_begin():
if (dev->flags & (IFF_NOARP | IFF_LOOPBACK) ||
(READ_ONCE(net->ipv6.devconf_all->accept_dad) < 1 &&
READ_ONCE(idev->cnf.accept_dad) < 1) ||
!(ifp->flags & IFA_F_TENTATIVE) ||
ifp->flags & IFA_F_NODAD) {
...
addrconf_dad_completed(ifp, bump_id, send_na);
return;
}
This check occurs before checking if (!(idev->if_flags & IF_READY)). addrconf_dad_completed() immediately calls ipv6_ifa_notify(RTM_NEWADDR, ifp), which calls __ipv6_ifa_notify(RTM_NEWADDR, ifp).
- Missing Host Route Regeneration: If an event triggers DAD processing (e.g., an in-flight
addrconf_dad_work() queued by addrconf_dad_start() that unblocks after rtnl_net_lock, or a NETDEV_CHANGE notification running addrconf_dad_run(), or modifying address flags via inet6_addr_modify()) without going through fixup_permanent_addr() (which only executes during NETDEV_UP for addresses retaining IFA_F_PERMANENT), ifp->rt remains NULL.
- In
__ipv6_ifa_notify() under case RTM_NEWADDR:, because ifp->rt is NULL and lo has IFF_UP, the else if (!ifp->rt && (ifp->idev->dev->flags & IFF_UP)) branch is taken, producing the reported warning.