From patchwork Tue Feb 21 10:38:10 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: 9584215 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 0668C6042F for ; Tue, 21 Feb 2017 10:38:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEDC128805 for ; Tue, 21 Feb 2017 10:38:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3B03288DD; Tue, 21 Feb 2017 10:38:40 +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 3B24228805 for ; Tue, 21 Feb 2017 10:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751954AbdBUKij (ORCPT ); Tue, 21 Feb 2017 05:38:39 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34827 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751848AbdBUKiX (ORCPT ); Tue, 21 Feb 2017 05:38:23 -0500 Received: by mail-lf0-f68.google.com with SMTP id z127so8755296lfa.2; Tue, 21 Feb 2017 02:38:22 -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=vN7XiL64zg+xx7KvQuJ24DrCxxUtyJhO6r45oU/Xv8ed0TxSE2Pd4RYxl7LJfdT6P2 e7cwY+tD+y15Y6cCTk7+iw0LAGBawG0fVHSfZEWxENsRGu7WCXNH84C0Ozv/Y1GfJ3RR 6qpaLWhfyH5k//e4mHAcuNoke+hLV2/J1hqlHQVN8sOYszP6j/qejESUdSHyczixM5oa hXy8CKCUx701zRlk5aiiZ98yTiwKAK1DM9Mm9v8GPh+FKv3CI5W5yFQsj4FqcNlK2Xe5 oUAkaFxADFFCYPbLS/5y4jIiqcI9nw/6oKUIUmZULFkTCTIhXv07OWcC+UVjFj1+jEV+ 0jOA== 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=SD9N/0pD4zBtZLH/9uAYmzx50DhzwyTlUeXzTbZ72N8OvIo2tP791KTh4i9/QEFD9b Er0/AE4ABKB0mvJHv5LFUVyvqPoS+Z0X9YPAS4ci+cpiO8RQHng0DWAIsAMNJDDsKEZZ rKjKqrTsYu0F1ROnmQSK0sNQBPwhniTFzLR3E3Ni4v2r9LwDJ3Uy9YScIu1Y8VbUUgqw lycP9V5JcuoYvFd3Unc8Qxwo/eG4G8luHo9oSwQ1pHO8M3ITXq/zPR/fo0fFm9JFeiAw y3xhTFfebSSiy3Z03KxOKLQ/c8bBHjfcT4/erodhX9HbeH07YX2LPCD6eyVpQq7Y4Vjr OWkw== X-Gm-Message-State: AMke39mlI0lyEdFRPMliQZPELi+7WlsvvWlIcbRVTlBtFoCEqFQxIUjuMfxYRWR6MVryAQ== X-Received: by 10.25.193.145 with SMTP id r139mr7168574lff.73.1487673500204; Tue, 21 Feb 2017 02:38:20 -0800 (PST) Received: from localhost.localdomain ([2001:998:22:0:4f7c:5e8e:5bc:71bd]) by smtp.gmail.com with ESMTPSA id f137sm469811lff.21.2017.02.21.02.38.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 02:38:19 -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, netdev@vger.kernel.org Subject: [PATCH v4 4/5] ipv6: addrconf: fix 48 bit 6lowpan autoconfiguration Date: Tue, 21 Feb 2017 12:38:10 +0200 Message-Id: <20170221103811.1506-6-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170221103811.1506-1-luiz.dentz@gmail.com> References: <20170221103811.1506-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: