Skip to content

Commit 02862ea

Browse files
thomasjwinterSasha Levin
authored andcommitted
ip/ip6_gre: Fix changing addr gen mode not generating IPv6 link local address
[ Upstream commit 23ca0c2 ] For our point-to-point GRE tunnels, they have IN6_ADDR_GEN_MODE_NONE when they are created then we set IN6_ADDR_GEN_MODE_EUI64 when they come up to generate the IPv6 link local address for the interface. Recently we found that they were no longer generating IPv6 addresses. This issue would also have affected SIT tunnels. Commit e5dd729 changed the code path so that GRE tunnels generate an IPv6 address based on the tunnel source address. It also changed the code path so GRE tunnels don't call addrconf_addr_gen in addrconf_dev_config which is called by addrconf_sysctl_addr_gen_mode when the IN6_ADDR_GEN_MODE is changed. This patch aims to fix this issue by moving the code in addrconf_notify which calls the addr gen for GRE and SIT into a separate function and calling it in the places that expect the IPv6 address to be generated. The previous addrconf_dev_config is renamed to addrconf_eth_config since it only expected eth type interfaces and follows the addrconf_gre/sit_config format. A part of this changes means that the loopback address will be attempted to be configured when changing addr_gen_mode for lo. This should not be a problem because the address should exist anyway and if does already exist then no error is produced. Fixes: e5dd729 ("ip/ip6_gre: use the same logic as SIT interfaces when computing v6LL address") Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e45ec53 commit 02862ea

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

net/ipv6/addrconf.c

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3447,6 +3447,30 @@ static void addrconf_gre_config(struct net_device *dev)
34473447
}
34483448
#endif
34493449

3450+
static void addrconf_init_auto_addrs(struct net_device *dev)
3451+
{
3452+
switch (dev->type) {
3453+
#if IS_ENABLED(CONFIG_IPV6_SIT)
3454+
case ARPHRD_SIT:
3455+
addrconf_sit_config(dev);
3456+
break;
3457+
#endif
3458+
#if IS_ENABLED(CONFIG_NET_IPGRE) || IS_ENABLED(CONFIG_IPV6_GRE)
3459+
case ARPHRD_IP6GRE:
3460+
case ARPHRD_IPGRE:
3461+
addrconf_gre_config(dev);
3462+
break;
3463+
#endif
3464+
case ARPHRD_LOOPBACK:
3465+
init_loopback(dev);
3466+
break;
3467+
3468+
default:
3469+
addrconf_dev_config(dev);
3470+
break;
3471+
}
3472+
}
3473+
34503474
static int fixup_permanent_addr(struct net *net,
34513475
struct inet6_dev *idev,
34523476
struct inet6_ifaddr *ifp)
@@ -3615,26 +3639,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
36153639
run_pending = 1;
36163640
}
36173641

3618-
switch (dev->type) {
3619-
#if IS_ENABLED(CONFIG_IPV6_SIT)
3620-
case ARPHRD_SIT:
3621-
addrconf_sit_config(dev);
3622-
break;
3623-
#endif
3624-
#if IS_ENABLED(CONFIG_NET_IPGRE) || IS_ENABLED(CONFIG_IPV6_GRE)
3625-
case ARPHRD_IP6GRE:
3626-
case ARPHRD_IPGRE:
3627-
addrconf_gre_config(dev);
3628-
break;
3629-
#endif
3630-
case ARPHRD_LOOPBACK:
3631-
init_loopback(dev);
3632-
break;
3633-
3634-
default:
3635-
addrconf_dev_config(dev);
3636-
break;
3637-
}
3642+
addrconf_init_auto_addrs(dev);
36383643

36393644
if (!IS_ERR_OR_NULL(idev)) {
36403645
if (run_pending)
@@ -6397,7 +6402,7 @@ static int addrconf_sysctl_addr_gen_mode(struct ctl_table *ctl, int write,
63976402

63986403
if (idev->cnf.addr_gen_mode != new_val) {
63996404
idev->cnf.addr_gen_mode = new_val;
6400-
addrconf_dev_config(idev->dev);
6405+
addrconf_init_auto_addrs(idev->dev);
64016406
}
64026407
} else if (&net->ipv6.devconf_all->addr_gen_mode == ctl->data) {
64036408
struct net_device *dev;
@@ -6408,7 +6413,7 @@ static int addrconf_sysctl_addr_gen_mode(struct ctl_table *ctl, int write,
64086413
if (idev &&
64096414
idev->cnf.addr_gen_mode != new_val) {
64106415
idev->cnf.addr_gen_mode = new_val;
6411-
addrconf_dev_config(idev->dev);
6416+
addrconf_init_auto_addrs(idev->dev);
64126417
}
64136418
}
64146419
}

0 commit comments

Comments
 (0)