From patchwork Fri Feb 24 12:14:38 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: 9590007 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 B3F24601AE for ; Fri, 24 Feb 2017 12:15:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD6702872D for ; Fri, 24 Feb 2017 12:15:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D064B28783; Fri, 24 Feb 2017 12:15:58 +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 84FF52872D for ; Fri, 24 Feb 2017 12:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751393AbdBXMPU (ORCPT ); Fri, 24 Feb 2017 07:15:20 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34653 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751246AbdBXMPB (ORCPT ); Fri, 24 Feb 2017 07:15:01 -0500 Received: by mail-lf0-f68.google.com with SMTP id x142so469673lfd.1; Fri, 24 Feb 2017 04:14:48 -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=Efn7BndvUYcF+JAX9zmmTQuN35lrIg5shv8yS5fYBMA=; b=EgIN3wYphpGc6Ze6mJnMNRhICoXYICvBFDHdK1awetC3go2Bn0p+v6mYvUMaXdSug1 j1jMLKjn6TMcQhjd6cOVqConWv1f/0asYTgOnKBFXWDwzkLcfjJbRjpKVIZF6h/Gc5f6 0iEvVZGiLYDLyHNoKDAXKZR929uVRvZEl7T3pn5nJGjD4ebSr21C9FmXQ6Pl7E5NIc6C nCMlTjrbUDjAro1/UK9nuoMifNZgzFkZGposHPGSVium1/xbZX804RVlVnhAQXWbRfdb i3Io4AQw7UJMP8NRjtVskn1GN34HwCBbYRiqVYGOjwFNbvC1ApGAgJgytaixIycTbxYw bmlA== 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=Efn7BndvUYcF+JAX9zmmTQuN35lrIg5shv8yS5fYBMA=; b=Hdn0K6sEaKuo7Vu9VST5+dKCnSlZIRFrPCgR6CbdIQJMcKtPrRTux7qZW2CkOFIUJb BZLs3f7tpXkDESxJ1YFANfOVyso//2wlzb7V3DkmIZViqDGUYgvlU9eBe8w+lVJ4xfgz WSx4W+p70CUFh0DvmL3sSCMuqoiKJcAcimgdQ85isIAiCcFmXYq/nrtQiv3AlkpOsNR8 OkovTYoYf8zWIAoEUA2Y4xyPwVXlKWiIKWCU+bWKFXrVrLcv1rFK/O8AkYxg1MoLz6U0 Id6k8WEBdqYet8ItKuIfjMG1UIAEeDocLbxQ1NXT1Gv6v4J1jS939jmAz51JpGRHkwy4 o7PA== X-Gm-Message-State: AMke39m5kiFIVYNKb0Ph5Op5kn4MxwxNE5tcPoDS+fWeV3jlbikLcZImXNh8AM3qL0H40w== X-Received: by 10.46.20.20 with SMTP id u20mr670445ljd.61.1487938487342; Fri, 24 Feb 2017 04:14:47 -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 26sm8569196ljo.21.2017.02.24.04.14.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 04:14:46 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Cc: patrik.flykt@linux.intel.com, jukka.rissanen@linux.intel.com, stefan@osg.samsung.com, aar@pengutronix.de, linux-wpan@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 4/6] ipv6: addrconf: fix 48 bit 6lowpan autoconfiguration Date: Fri, 24 Feb 2017 14:14:38 +0200 Message-Id: <20170224121440.32269-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170224121440.32269-1-luiz.dentz@gmail.com> References: <20170224121440.32269-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 --- 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: