From mboxrd@z Thu Jan 1 00:00:00 1970 From: Subash Abhinov Kasiviswanathan Subject: [PATCH net-next] net: ipv6: Generate random IID for addresses on RAWIP devices Date: Sun, 3 Jun 2018 15:54:34 -0600 Message-ID: <1528062874-19250-1-git-send-email-subashab@codeaurora.org> Cc: Subash Abhinov Kasiviswanathan To: davem@davemloft.net, netdev@vger.kernel.org Return-path: Received: from smtp.codeaurora.org ([198.145.29.96]:43456 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751159AbeFCVzH (ORCPT ); Sun, 3 Jun 2018 17:55:07 -0400 Sender: netdev-owner@vger.kernel.org List-ID: RAWIP devices such as rmnet do not have a hardware address and instead require the kernel to generate a random IID for the temporary addresses. For permanent addresses, the device IID is used along with prefix received. Signed-off-by: Subash Abhinov Kasiviswanathan --- net/ipv6/addrconf.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index f09afc2..e4c4540 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -2230,6 +2230,18 @@ static int addrconf_ifid_ip6tnl(u8 *eui, struct net_device *dev) return 0; } +static int addrconf_ifid_rawip(u8 *eui, struct net_device *dev) +{ + struct in6_addr lladdr; + + if (ipv6_get_lladdr(dev, &lladdr, IFA_F_TENTATIVE)) + get_random_bytes(eui, 8); + else + memcpy(eui, lladdr.s6_addr + 8, 8); + + return 0; +} + static int ipv6_generate_eui64(u8 *eui, struct net_device *dev) { switch (dev->type) { @@ -2252,6 +2264,8 @@ static int ipv6_generate_eui64(u8 *eui, struct net_device *dev) case ARPHRD_TUNNEL6: case ARPHRD_IP6GRE: return addrconf_ifid_ip6tnl(eui, dev); + case ARPHRD_RAWIP: + return addrconf_ifid_rawip(eui, dev); } return -1; } @@ -3286,7 +3300,8 @@ static void addrconf_dev_config(struct net_device *dev) (dev->type != ARPHRD_IP6GRE) && (dev->type != ARPHRD_IPGRE) && (dev->type != ARPHRD_TUNNEL) && - (dev->type != ARPHRD_NONE)) { + (dev->type != ARPHRD_NONE) && + (dev->type != ARPHRD_RAWIP)) { /* Alas, we support only Ethernet autoconfiguration. */ return; } -- 1.9.1