Skip to contentSkip to conversation

gre: Fix default IPv6 multicast route creation.

PATCH Applied Guillaume Nault 4 participants 9 messages Jul 9, 2025 – Jul 11, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover gre: Fix default IPv6 multicast route creation.

When fixing IPv6 link-local address generation on GRE devices with commit 3e6a0243ff00 ("gre: Fix again IPv6 link-local address generation."), I accidentally broke the default IPv6 multicast route creation on these GRE devices.

Fix that in patch 1, making the GRE specific code yet a bit closer to the generic code used by most other network interface types.

Then extend the selftest in patch 2 to cover this case.

Guillaume Nault (2):
gre: Fix IPv6 multicast route creation.
selftests: Add IPv6 multicast route generation tests for GRE devices.

 net/ipv6/addrconf.c                           |  9 ++-----
 .../testing/selftests/net/gre_ipv6_lladdr.sh  | 27 ++++++++++++-------
 2 files changed, 19 insertions(+), 17 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/2 gre: Fix IPv6 multicast route creation.

Use addrconf_add_dev() instead of ipv6_find_idev() in addrconf_gre_config() so that we don't just get the inet6_dev, but also install the default ff00::/8 multicast route.

Before commit 3e6a0243ff00 ("gre: Fix again IPv6 link-local address generation."), the multicast route was created at the end of the function by addrconf_add_mroute(). But this code path is now only taken in one particular case (gre devices not bound to a local IP address and in EUI64 mode). For all other cases, the function exits early and addrconf_add_mroute() is not called anymore.

Using addrconf_add_dev() instead of ipv6_find_idev() in addrconf_gre_config(), fixes the problem as it will create the default multicast route for all gre devices. This also brings addrconf_gre_config() a bit closer to the normal netdevice IPv6 configuration code (addrconf_dev_config()).

---
 net/ipv6/addrconf.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
net/ipv6/addrconf.c +2 -7
index ba2ec7c870cc..870a0bd6c2ba 100644
@@ -3525,11 +3525,9 @@ static void addrconf_gre_config(struct net_device *dev)
 
 	ASSERT_RTNL();
 
