Skip to contentSkip to conversation

Add IPv6 tokenized interface identifier support

RFC PATCH In review Daniel Borkmann 4 participants 9 messages Apr 4, 2013 – Apr 7, 2013

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

cover Add IPv6 tokenized interface identifier support

This RFC patchset adds IPv6 tokenized interface identifier support for the net-next kernel as well as for iproute2 in order to configure a networking device for IPv6 Token IIDs.

For a more detailled description, have a look at the two patches directly.

Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 1/2 net: ipv6: add tokenized interface identifier support

This patch adds support for tokenized IIDs, that allow for administrators to assign well-known host-part addresses to nodes whilst still obtaining global network prefix from Router Advertisements. It is currently in IETF RFC draft status [1]:

The primary target for such support is server platforms where addresses are usually manually configured, rather than using DHCPv6 or SLAAC. By using tokenised identifiers, hosts can still determine their network prefix by use of SLAAC, but more readily be automatically renumbered should their network prefix change.

[1] http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

The implementation is partially based on top of Mark K. Thompson's proof of concept. Successfully tested by myself.

Cc Hannes Frederic Sowa <[email protected]>
Cc YOSHIFUJI Hideaki <[email protected]>
---
 include/net/if_inet6.h       |    2 +
 include/net/ipv6.h           |    2 +
 include/uapi/linux/if_link.h |    1 +
 net/ipv6/addrconf.c          |   87 ++++++++++++++++++++++++++++++++++++++++-
 net/ipv6/addrconf_core.c     |    2 -
 5 files changed, 89 insertions(+), 5 deletions(-)
