Skip to contentSkip to conversation

ipv6: Do not keep loopback addresses when MTU is below minimum

PATCH Applied Ido Schimmel 4 participants 4 messages Nov 25 – Nov 30

Subsystems (3)
lore
Share & tools
lore

Ido Schimmel

author maintainer
#0 lore raw

PATCH 1/1 ipv6: Do not keep loopback addresses when MTU is below minimum

When the MTU of a device drops below the minimum IPv6 MTU (1280), addrconf_ifdown() is called to stop IPv6 on the device. For all devices other than loopback, the IPv6 configuration is destroyed together with all the addresses. For the loopback device, the configuration is retained and so are permanent addresses if keep_addr_on_down is set, but their host routes are deleted.

This results in an up device with addresses that do not have host routes, a state that persists even after the MTU is raised and that the kernel warns about when DAD completes for such an address:

IPv6: BUG: Address 2001::fb on device lo is missing its host route.

IPv6 cannot operate below the minimum MTU, so there is no point in keeping the addresses. Do not keep them, similar to when IPv6 is disabled via disable_ipv6. This aligns the loopback device with other devices and with IPv4, where all the addresses are flushed when the MTU drops below the minimum IPv4 MTU (68).

Before:

 # sysctl -wq net.ipv6.conf.lo.keep_addr_on_down=1
 # ip -6 address add 2001:db8:1::1/64 dev lo
 # ip link set dev lo mtu 1000
 # ip -6 address show dev lo
 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1000 qdisc noqueue state UNKNOWN group default qlen 1000
     inet6 2001:db8:1::1/64 scope global tentative
        valid_lft forever preferred_lft forever
 # ip -6 route show table local dev lo
 #

After:

 # sysctl -wq net.ipv6.conf.lo.keep_addr_on_down=1
 # ip -6 address add 2001:db8:1::1/64 dev lo
 # ip link set dev lo mtu 1000
 # ip -6 address show dev lo
 #

Other devices (before and after):

 # ip link add name dummy1 up type dummy
 # sysctl -wq net.ipv6.conf.dummy1.keep_addr_on_down=1
 # ip -6 address add 2001:db8:2::1/64 dev dummy1
 # ip link set dev dummy1 mtu 1000
 # ip -6 address show dev dummy1
 #

IPv4 (before and after):

 # ip -4 address add 192.0.2.1/32 dev lo
 # ip link set dev lo mtu 67
 # ip -4 address show dev lo
 #

---

Notes:
Targeted at net-next without a Fixes tag as this is not a regression:
the loopback device has been keeping its addresses without host routes when its MTU drops below IPV6_MIN_MTU ever since keep_addr_on_down was introduced in v4.6. The only symptom is a pr_warn() message (not a WARN() backtrace) that so far was only triggered by syzbot and the patch changes user visible behavior.

 net/ipv6/addrconf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/ipv6/addrconf.c +5 -2
index cdea18e5ba1a..285ad5c3bca1 100644
@@ -3948,9 +3948,12 @@ static int addrconf_ifdown(struct net_device *dev, bool unregister)
 	}
 
 	/* combine the user config with event to determine if permanent
-	 * addresses are to be removed from address hash table
+	 * addresses are to be removed from address hash table. IPv6 cannot
+	 * operate below IPV6_MIN_MTU, so treat that like disable_ipv6 and do
+	 * not keep addresses without their host routes.
 	 */
