From patchwork Thu Feb 16 17:19:45 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: 9577759 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 4473560586 for ; Thu, 16 Feb 2017 17:20:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36E9228623 for ; Thu, 16 Feb 2017 17:20:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C03C2862C; Thu, 16 Feb 2017 17:20:00 +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 D34C028623 for ; Thu, 16 Feb 2017 17:19:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932653AbdBPRT7 (ORCPT ); Thu, 16 Feb 2017 12:19:59 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35220 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932645AbdBPRT5 (ORCPT ); Thu, 16 Feb 2017 12:19:57 -0500 Received: by mail-lf0-f65.google.com with SMTP id v186so1984325lfa.2; Thu, 16 Feb 2017 09:19:56 -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=FjZN5O8gdMmPxv1dvqIANG0a1GB0wh6qh+A6Vo3AEMNHNPGCeIgIS2bHkxNzVMW0UC 0DpK/jlo7v3/jl1hly72agO7hwSh/yYa+i/EUfo4/426VAvK16zW4RdpO6qVM8RgItYk zSgdTCGcBn9/3+6l0d1mKLmxrck7nuO15eeMF1+tOP1OI+vF/wO63Y+RBAvwTip6Wsno krUMFAOMcdYp347aQYeMIzCzVaZLNoSAIZNkGC3x/8r+hpKClUQiIeMmIKBK5Uh1yVHS Y3VVf8XCaZwSWD0r2z+Y4ZjX1J2hntTZwp/VhoZDG4fXsZyMZiIeAKmJtrdQWasAh6d+ wwvw== 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=l5giTXOt5XkDPgfrBYAiChoBChl2cM+/07m5V2vEI6JHV7MHlFlyGRgNJs6BR7Frlo gBL0D8V9xqAeT6YIJngSZDXdDq87xMD2rIkGBS2tPztPlzBIlCQEPsSywlsrpxEeTNnZ HdqUNZcWSjkGd45ce1xRQxysp7GY8KtViLMG5EWaecPc1XpdAQvHQps0TN9pgZzgBJxY T1+z1jZJWhMgFK+koCNGBDuTdhlLbWBTACUMl6M5YhEn67toF7an9OjrOokLs26/f3kz 998EbqvlfJMmd0hLjMw2YhTETH0Rl2DaN5oSX8mK+nuDrww3X8xbcfGI9iLzwCdbtJzT +IlA== X-Gm-Message-State: AMke39nc8m15JkQqPp/t0Opbj/dwsCgBmLPRZ6ZiEGmrreuAHFcJiLM0hz39hGTAq4ctwA== X-Received: by 10.25.242.3 with SMTP id q3mr1072794lfh.135.1487265595506; Thu, 16 Feb 2017 09:19:55 -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 187sm1874292ljj.7.2017.02.16.09.19.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 09:19:53 -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 v2 4/5] ipv6: addrconf: fix 48 bit 6lowpan autoconfiguration Date: Thu, 16 Feb 2017 19:19:45 +0200 Message-Id: <20170216171946.5105-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170216171946.5105-1-luiz.dentz@gmail.com> References: <20170216171946.5105-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: