From patchwork Fri Feb 17 15:50:02 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: 9580253 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 E48866042F for ; Fri, 17 Feb 2017 15:50:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D704728724 for ; Fri, 17 Feb 2017 15:50:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC1AF28725; Fri, 17 Feb 2017 15:50:18 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 467A728721 for ; Fri, 17 Feb 2017 15:50:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934226AbdBQPuR (ORCPT ); Fri, 17 Feb 2017 10:50:17 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33040 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934668AbdBQPuO (ORCPT ); Fri, 17 Feb 2017 10:50:14 -0500 Received: by mail-lf0-f65.google.com with SMTP id x1so4150121lff.0; Fri, 17 Feb 2017 07:50:13 -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=VSYbATaW2dj852W6wGMhD2fJ9H27pkpqpxygtUKrtKU=; b=a6+lnR7sAB6s5Y03wEk8aVd3K36w9/XJckfpFs7YDoL3JRA4dEnHxMfob4bUgOISRb 2z2fgHdDFrAB5fC6E2Uo50TwDiUSJ2VWPK+0N9gc8GxfrySdSTxtk7AKqI9KUyhyDG1T lfxYVExI4DU9/0nEQAbsxqSvw5L+WwMQxy7lZbEgOjjlzIWdmMG+pOmibwZnuD2MTWL/ 1gAghWhojMKUEyHpci5lzBMs/uz1fbCo90hMh0OHuPkwVz6nJQfwjpTCJH9Z/fiqWbnJ mdT8yXFRcJ5x4zcNlvZaedPWGwZQDmljyHWm5fyyKHji4t+2wRxY2x4XRyq8k2TIEhRm GcLw== 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=VSYbATaW2dj852W6wGMhD2fJ9H27pkpqpxygtUKrtKU=; b=S071D4bf6hh2oGiATZMpJkIG7B1LTr5DLzK1RMLx6sRBD+iwk3B1cRd+yKL25LTU18 L5WV3YHDs3NyB1GIPSeejYjOAyoICctOLTItKHqTgDg9hX8cGV+2jf2I2rxHNmgCmR/x IE5gemQziLC11X+ulB/TQp2rakwfTXfFBxzJ1pbb5DKEeEKNo7HOmzPeNHqKoxng7A18 qemOVyscDb5ek0GxyqlWxHnTBBpSijhPemzOH6lZT/CL5bgMZPpl4R45PPrOV4DsN9Xb bqHRPosv61VnnIBWkEKEbbIgW4mMDGxXmE3AgxyD1+QJobFo4vQcsMn+VUFtrLITz429 kBrQ== X-Gm-Message-State: AMke39leSG5guzvFO8QdB7j6jgRZbejA8Ix3nCKt6M529dM8XRX8yfFmyxGenSJMB6vv3g== X-Received: by 10.25.161.208 with SMTP id k199mr2355703lfe.165.1487346612810; Fri, 17 Feb 2017 07:50:12 -0800 (PST) Received: from vudentzs-t460s.pp.htv.fi (89-27-7-11.bb.dnainternet.fi. [89.27.7.11]) by smtp.gmail.com with ESMTPSA id c18sm2600726ljd.52.2017.02.17.07.50.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Feb 2017 07:50:12 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Cc: patrik.flykt@linux.intel.com, aar@pengutronix.de, linux-wpan@vger.kernel.org Subject: [PATCH v3 4/5] ipv6: addrconf: fix 48 bit 6lowpan autoconfiguration Date: Fri, 17 Feb 2017 17:50:02 +0200 Message-Id: <20170217155003.4594-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170217155003.4594-1-luiz.dentz@gmail.com> References: <20170217155003.4594-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 --- 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 ac9bd56..dede33f 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -2050,12 +2050,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; } @@ -2146,7 +2153,7 @@ static int ipv6_generate_eui64(u8 *eui, struct net_device *dev) case ARPHRD_IPGRE: 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: