Skip to contentSkip to conversation

net: ipv6: add tokenized interface identifier support

PATCH Applied Daniel Borkmann 3 participants 4 messages Apr 8, 2013

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

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

This patch adds support for IPv6 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 draft status.

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. [...]

The disadvantage with static addresses is that they are likely to require manual editing should the network prefix in use change. If instead there were a method to only manually configure the static identifier part of the IPv6 address, then the address could be automatically updated when a new prefix was introduced, as described in [RFC4192] for example. In such cases a DNS server might be configured with such a tokenised interface identifier of ::53, and SLAAC would use the token in constructing the interface address, using the advertised prefix. [...]

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. However, it uses the Netlink interface for configuration resp. data retrival, so that it can be easily extended in future. Successfully tested by myself.

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

---
RFC -> v1:
- Applied Hannes' feedback from the RFC
- Dropped the RFC from the subject

The iproute2 part of this patch was previously posted at
http://thread.gmane.org/gmane.linux.network/264553/focus=264555
and will be re-submitted during the 3.10 merge window as Stephen requested.

 include/net/if_inet6.h       |    2 +
 include/uapi/linux/if_link.h |    1 +
 net/ipv6/addrconf.c          |   87 ++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 87 insertions(+), 3 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/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

Signature · 1 line
1.7.1
maintainer Applied
#1 lore raw

From: Daniel Borkmann <[email protected]>
Date: Mon, 8 Apr 2013 16:01:30 +0200

Quoted 31 lines

This patch adds support for IPv6 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 draft status.

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. [...]

The disadvantage with static addresses is that they are likely to require manual editing should the network prefix in use change. If instead there were a method to only manually configure the static identifier part of the IPv6 address, then the address could be automatically updated when a new prefix was introduced, as described in [RFC4192] for example. In such cases a DNS server might be configured with such a tokenised interface identifier of ::53, and SLAAC would use the token in constructing the interface address, using the advertised prefix. [...]

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. However, it uses the Netlink interface for configuration resp. data retrival, so that it can be easily extended in future. Successfully tested by myself.

Quoted 4 lines
Cc Hannes Frederic Sowa <[email protected]>
Cc YOSHIFUJI Hideaki <[email protected]>
Cc Thomas Graf <[email protected]>

Applied.

#2 lore raw
In reply to Daniel Borkmann

Sorry, I was a bit busy and just had more time to look at your patch again. Perhaps you could look into my comments. (A new patch would be needed as it already landed in net-next).

net/ipv6/addrconf.c static struct inet6_dev *ipv6_add_dev(struct net_device *dev) · line 425

Quoted 9 lines · Daniel Borkmann
net/ipv6/addrconf.c +1 -0
index a33b157..65d8139 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));

ndev is allocated with __GFP_ZERO so no need to clear it. Otherwise I would do

ndev->token = in6addr_any;

to make the check in addrconf_prefix_rcv more clear.

Quoted 8 lines
net/ipv6/addrconf.c +8 -0
+static int inet6_set_iftoken(struct inet6_dev *idev, struct in6_addr *token)
+{
+	struct in6_addr ll_addr;
+	struct inet6_ifaddr *ifp;
+	struct net_device *dev = idev->dev;
+
+	if (token == NULL)
+		return -EINVAL;

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

Quoted 10 lines
net/ipv6/addrconf.c +10 -0
+	if (ipv6_addr_any(token))
+		return -EINVAL;
+	if (dev->flags & (IFF_LOOPBACK | IFF_NOARP))
+		return -EINVAL;
+	if (idev->dead || !(idev->if_flags & IF_READY))
+		return -EINVAL;
+	if (!ipv6_accept_ra(idev))
+		return -EINVAL;
+	if (idev->cnf.rtr_solicits <= 0)
+		return -EINVAL;

IF_READY marks an interface which is already up. So we are not allowed to set a token on an interface which is down? I would drop this requirement, seems like a usability issue. ;)

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

Quoted 8 lines
net/ipv6/addrconf.c +8 -0
+
+	write_lock_bh(&idev->lock);
+
+	BUILD_BUG_ON(sizeof(token->s6_addr) != 16);
+	memcpy(idev->token.s6_addr + 8, token->s6_addr + 8, 8);
+
+	write_unlock_bh(&idev->lock);
+

{

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

Quoted 5 lines
net/ipv6/addrconf.c +5 -0
+	ipv6_get_lladdr(dev, &ll_addr, IFA_F_TENTATIVE | IFA_F_OPTIMISTIC);
+	ndisc_send_rs(dev, &ll_addr, &in6addr_linklocal_allrouters);
+
+	write_lock_bh(&idev->lock);
+	idev->if_flags |= IF_RS_SENT;

}

