From patchwork Thu Mar 2 13:23:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 9600267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 718D760453 for ; Thu, 2 Mar 2017 13:32:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62CF5284A5 for ; Thu, 2 Mar 2017 13:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57C10284E7; Thu, 2 Mar 2017 13:32:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC666284A5 for ; Thu, 2 Mar 2017 13:32:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753149AbdCBNcz (ORCPT ); Thu, 2 Mar 2017 08:32:55 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35576 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753138AbdCBNcv (ORCPT ); Thu, 2 Mar 2017 08:32:51 -0500 Received: by mail-lf0-f65.google.com with SMTP id z127so5751704lfa.2; Thu, 02 Mar 2017 05:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=smxUq7KcgXn6PZnwwlmYvsAY75jVFYNae6LoYPHvf6I=; b=ttVYeM9uwhTzg3lZ9unpSNs9LSX8ZPu6ON/cpD3k13P5Rwnkt/Dko1QNbGQg7spHKt ldlnZu2KhmT8d8TprE7mH/TPFb3O43TBkwrZt7Dkvhgtb2IWbYG48zaWcP1CqRWfI5rc 3vUSiAP5Gc/cqfzytp0U7xNl9ZaH7oVvA5QfR7yzc3LXI46nPZ7sWrgPNKz5lhZ+6cB4 YPt3vq3CV6P2TL59v4KMMfImpbKpXVKgxXqPJNU0UJKHB/sCsNAXBJZe7GqhWEezH3N3 Icl0e7B4x2aCfqPjUAQVwq9aKgYaYQPO6DEdKxAbJtYwwmcVFa9hpHgXzN5NfQer8HS4 E8Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=smxUq7KcgXn6PZnwwlmYvsAY75jVFYNae6LoYPHvf6I=; b=SFrZnykk4lqeFI56KKew/yY5gOg+SkjWchGGgAeJPg//iRh+YtH0Gf8BcWQQkLHQrR eu7tmWs39lazgVWG8lEHVrUomk6aCi6fIG0MKdtTSVDmk6TiqBnRJJ6zA2yRqKTgCp2k Zu4JtLF4tiDR0JZ++eBQnx7H8ConJ7TYjMYBgrrLd05psSGFdPpC6xJnxC/GNYOg8Oqs qCkeoLy7uH2ezEEpHA22AZs4Z8uWaNINBCT/AS6xwrUNrs0+B1PIR2U1o4gHtYll9Hx4 MCJf/aYms/Sis/WOb0tDqxh+8KMSljif1NtBg8FbSdaAIvVpbKDbY5Uh/vp/8RReXXHD fVIA== X-Gm-Message-State: AMke39lP/eYSKKHcplDMulpeTT/7kJLMWeQ+Ev6V7PBXxQZs1DSZcVMjncCpl30U9rWv4A== X-Received: by 10.46.81.18 with SMTP id f18mr4824299ljb.136.1488461024673; Thu, 02 Mar 2017 05:23:44 -0800 (PST) Received: from localhost.localdomain (85-76-69-169-nat.elisa-mobile.fi. [85.76.69.169]) by smtp.gmail.com with ESMTPSA id b72sm1700349lfb.24.2017.03.02.05.23.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 05:23:44 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Cc: patrik.flykt@linux.intel.com, aar@pengutronix.de, jukka.rissanen@linux.intel.com, linux-wpan@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v6 4/6] ipv6: addrconf: fix 48 bit 6lowpan autoconfiguration Date: Thu, 2 Mar 2017 15:23:33 +0200 Message-Id: <20170302132335.21192-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170302132335.21192-1-luiz.dentz@gmail.com> References: <20170302132335.21192-1-luiz.dentz@gmail.com> Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Alexander Aring This patch adds support for 48 bit 6LoWPAN address length autoconfiguration which is the case for BTLE 6LoWPAN. Signed-off-by: Alexander Aring Signed-off-by: Luiz Augusto von Dentz Reviewed-by: Stefan Schmidt Acked-by: David S. Miller --- net/ipv6/addrconf.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 3a2025f..7756640 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -2052,12 +2052,19 @@ static void addrconf_leave_anycast(struct inet6_ifaddr *ifp) __ipv6_dev_ac_dec(ifp->idev, &addr); } -static int addrconf_ifid_eui64(u8 *eui, struct net_device *dev) +static int addrconf_ifid_6lowpan(u8 *eui, struct net_device *dev) { - if (dev->addr_len != EUI64_ADDR_LEN) + switch (dev->addr_len) { + case ETH_ALEN: + return addrconf_ifid_eui48(eui, dev); + case EUI64_ADDR_LEN: + memcpy(eui, dev->dev_addr, EUI64_ADDR_LEN); + eui[0] ^= 2; + break; + default: return -1; - memcpy(eui, dev->dev_addr, EUI64_ADDR_LEN); - eui[0] ^= 2; + } + return 0; } @@ -2149,7 +2156,7 @@ static int ipv6_generate_eui64(u8 *eui, struct net_device *dev) case ARPHRD_TUNNEL: return addrconf_ifid_gre(eui, dev); case ARPHRD_6LOWPAN: - return addrconf_ifid_eui64(eui, dev); + return addrconf_ifid_6lowpan(eui, dev); case ARPHRD_IEEE1394: return addrconf_ifid_ieee1394(eui, dev); case ARPHRD_TUNNEL6: