aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/addrconf.h15
-rw-r--r--net/ipv6/addrconf.c26
2 files changed, 25 insertions, 16 deletions
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 1ba4e5bf5801..8317c1bcd86c 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -233,20 +233,7 @@ static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr)
233 (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0); 233 (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0);
234} 234}
235 235
236static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr) 236extern int __ipv6_isatap_ifid(u8 *eui, __be32 addr);
237{
238 eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) ||
239 ipv4_is_loopback(addr) || ipv4_is_linklocal_169(addr) ||
240 ipv4_is_private_172(addr) || ipv4_is_test_192(addr) ||
241 ipv4_is_anycast_6to4(addr) || ipv4_is_private_192(addr) ||
242 ipv4_is_test_198(addr) || ipv4_is_multicast(addr) ||
243 ipv4_is_lbcast(addr)) ? 0x00 : 0x02;
244 eui[1] = 0;
245 eui[2] = 0x5E;
246 eui[3] = 0xFE;
247 memcpy (eui+4, &addr, 4);
248 return 0;
249}
250 237
251static inline int ipv6_addr_is_isatap(const struct in6_addr *addr) 238static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
252{ 239{
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index b17fafc56241..d15f3e095e7e 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1494,6 +1494,29 @@ static int addrconf_ifid_infiniband(u8 *eui, struct net_device *dev)
1494 return 0; 1494 return 0;
1495} 1495}
1496 1496
1497int __ipv6_isatap_ifid(u8 *eui, __be32 addr)
1498{
1499 eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) ||
1500 ipv4_is_loopback(addr) || ipv4_is_linklocal_169(addr) ||
1501 ipv4_is_private_172(addr) || ipv4_is_test_192(addr) ||
1502 ipv4_is_anycast_6to4(addr) || ipv4_is_private_192(addr) ||
1503 ipv4_is_test_198(addr) || ipv4_is_multicast(addr) ||
1504 ipv4_is_lbcast(addr)) ? 0x00 : 0x02;
1505 eui[1] = 0;
1506 eui[2] = 0x5E;
1507 eui[3] = 0xFE;
1508 memcpy(eui + 4, &addr, 4);
1509 return 0;
1510}
1511EXPORT_SYMBOL(__ipv6_isatap_ifid);
1512
1513static int addrconf_ifid_sit(u8 *eui, struct net_device *dev)
1514{
1515 if (dev->priv_flags & IFF_ISATAP)
1516 return __ipv6_isatap_ifid(eui, *(__be32 *)dev->dev_addr);
1517 return -1;
1518}
1519
1497static int ipv6_generate_eui64(u8 *eui, struct net_device *dev) 1520static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
1498{ 1521{
1499 switch (dev->type) { 1522 switch (dev->type) {
@@ -1506,8 +1529,7 @@ static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
1506 case ARPHRD_INFINIBAND: 1529 case ARPHRD_INFINIBAND:
1507 return addrconf_ifid_infiniband(eui, dev); 1530 return addrconf_ifid_infiniband(eui, dev);
1508 case ARPHRD_SIT: 1531 case ARPHRD_SIT:
1509 if (dev->priv_flags & IFF_ISATAP) 1532 return addrconf_ifid_sit(eui, dev);
1510 return ipv6_isatap_eui64(eui, *(__be32 *)dev->dev_addr);
1511 } 1533 }
1512 return -1; 1534 return -1;
1513} 1535}