-	if (!unregister && !idev->cnf.disable_ipv6) {
+	if (!unregister && !idev->cnf.disable_ipv6 &&
+	    dev->mtu >= IPV6_MIN_MTU) {
 		/* aggregate the system setting and interface setting */
 		int _keep_addr = READ_ONCE(net->ipv6.devconf_all->keep_addr_on_down);
 
Signature · 1 line
2.56.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 72 lines · Ido Schimmel

When the MTU of a device drops below the minimum IPv6 MTU (1280), addrconf_ifdown() is called to stop IPv6 on the device. For all devices other than loopback, the IPv6 configuration is destroyed together with all the addresses. For the loopback device, the configuration is retained and so are permanent addresses if keep_addr_on_down is set, but their host routes are deleted.

This results in an up device with addresses that do not have host routes, a state that persists even after the MTU is raised and that the kernel warns about when DAD completes for such an address:

IPv6: BUG: Address 2001::fb on device lo is missing its host route.

IPv6 cannot operate below the minimum MTU, so there is no point in keeping the addresses. Do not keep them, similar to when IPv6 is disabled via disable_ipv6. This aligns the loopback device with other devices and with IPv4, where all the addresses are flushed when the MTU drops below the minimum IPv4 MTU (68).

Before:

 # sysctl -wq net.ipv6.conf.lo.keep_addr_on_down=1
 # ip -6 address add 2001:db8:1::1/64 dev lo
 # ip link set dev lo mtu 1000
 # ip -6 address show dev lo
 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1000 qdisc noqueue state UNKNOWN group default qlen 1000
     inet6 2001:db8:1::1/64 scope global tentative
        valid_lft forever preferred_lft forever
 # ip -6 route show table local dev lo
 #

After:

 # sysctl -wq net.ipv6.conf.lo.keep_addr_on_down=1
 # ip -6 address add 2001:db8:1::1/64 dev lo
 # ip link set dev lo mtu 1000
 # ip -6 address show dev lo
 #

Other devices (before and after):

 # ip link add name dummy1 up type dummy
 # sysctl -wq net.ipv6.conf.dummy1.keep_addr_on_down=1
 # ip -6 address add 2001:db8:2::1/64 dev dummy1
 # ip link set dev dummy1 mtu 1000
 # ip -6 address show dev dummy1
 #

IPv4 (before and after):

 # ip -4 address add 192.0.2.1/32 dev lo
 # ip link set dev lo mtu 67
 # ip -4 address show dev lo
 #

---

Notes:
Targeted at net-next without a Fixes tag as this is not a regression:
the loopback device has been keeping its addresses without host routes when its MTU drops below IPV6_MIN_MTU ever since keep_addr_on_down was introduced in v4.6. The only symptom is a pr_warn() message (not a WARN() backtrace) that so far was only triggered by syzbot and the patch changes user visible behavior.

Quoted 3 lines
 net/ipv6/addrconf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ido Schimmel
Quoted 97 lines · Ido Schimmel

When the MTU of a device drops below the minimum IPv6 MTU (1280), addrconf_ifdown() is called to stop IPv6 on the device. For all devices other than loopback, the IPv6 configuration is destroyed together with all the addresses. For the loopback device, the configuration is retained and so are permanent addresses if keep_addr_on_down is set, but their host routes are deleted.

This results in an up device with addresses that do not have host routes, a state that persists even after the MTU is raised and that the kernel warns about when DAD completes for such an address:

IPv6: BUG: Address 2001::fb on device lo is missing its host route.

IPv6 cannot operate below the minimum MTU, so there is no point in keeping the addresses. Do not keep them, similar to when IPv6 is disabled via disable_ipv6. This aligns the loopback device with other devices and with IPv4, where all the addresses are flushed when the MTU drops below the minimum IPv4 MTU (68).

Before:

 # sysctl -wq net.ipv6.conf.lo.keep_addr_on_down=1
 # ip -6 address add 2001:db8:1::1/64 dev lo
 # ip link set dev lo mtu 1000
 # ip -6 address show dev lo
 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1000 qdisc noqueue state UNKNOWN group default qlen 1000
     inet6 2001:db8:1::1/64 scope global tentative
        valid_lft forever preferred_lft forever
 # ip -6 route show table local dev lo
 #

After:

 # sysctl -wq net.ipv6.conf.lo.keep_addr_on_down=1
 # ip -6 address add 2001:db8:1::1/64 dev lo
 # ip link set dev lo mtu 1000
 # ip -6 address show dev lo
 #

Other devices (before and after):

 # ip link add name dummy1 up type dummy
 # sysctl -wq net.ipv6.conf.dummy1.keep_addr_on_down=1
 # ip -6 address add 2001:db8:2::1/64 dev dummy1
 # ip link set dev dummy1 mtu 1000
 # ip -6 address show dev dummy1
 #

IPv4 (before and after):

 # ip -4 address add 192.0.2.1/32 dev lo
 # ip link set dev lo mtu 67
 # ip -4 address show dev lo
 #

---

Notes:
Targeted at net-next without a Fixes tag as this is not a regression:
the loopback device has been keeping its addresses without host routes when its MTU drops below IPV6_MIN_MTU ever since keep_addr_on_down was introduced in v4.6. The only symptom is a pr_warn() message (not a WARN() backtrace) that so far was only triggered by syzbot and the patch changes user visible behavior.

 net/ipv6/addrconf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/ipv6/addrconf.c +5 -2
index cdea18e5ba1a..285ad5c3bca1 100644
@@ -3948,9 +3948,12 @@ static int addrconf_ifdown(struct net_device *dev, bool unregister)
 	}
 
 	/* combine the user config with event to determine if permanent
-	 * addresses are to be removed from address hash table
+	 * addresses are to be removed from address hash table. IPv6 cannot
+	 * operate below IPV6_MIN_MTU, so treat that like disable_ipv6 and do
+	 * not keep addresses without their host routes.
 	 */
-	if (!unregister && !idev->cnf.disable_ipv6) {
+	if (!unregister && !idev->cnf.disable_ipv6 &&
+	    dev->mtu >= IPV6_MIN_MTU) {
 		/* aggregate the system setting and interface setting */
 		int _keep_addr = READ_ONCE(net->ipv6.devconf_all->keep_addr_on_down);
 
Signature · 1 line
2.56.0
#3 lore raw
In reply to Ido Schimmel
This patch was applied to netdev/net-next.git (main) by Willem de Bruijn <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Willem de Bruijn <[email protected]>:

Quoted 8 lines · On Wed, 25 Nov 2026 13:17:09 +0200 you wrote:

When the MTU of a device drops below the minimum IPv6 MTU (1280), addrconf_ifdown() is called to stop IPv6 on the device. For all devices other than loopback, the IPv6 configuration is destroyed together with all the addresses. For the loopback device, the configuration is retained and so are permanent addresses if keep_addr_on_down is set, but their host routes are deleted.

[...]

Here is the summary with links:
- [net-next] ipv6: Do not keep loopback addresses when MTU is below minimum

    https://git.kernel.org/netdev/net-next/c/3ad439ed7011

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html