This should then be only called if IF_READY is set. Otherwise normal ifup handling will send out the rs. If one day there is the possibility to add more than one token we would actually have to check the minimum solicitation intervals. I think this does not matter now.

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

Quoted 11 lines
net/ipv6/addrconf.c +11 -0
+
+	/* Well, that's kinda nasty ... */
+	list_for_each_entry(ifp, &idev->addr_list, if_list) {
+		spin_lock(&ifp->lock);
+		if (ipv6_addr_src_scope(&ifp->addr) ==
+		    IPV6_ADDR_SCOPE_GLOBAL) {
+			ifp->valid_lft = 0;
+			ifp->prefered_lft = 0;
+		}
+		spin_unlock(&ifp->lock);
+	}

As I understand this logic it also does deprecate current statically configured ip addresses? Perhaps another per-inet6_ifaddr flag to mark the ip address as token configured and just clean these address.

The flag would have to be set in addrconf_prefix_rcv if tokens are active.

Thanks,

Hannes

#3 lore raw
Quoted 3 lines · Hannes Frederic Sowa

Sorry, I was a bit busy and just had more time to look at your patch again. Perhaps you could look into my comments. (A new patch would be needed as it already landed in net-next).

Right, I'll prepare this follow-up patch(es) by tomorrow. Thanks for your feedback Hannes!

Quoted 84 lines · Daniel Borkmann

net/ipv6/addrconf.c static struct inet6_dev *ipv6_add_dev(struct net_device *dev) · line 425

Quoted 9 lines
net/ipv6/addrconf.c +1 -0
index a33b157..65d8139 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));

ndev is allocated with __GFP_ZERO so no need to clear it. Otherwise I would do

ndev->token = in6addr_any;

to make the check in addrconf_prefix_rcv more clear.

Quoted 8 lines
net/ipv6/addrconf.c +8 -0
+static int inet6_set_iftoken(struct inet6_dev *idev, struct in6_addr *token)
+{
+	struct in6_addr ll_addr;
+	struct inet6_ifaddr *ifp;
+	struct net_device *dev = idev->dev;
+
+	if (token == NULL)
+		return -EINVAL;

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

Quoted 10 lines
net/ipv6/addrconf.c +10 -0
+	if (ipv6_addr_any(token))
+		return -EINVAL;
+	if (dev->flags & (IFF_LOOPBACK | IFF_NOARP))
+		return -EINVAL;
+	if (idev->dead || !(idev->if_flags & IF_READY))
+		return -EINVAL;
+	if (!ipv6_accept_ra(idev))
+		return -EINVAL;
+	if (idev->cnf.rtr_solicits <= 0)
+		return -EINVAL;

IF_READY marks an interface which is already up. So we are not allowed to set a token on an interface which is down? I would drop this requirement, seems like a usability issue. ;)

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

Quoted 8 lines
net/ipv6/addrconf.c +8 -0
+
+	write_lock_bh(&idev->lock);
+
+	BUILD_BUG_ON(sizeof(token->s6_addr) != 16);
+	memcpy(idev->token.s6_addr + 8, token->s6_addr + 8, 8);
+
+	write_unlock_bh(&idev->lock);
+

{

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

Quoted 5 lines
net/ipv6/addrconf.c +5 -0
+	ipv6_get_lladdr(dev, &ll_addr, IFA_F_TENTATIVE | IFA_F_OPTIMISTIC);
+	ndisc_send_rs(dev, &ll_addr, &in6addr_linklocal_allrouters);
+
+	write_lock_bh(&idev->lock);
+	idev->if_flags |= IF_RS_SENT;

}

This should then be only called if IF_READY is set. Otherwise normal ifup handling will send out the rs. If one day there is the possibility to add more than one token we would actually have to check the minimum solicitation intervals. I think this does not matter now.

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

Quoted 11 lines
net/ipv6/addrconf.c +11 -0
+
+	/* Well, that's kinda nasty ... */
+	list_for_each_entry(ifp, &idev->addr_list, if_list) {
+		spin_lock(&ifp->lock);
+		if (ipv6_addr_src_scope(&ifp->addr) ==
+		    IPV6_ADDR_SCOPE_GLOBAL) {
+			ifp->valid_lft = 0;
+			ifp->prefered_lft = 0;
+		}
+		spin_unlock(&ifp->lock);
+	}

As I understand this logic it also does deprecate current statically configured ip addresses? Perhaps another per-inet6_ifaddr flag to mark the ip address as token configured and just clean these address.

The flag would have to be set in addrconf_prefix_rcv if tokens are active.

Thanks,

Hannes