Skip to content

Commit cca6e9f

Browse files
committed
Merge branch 'ip-ip6_gre-fix-gre-tunnels-not-generating-ipv6-link-local-addresses'
Thomas Winter says: ==================== ip/ip6_gre: Fix GRE tunnels not generating IPv6 link local addresses 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. Also, non-point-to-point tunnels were not generating any IPv6 link local address and instead generating an IPv6 compat address, breaking IPv6 communication on the tunnel. These failures were caused by commit e5dd729 and this patch set aims to resolve these issues. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 64466c4 + 30e2291 commit cca6e9f

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

net/ipv6/addrconf.c

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3127,17 +3127,17 @@ static void add_v4_addrs(struct inet6_dev *idev)
31273127
offset = sizeof(struct in6_addr) - 4;
31283128
memcpy(&addr.s6_addr32[3], idev->dev->dev_addr + offset, 4);
31293129

3130-
if (idev->dev->flags&IFF_POINTOPOINT) {
3130+
if (!(idev->dev->flags & IFF_POINTOPOINT) && idev->dev->type == ARPHRD_SIT) {
3131+
scope = IPV6_ADDR_COMPATv4;
3132+
plen = 96;
3133+
pflags |= RTF_NONEXTHOP;
3134+
} else {
31313135
if (idev->cnf.addr_gen_mode == IN6_ADDR_GEN_MODE_NONE)
31323136
return;
31333137

31343138
addr.s6_addr32[0] = htonl(0xfe800000);
31353139
scope = IFA_LINK;
31363140
plen = 64;
3137-
} else {
3138-
scope = IPV6_ADDR_COMPATv4;
3139-
plen = 96;
3140-
pflags |= RTF_NONEXTHOP;
31413141
}
31423142

31433143
if (addr.s6_addr32[3]) {
@@ -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)