include/net/if_inet6.h +2 -0
index 9356322..f1063d6 100644
@@ -187,6 +187,8 @@ struct inet6_dev {
 	struct list_head	tempaddr_list;
 #endif
 
+	struct in6_addr		token;
+
 	struct neigh_parms	*nd_parms;
 	struct inet6_dev	*next;
 	struct ipv6_devconf	cnf;
include/net/ipv6.h +2 -0
index 0810aa5..da8c11e 100644
@@ -88,6 +88,8 @@
 #define IPV6_ADDR_SCOPE_ORGLOCAL	0x08
 #define IPV6_ADDR_SCOPE_GLOBAL		0x0e
 
+#define IPV6_ADDR_SCOPE_TYPE(scope)	((scope) << 16)
+
 /*
  *	Addr flags
  */
include/uapi/linux/if_link.h +1 -0
index c4edfe1..6b35c42 100644
@@ -201,6 +201,7 @@ enum {
 	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
 	IFLA_INET6_CACHEINFO,	/* time values and max reasm size */
 	IFLA_INET6_ICMP6STATS,	/* statistics (icmpv6)		*/
+	IFLA_INET6_TOKEN,	/* device token			*/
 	__IFLA_INET6_MAX
 };
 
net/ipv6/addrconf.c +84 -3

123 lines not on this page · raw message

net/ipv6/addrconf_core.c +0 -2
index d051e5f..8b723de 100644
@@ -6,8 +6,6 @@
 #include <linux/export.h>
 #include <net/ipv6.h>
 
-#define IPV6_ADDR_SCOPE_TYPE(scope)	((scope) << 16)
-
 static inline unsigned int ipv6_addr_scope2type(unsigned int scope)
 {
 	switch (scope) {
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH net-next 1/2] net: ipv6: add tokenized interface identifier support

Quoted 13 lines · Daniel Borkmann

This patch adds support for tokenized IIDs, that allow for administrators to assign well-known host-part addresses to nodes whilst still obtaining global network prefix from Router Advertisements. It is currently in IETF RFC draft status [1]:

The primary target for such support is server platforms where addresses are usually manually configured, rather than using DHCPv6 or SLAAC. By using tokenised identifiers, hosts can still determine their network prefix by use of SLAAC, but more readily be automatically renumbered should their network prefix change.

Quoted 4 lines

[1] http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

The implementation is partially based on top of Mark K. Thompson's proof of concept. Successfully tested by myself.

Cool, this looks really useful.

One comment so far:

include/net/ipv6.h line 92

Quoted 2 lines
include/net/ipv6.h +2 -0
+#define IPV6_ADDR_SCOPE_TYPE(scope)	((scope) << 16)
+

I think we should not export this macro but instead...

net/ipv6/addrconf.c static int inet6_fill_link_af(struct sk_buff *skb, const struct net_device *dev) · line 4333

Quoted 5 lines
net/ipv6/addrconf.c +5 -0
+	/* Well, that's kinda nasty ... */
+	list_for_each_entry(ifp, &idev->addr_list, if_list) {
+		spin_lock(&ifp->lock);
+		if (__ipv6_addr_type(&ifp->addr) &
+		    IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)) {

...use

if (ipv6_addr_src_scope(&ifp->addr) == IPV6_ADDR_SCOPE_GLOBAL) {

here.

net/ipv6/addrconf_core.c line 10

Quoted 10 lines
net/ipv6/addrconf_core.c +0 -2
index d051e5f..8b723de 100644
@@ -6,8 +6,6 @@
 #include <linux/export.h>
 #include <net/ipv6.h>
 
-#define IPV6_ADDR_SCOPE_TYPE(scope)	((scope) << 16)
-

This hunk can be dropped then.

Thanks,

Hannes

#3 lore raw

Re: [PATCH net-next 1/2] net: ipv6: add tokenized interface identifier support

Quoted 48 lines · Hannes Frederic Sowa
Quoted 13 lines · Daniel Borkmann

This patch adds support for tokenized IIDs, that allow for administrators to assign well-known host-part addresses to nodes whilst still obtaining global network prefix from Router Advertisements. It is currently in IETF RFC draft status [1]:

The primary target for such support is server platforms where addresses are usually manually configured, rather than using DHCPv6 or SLAAC. By using tokenised identifiers, hosts can still determine their network prefix by use of SLAAC, but more readily be automatically renumbered should their network prefix change.

Quoted 4 lines

[1] http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

The implementation is partially based on top of Mark K. Thompson's proof of concept. Successfully tested by myself.

Cool, this looks really useful.

One comment so far:

include/net/ipv6.h line 92

Quoted 2 lines
include/net/ipv6.h +2 -0
+#define IPV6_ADDR_SCOPE_TYPE(scope)	((scope) << 16)
+

I think we should not export this macro but instead...

net/ipv6/addrconf.c static int inet6_fill_link_af(struct sk_buff *skb, const struct net_device *dev) · line 4333

Quoted 5 lines
net/ipv6/addrconf.c +5 -0
+	/* Well, that's kinda nasty ... */
+	list_for_each_entry(ifp, &idev->addr_list, if_list) {
+		spin_lock(&ifp->lock);
+		if (__ipv6_addr_type(&ifp->addr) &
+		    IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)) {

...use

if (ipv6_addr_src_scope(&ifp->addr) == IPV6_ADDR_SCOPE_GLOBAL) {

here.

Quoted 8 lines
net/ipv6/addrconf_core.c +0 -0
index d051e5f..8b723de 100644
@@ -6,8 +6,6 @@
  #include <linux/export.h>
  #include <net/ipv6.h>
 
Quoted 4 lines

net/ipv6/addrconf_core.c line 10

Quoted 2 lines
net/ipv6/addrconf_core.c +0 -2
-#define IPV6_ADDR_SCOPE_TYPE(scope)	((scope) << 16)
-

This hunk can be dropped then.

Thanks for the review Hannes, I'll do that in a version 2 of the set.

Thanks,

Daniel

#4 lore raw

Re: [PATCH net-next 1/2] net: ipv6: add tokenized interface identifier support

In reply to Daniel Borkmann
Quoted 86 lines · Daniel Borkmann

This patch adds support for tokenized IIDs, that allow for administrators to assign well-known host-part addresses to nodes whilst still obtaining global network prefix from Router Advertisements. It is currently in IETF RFC draft status [1]:

The primary target for such support is server platforms where addresses are usually manually configured, rather than using DHCPv6 or SLAAC. By using tokenised identifiers, hosts can still determine their network prefix by use of SLAAC, but more readily be automatically renumbered should their network prefix change.

[1] http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

The implementation is partially based on top of Mark K. Thompson's proof of concept. Successfully tested by myself.

Cc Hannes Frederic Sowa <[email protected]>
Cc YOSHIFUJI Hideaki <[email protected]>
---
 include/net/if_inet6.h       |    2 +
 include/net/ipv6.h           |    2 +
 include/uapi/linux/if_link.h |    1 +
 net/ipv6/addrconf.c          |   87 ++++++++++++++++++++++++++++++++++++++++-
 net/ipv6/addrconf_core.c     |    2 -
 5 files changed, 89 insertions(+), 5 deletions(-)
include/net/if_inet6.h +2 -0
index 9356322..f1063d6 100644
@@ -187,6 +187,8 @@ struct inet6_dev {
 	struct list_head	tempaddr_list;
 #endif
 
+	struct in6_addr		token;
+
 	struct neigh_parms	*nd_parms;
 	struct inet6_dev	*next;
 	struct ipv6_devconf	cnf;
include/net/ipv6.h +2 -0
index 0810aa5..da8c11e 100644
@@ -88,6 +88,8 @@
 #define IPV6_ADDR_SCOPE_ORGLOCAL	0x08
 #define IPV6_ADDR_SCOPE_GLOBAL		0x0e
 
+#define IPV6_ADDR_SCOPE_TYPE(scope)	((scope) << 16)
+
 /*
  *	Addr flags
  */
include/uapi/linux/if_link.h +1 -0
index c4edfe1..6b35c42 100644
@@ -201,6 +201,7 @@ enum {
 	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
 	IFLA_INET6_CACHEINFO,	/* time values and max reasm size */
 	IFLA_INET6_ICMP6STATS,	/* statistics (icmpv6)		*/
+	IFLA_INET6_TOKEN,	/* device token			*/
 	__IFLA_INET6_MAX
 };
 
net/ipv6/addrconf.c +2 -2
index a33b157..fb0e8a0 100644
@@ -422,6 +422,7 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
 		ipv6_regen_rndid((unsigned long) ndev);
 	}
 #endif
+	memset(ndev->token.s6_addr, 0, sizeof(ndev->token.s6_addr));
 
 	if (netif_running(dev) && addrconf_qdisc_ok(dev))
 		ndev->if_flags |= IF_READY;
@@ -2136,8 +2137,14 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
 
 		if (pinfo->prefix_len == 64) {
 			memcpy(&addr, &pinfo->prefix, 8);
-			if (ipv6_generate_eui64(addr.s6_addr + 8, dev) &&
-			    ipv6_inherit_eui64(addr.s6_addr + 8, in6_dev)) {
+

net/ipv6/addrconf.c void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao) · line 2150

Quoted 10 lines
net/ipv6/addrconf.c +7 -0
+			if (!ipv6_addr_any(&in6_dev->token)) {
+				read_lock_bh(&in6_dev->lock);
+				memcpy(addr.s6_addr + 8,
+				       in6_dev->token.s6_addr + 8, 8);
+				read_unlock_bh(&in6_dev->lock);
+			} else if (ipv6_generate_eui64(addr.s6_addr + 8, dev) &&
+				   ipv6_inherit_eui64(addr.s6_addr + 8, in6_dev)) {
 				in6_dev_put(in6_dev);
 				return;
 			}

Why not initialize token by interface-identifier and then allow users to "override"?

--yoshfuji

#5 lore raw

Re: [PATCH net-next 1/2] net: ipv6: add tokenized interface identifier support

Quoted 23 lines · YOSHIFUJI Hideaki
Quoted 22 lines · Daniel Borkmann

This patch adds support for tokenized IIDs, that allow for administrators to assign well-known host-part addresses to nodes whilst still obtaining global network prefix from Router Advertisements. It is currently in IETF RFC draft status [1]:

The primary target for such support is server platforms where addresses are usually manually configured, rather than using DHCPv6 or SLAAC. By using tokenised identifiers, hosts can still determine their network prefix by use of SLAAC, but more readily be automatically renumbered should their network prefix change.

[1] http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

The implementation is partially based on top of Mark K. Thompson's proof of concept. Successfully tested by myself.

Cc Hannes Frederic Sowa <[email protected]>
Cc YOSHIFUJI Hideaki <[email protected]>

---

[...]

Quoted 10 lines
Quoted 10 lines
  		if (pinfo->prefix_len == 64) {
  			memcpy(&addr, &pinfo->prefix, 8);
net/ipv6/addrconf.c +6 -2
-			if (ipv6_generate_eui64(addr.s6_addr + 8, dev) &&
-			    ipv6_inherit_eui64(addr.s6_addr + 8, in6_dev)) {
+
+			if (!ipv6_addr_any(&in6_dev->token)) {
+				read_lock_bh(&in6_dev->lock);
+				memcpy(addr.s6_addr + 8,
+				       in6_dev->token.s6_addr + 8, 8);
+				read_unlock_bh(&in6_dev->lock);
Quoted 8 lines

net/ipv6/addrconf.c void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao) · line 2150

Quoted 5 lines
net/ipv6/addrconf.c +2 -0
+			} else if (ipv6_generate_eui64(addr.s6_addr + 8, dev) &&
+				   ipv6_inherit_eui64(addr.s6_addr + 8, in6_dev)) {
  				in6_dev_put(in6_dev);
  				return;
  			}

Why not initialize token by interface-identifier and then allow users to "override"?

Sure this would simplify this part above ...

... maybe I'm wrong, but then, probably, if someone changes the netdev's hw address during runtime, we could not keep track of that anymore as dynamically done in e.g. ipv6_generate_eui64(), since we've already done the token init at an earlier point in time, no?

With the current patch, we would have a clear separation of both concepts like ``either you use token iids, or you don't''.

#6 lore raw

PATCH 2/2 ip: ipv6: add tokenized interface identifier support

In reply to Daniel Borkmann

This is experimental support for tokenized IIDs, that enable administrators to assign well-known host-part addresses to nodes whilst still obtaining global network prefix from Router Advertisements. It is currently in IETF RFC draft status [1].

Example commands with iproute2:

Setting a device token:

  # ip token set ::1a:2b:3c:4d/64 dev eth1

Getting a device token:

  # ip token get dev eth1
  token ::1a:2b:3c:4d dev eth1

Listing all tokens:

  # ip token list  (or: ip token)
  token :: dev eth0
  token ::1a:2b:3c:4d dev eth1

[1] http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

Cc Hannes Frederic Sowa <[email protected]>
Cc YOSHIFUJI Hideaki <[email protected]>
---
 include/linux/if_link.h |   1 +
 ip/Makefile             |   2 +-
 ip/ip.c                 |   3 +-
 ip/ip_common.h          |   1 +
 ip/iptoken.c            | 208 ++++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/Makefile       |   2 +-
 man/man8/ip-token.8     |  66 +++++++++++++++
 7 files changed, 280 insertions(+), 3 deletions(-)
 create mode 100644 ip/iptoken.c
 create mode 100644 man/man8/ip-token.8
include/linux/if_link.h +1 -0
index 40167af..f3a1b29 100644
@@ -199,6 +199,7 @@ enum {
 	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
 	IFLA_INET6_CACHEINFO,	/* time values and max reasm size */
 	IFLA_INET6_ICMP6STATS,	/* statistics (icmpv6)		*/
+	IFLA_INET6_TOKEN,	/* device token			*/
 	__IFLA_INET6_MAX
 };
 
ip/Makefile +1 -1
index 2b606d4..48bd4a1 100644
@@ -1,6 +1,6 @@
 IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
     rtm_map.o iptunnel.o ip6tunnel.o tunnel.o ipneigh.o ipntable.o iplink.o \
-    ipmaddr.o ipmonitor.o ipmroute.o ipprefix.o iptuntap.o \
+    ipmaddr.o ipmonitor.o ipmroute.o ipprefix.o iptuntap.o iptoken.o \
     ipxfrm.o xfrm_state.o xfrm_policy.o xfrm_monitor.o \
     iplink_vlan.o link_veth.o link_gre.o iplink_can.o \
     iplink_macvlan.o iplink_macvtap.o ipl2tp.o link_vti.o \
ip/ip.c +2 -1
index e10ddb2..69bd5ff 100644
@@ -45,7 +45,7 @@ static void usage(void)
 "       ip [ -force ] -batch filename\n"
 "where  OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable |\n"
 "                   tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm |\n"
-"                   netns | l2tp | tcp_metrics }\n"
+"                   netns | l2tp | tcp_metrics | token }\n"
 "       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
 "                    -f[amily] { inet | inet6 | ipx | dnet | bridge | link } |\n"
 "                    -4 | -6 | -I | -D | -B | -0 |\n"
@@ -80,6 +80,7 @@ static const struct cmd {
 	{ "tunl",	do_iptunnel },
 	{ "tuntap",	do_iptuntap },
 	{ "tap",	do_iptuntap },
+	{ "token",	do_iptoken },
 	{ "tcpmetrics",	do_tcp_metrics },
 	{ "tcp_metrics",do_tcp_metrics },
 	{ "monitor",	do_ipmonitor },
ip/ip_common.h +1 -0
index de56810..f9b4734 100644
@@ -49,6 +49,7 @@ extern int do_xfrm(int argc, char **argv);
 extern int do_ipl2tp(int argc, char **argv);
 extern int do_tcp_metrics(int argc, char **argv);
 extern int do_ipnetconf(int argc, char **argv);
+extern int do_iptoken(int argc, char **argv);
 
 static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb)
 {
ip/iptoken.c new file +208 -0

208 lines not on this page · raw message

man/man8/Makefile +1 -1
index d208f3b..ff80c98 100644
@@ -9,7 +9,7 @@ MAN8PAGES = $(TARGETS) ip.8 arpd.8 lnstat.8 routel.8 rtacct.8 rtmon.8 ss.8 \
 	ip-addrlabel.8 ip-l2tp.8 \
 	ip-maddress.8 ip-monitor.8 ip-mroute.8 ip-neighbour.8 \
 	ip-netns.8 ip-ntable.8 ip-rule.8 ip-tunnel.8 ip-xfrm.8 \
-	ip-tcp_metrics.8 ip-netconf.8
+	ip-tcp_metrics.8 ip-netconf.8 ip-token.8
 
 all: $(TARGETS)
 
man/man8/ip-token.8 new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#7 lore raw

Re: [PATCH iproute2 2/2] ip: ipv6: add tokenized interface identifier support

Quoted 19 lines · On Thu, 4 Apr 2013 16:37:38 +0200 Daniel Borkmann <[email protected]> wrote:

This is experimental support for tokenized IIDs, that enable administrators to assign well-known host-part addresses to nodes whilst still obtaining global network prefix from Router Advertisements. It is currently in IETF RFC draft status [1].

Example commands with iproute2:

Setting a device token:

  # ip token set ::1a:2b:3c:4d/64 dev eth1

Getting a device token:

  # ip token get dev eth1
  token ::1a:2b:3c:4d dev eth1

Listing all tokens:

  # ip token list  (or: ip token)
  token :: dev eth0
  token ::1a:2b:3c:4d dev eth1
Quoted 5 lines

[1] http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

Cc Hannes Frederic Sowa <[email protected]>
Cc YOSHIFUJI Hideaki <[email protected]>

Deferred.
Please resubmit during 3.10 merge window.

#8 lore raw

Re: [PATCH iproute2 2/2] ip: ipv6: add tokenized interface identifier support

Quoted 22 lines · Stephen Hemminger
Quoted 19 lines · On Thu, 4 Apr 2013 16:37:38 +0200 Daniel Borkmann <[email protected]> wrote:

This is experimental support for tokenized IIDs, that enable administrators to assign well-known host-part addresses to nodes whilst still obtaining global network prefix from Router Advertisements. It is currently in IETF RFC draft status [1].

Example commands with iproute2:

Setting a device token:

   # ip token set ::1a:2b:3c:4d/64 dev eth1

Getting a device token:

   # ip token get dev eth1
   token ::1a:2b:3c:4d dev eth1

Listing all tokens:

   # ip token list  (or: ip token)
   token :: dev eth0
   token ::1a:2b:3c:4d dev eth1
Quoted 8 lines
Quoted 5 lines

[1] http://tools.ietf.org/html/draft-chown-6man-tokenised-ipv6-identifiers-02

Cc Hannes Frederic Sowa <[email protected]>
Cc YOSHIFUJI Hideaki <[email protected]>

Deferred.
Please resubmit during 3.10 merge window.

Thanks, I'll do.