Skip to content

Commit aee80b5

Browse files
stephen hemmingerdavem330
authored andcommitted
ipv6: generate link local address for GRE tunnel
Use same logic as SIT tunnel to handle link local address for GRE tunnel. OSPFv3 requires link-local address to function. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8ef207d commit aee80b5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

net/ipv6/addrconf.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,11 @@ static int addrconf_ifid_sit(u8 *eui, struct net_device *dev)
15591559
return -1;
15601560
}
15611561

1562+
static int addrconf_ifid_gre(u8 *eui, struct net_device *dev)
1563+
{
1564+
return __ipv6_isatap_ifid(eui, *(__be32 *)dev->dev_addr);
1565+
}
1566+
15621567
static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
15631568
{
15641569
switch (dev->type) {
@@ -1572,6 +1577,8 @@ static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
15721577
return addrconf_ifid_infiniband(eui, dev);
15731578
case ARPHRD_SIT:
15741579
return addrconf_ifid_sit(eui, dev);
1580+
case ARPHRD_IPGRE:
1581+
return addrconf_ifid_gre(eui, dev);
15751582
}
15761583
return -1;
15771584
}
@@ -2423,6 +2430,29 @@ static void addrconf_sit_config(struct net_device *dev)
24232430
}
24242431
#endif
24252432

2433+
#if defined(CONFIG_NET_IPGRE) || defined(CONFIG_NET_IPGRE_MODULE)
2434+
static void addrconf_gre_config(struct net_device *dev)
2435+
{
2436+
struct inet6_dev *idev;
2437+
struct in6_addr addr;
2438+
2439+
pr_info("ipv6: addrconf_gre_config(%s)\n", dev->name);
2440+
2441+
ASSERT_RTNL();
2442+
2443+
if ((idev = ipv6_find_idev(dev)) == NULL) {
2444+
printk(KERN_DEBUG "init gre: add_dev failed\n");
2445+
return;
2446+
}
2447+
2448+
ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0);
2449+
addrconf_prefix_route(&addr, 64, dev, 0, 0);
2450+
2451+
if (!ipv6_generate_eui64(addr.s6_addr + 8, dev))
2452+
addrconf_add_linklocal(idev, &addr);
2453+
}
2454+
#endif
2455+
24262456
static inline int
24272457
ipv6_inherit_linklocal(struct inet6_dev *idev, struct net_device *link_dev)
24282458
{
@@ -2538,6 +2568,11 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
25382568
case ARPHRD_SIT:
25392569
addrconf_sit_config(dev);
25402570
break;
2571+
#endif
2572+
#if defined(CONFIG_NET_IPGRE) || defined(CONFIG_NET_IPGRE_MODULE)
2573+
case ARPHRD_IPGRE:
2574+
addrconf_gre_config(dev);
2575+
break;
25412576
#endif
25422577
case ARPHRD_TUNNEL6:
25432578
addrconf_ip6_tnl_config(dev);

0 commit comments

Comments
 (0)