-	idev = ipv6_find_idev(dev);
-	if (IS_ERR(idev)) {
-		pr_debug("%s: add_dev failed\n", __func__);
+	idev = addrconf_add_dev(dev);
+	if (IS_ERR(idev))
 		return;
-	}
 
 	/* Generate the IPv6 link-local address using addrconf_addr_gen(),
 	 * unless we have an IPv4 GRE device not bound to an IP address and
@@ -3543,9 +3541,6 @@ static void addrconf_gre_config(struct net_device *dev)
 	}
 
 	add_v4_addrs(idev);
-
-	if (dev->flags & IFF_POINTOPOINT)
-		addrconf_add_mroute(dev);
 }
 #endif
 
Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH net 1/2] gre: Fix IPv6 multicast route creation.

Quoted 17 lines · Guillaume Nault

Use addrconf_add_dev() instead of ipv6_find_idev() in addrconf_gre_config() so that we don't just get the inet6_dev, but also install the default ff00::/8 multicast route.

Before commit 3e6a0243ff00 ("gre: Fix again IPv6 link-local address generation."), the multicast route was created at the end of the function by addrconf_add_mroute(). But this code path is now only taken in one particular case (gre devices not bound to a local IP address and in EUI64 mode). For all other cases, the function exits early and addrconf_add_mroute() is not called anymore.

Using addrconf_add_dev() instead of ipv6_find_idev() in addrconf_gre_config(), fixes the problem as it will create the default multicast route for all gre devices. This also brings addrconf_gre_config() a bit closer to the normal netdevice IPv6 configuration code (addrconf_dev_config()).

Quoted 6 lines
#3 lore raw

Re: [PATCH net 1/2] gre: Fix IPv6 multicast route creation.

In reply to Guillaume Nault
Quoted 17 lines · On Wed, 9 Jul 2025 16:30:10 +0200 Guillaume Nault <[email protected]> wrote:

Use addrconf_add_dev() instead of ipv6_find_idev() in addrconf_gre_config() so that we don't just get the inet6_dev, but also install the default ff00::/8 multicast route.

Before commit 3e6a0243ff00 ("gre: Fix again IPv6 link-local address generation."), the multicast route was created at the end of the function by addrconf_add_mroute(). But this code path is now only taken in one particular case (gre devices not bound to a local IP address and in EUI64 mode). For all other cases, the function exits early and addrconf_add_mroute() is not called anymore.

Using addrconf_add_dev() instead of ipv6_find_idev() in addrconf_gre_config(), fixes the problem as it will create the default multicast route for all gre devices. This also brings addrconf_gre_config() a bit closer to the normal netdevice IPv6 configuration code (addrconf_dev_config()).

Quoted 6 lines

You probably also want to

so this gets picked up by the stable team after it's merged.

Best,
Gary

#4 lore raw

Re: [PATCH net 1/2] gre: Fix IPv6 multicast route creation.

Quoted 27 lines · Gary Guo
Quoted 17 lines · On Wed, 9 Jul 2025 16:30:10 +0200 Guillaume Nault <[email protected]> wrote:

Use addrconf_add_dev() instead of ipv6_find_idev() in addrconf_gre_config() so that we don't just get the inet6_dev, but also install the default ff00::/8 multicast route.

Before commit 3e6a0243ff00 ("gre: Fix again IPv6 link-local address generation."), the multicast route was created at the end of the function by addrconf_add_mroute(). But this code path is now only taken in one particular case (gre devices not bound to a local IP address and in EUI64 mode). For all other cases, the function exits early and addrconf_add_mroute() is not called anymore.

Using addrconf_add_dev() instead of ipv6_find_idev() in addrconf_gre_config(), fixes the problem as it will create the default multicast route for all gre devices. This also brings addrconf_gre_config() a bit closer to the normal netdevice IPv6 configuration code (addrconf_dev_config()).

Quoted 6 lines
Quoted 5 lines

You probably also want to

so this gets picked up by the stable team after it's merged.

Yeah, I forgot that the policy had changed.
It seems that Jakub took care of it anyway.
Thanks again!

Quoted 3 lines

Best,
Gary

#5 lore raw

PATCH 2/2 selftests: Add IPv6 multicast route generation tests for GRE devices.

In reply to Guillaume Nault

The previous patch fixes a bug that prevented the creation of the default IPv6 multicast route (ff00::/8) for some GRE devices. Now let's extend the GRE IPv6 selftests to cover this case.

Also, rename check_ipv6_ll_addr() to check_ipv6_device_config() and adapt comments and script output to take into account the fact that we're not limitted to link-local address generation.

---
 .../testing/selftests/net/gre_ipv6_lladdr.sh  | 27 ++++++++++++-------
 1 file changed, 17 insertions(+), 10 deletions(-)
tools/testing/selftests/net/gre_ipv6_lladdr.sh +17 -10
index 5b34f6e1f831..48eb999a3120 100755
@@ -24,7 +24,10 @@ setup_basenet()
 	ip -netns "${NS0}" address add dev lo 2001:db8::10/64 nodad
 }
 
-# Check if network device has an IPv6 link-local address assigned.
+# Check the IPv6 configuration of a network device.
+#
+# We currently check the generation of the link-local IPv6 address and the
+# creation of the ff00::/8 multicast route.
 #
 # Parameters:
 #
@@ -35,7 +38,7 @@ setup_basenet()
 #         a link-local address)
 #   * $4: The user visible name for the scenario being tested
 #
-check_ipv6_ll_addr()
+check_ipv6_device_config()
 {
 	local DEV="$1"
 	local EXTRA_MATCH="$2"
@@ -45,7 +48,11 @@ check_ipv6_ll_addr()
 	RET=0
 	set +e
 	ip -netns "${NS0}" -6 address show dev "${DEV}" scope link | grep "fe80::" | grep -q "${EXTRA_MATCH}"
-	check_err_fail "${XRET}" $? ""
+	check_err_fail "${XRET}" $? "IPv6 link-local address generation"
+
+	ip -netns "${NS0}" -6 route show table local type multicast ff00::/8 proto kernel | grep -q "${DEV}"
+	check_err_fail 0 $? "IPv6 multicast route creation"
+
 	log_test "${MSG}"
 	set -e
 }
@@ -102,20 +109,20 @@ test_gre_device()
 		;;
 	esac
 
-	# Check that IPv6 link-local address is generated when device goes up
+	# Check the IPv6 device configuration when it goes up
 	ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode="${ADDR_GEN_MODE}"
 	ip -netns "${NS0}" link set dev gretest up
-	check_ipv6_ll_addr gretest "${MATCH_REGEXP}" "${XRET}" "config: ${MSG}"
+	check_ipv6_device_config gretest "${MATCH_REGEXP}" "${XRET}" "config: ${MSG}"
 
 	# Now disable link-local address generation
 	ip -netns "${NS0}" link set dev gretest down
 	ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode=1
 	ip -netns "${NS0}" link set dev gretest up
 
-	# Check that link-local address generation works when re-enabled while
-	# the device is already up
+	# Check the IPv6 device configuration when link-local address
+	# generation is re-enabled while the device is already up
 	ip netns exec "${NS0}" sysctl -qw net.ipv6.conf.gretest.addr_gen_mode="${ADDR_GEN_MODE}"
-	check_ipv6_ll_addr gretest "${MATCH_REGEXP}" "${XRET}" "update: ${MSG}"
+	check_ipv6_device_config gretest "${MATCH_REGEXP}" "${XRET}" "update: ${MSG}"
 
 	ip -netns "${NS0}" link del dev gretest
 }
@@ -126,7 +133,7 @@ test_gre4()
 	local MODE
 
 	for GRE_TYPE in "gre" "gretap"; do
-		printf "\n####\nTesting IPv6 link-local address generation on ${GRE_TYPE} devices\n####\n\n"
+		printf "\n####\nTesting IPv6 configuration of ${GRE_TYPE} devices\n####\n\n"
 
 		for MODE in "eui64" "none" "stable-privacy" "random"; do
 			test_gre_device "${GRE_TYPE}" 192.0.2.10 192.0.2.11 "${MODE}"
@@ -142,7 +149,7 @@ test_gre6()
 	local MODE
 
 	for GRE_TYPE in "ip6gre" "ip6gretap"; do
-		printf "\n####\nTesting IPv6 link-local address generation on ${GRE_TYPE} devices\n####\n\n"
+		printf "\n####\nTesting IPv6 configuration of ${GRE_TYPE} devices\n####\n\n"
 
 		for MODE in "eui64" "none" "stable-privacy" "random"; do
 			test_gre_device "${GRE_TYPE}" 2001:db8::10 2001:db8::11 "${MODE}"
Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH net 2/2] selftests: Add IPv6 multicast route generation tests for GRE devices.

Quoted 7 lines · Guillaume Nault

The previous patch fixes a bug that prevented the creation of the default IPv6 multicast route (ff00::/8) for some GRE devices. Now let's extend the GRE IPv6 selftests to cover this case.

Also, rename check_ipv6_ll_addr() to check_ipv6_device_config() and adapt comments and script output to take into account the fact that we're not limitted to link-local address generation.

In case you have v2: s/limitted/limited/

Quoted 2 lines
#7 lore raw

Re: [PATCH net 2/2] selftests: Add IPv6 multicast route generation tests for GRE devices.

Quoted 10 lines · Ido Schimmel
Quoted 7 lines · Guillaume Nault

The previous patch fixes a bug that prevented the creation of the default IPv6 multicast route (ff00::/8) for some GRE devices. Now let's extend the GRE IPv6 selftests to cover this case.

Also, rename check_ipv6_ll_addr() to check_ipv6_device_config() and adapt comments and script output to take into account the fact that we're not limitted to link-local address generation.

In case you have v2: s/limitted/limited/

Forgot to run the spell-checker, sorry.
Anyway, it seems Jakub fixed it while merging.
Thank you both!

Quoted 5 lines
Quoted 2 lines
#8 lore raw
In reply to Guillaume Nault
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 9 Jul 2025 16:30:04 +0200 you wrote:

When fixing IPv6 link-local address generation on GRE devices with commit 3e6a0243ff00 ("gre: Fix again IPv6 link-local address generation."), I accidentally broke the default IPv6 multicast route creation on these GRE devices.

Fix that in patch 1, making the GRE specific code yet a bit closer to the generic code used by most other network interface types.

[...]

Here is the summary with links:
- [net,1/2] gre: Fix IPv6 multicast route creation.

    https://git.kernel.org/netdev/net/c/4e914ef063de
  - [net,2/2] selftests: Add IPv6 multicast route generation tests for GRE devices.
    https://git.kernel.org/netdev/net/c/4d61a8a73343

You are awesome, thank you!

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