From patchwork Thu Mar 2 13:23:30 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: 734605 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vYtXh2bQ4z9s7m for ; Fri, 3 Mar 2017 00:32:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TOu0dYdj"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752422AbdCBNc3 (ORCPT ); Thu, 2 Mar 2017 08:32:29 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36595 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753024AbdCBNcZ (ORCPT ); Thu, 2 Mar 2017 08:32:25 -0500 Received: by mail-lf0-f66.google.com with SMTP id g70so4746392lfh.3; Thu, 02 Mar 2017 05:32:23 -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=eHPOtmwgaWs0ct/wypRi8S74EZwv8OU2ZNScjhjIkl8=; b=TOu0dYdjXbVefxcSPPBj3tdbn8gn6fZAKK3KEsME0+R/Oj43xtonDZUADauibFL8Af uB4Ulw4qv5e6zAU2aY6JIcOFIpxfTk9kIvo21edCcH/vZHvkYDjs8iIHPQduZiuKEqj5 SUq7eCPsiXhE15cwZ5FnMk8SeL2xF26+x96G5nTAbzHLuaX5IIX6y5rIfxRvIEotnPM4 kOWIFEp+JVDWP+pAcn3lXNKH0xUTJcuRB7zgy8U5suroqeOsmZiNRqKOZ+JAf6gRb+FN bdVLmXmhp1LBfaCuC9WXJ54mG7AhzNmFNGnYIW0yYIu5R5Oo41NZcRbuLj00GUWVZIFh fjdQ== 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=eHPOtmwgaWs0ct/wypRi8S74EZwv8OU2ZNScjhjIkl8=; b=dtwkIH5qtL7kHI7h8UDPpwCVCJpG/LI24AzCEy+jqDsPke5Qa4fLS6S+Khsc6NeVDb vTwoXzBRI0H+x/GCUx+ftm3mlRv64gCdKbnRf0pKGj6MTVDWx+42uz0jweDG+hT2xKai alQrtjK5zyekuRxiVL4C6IordXqSqq5BogUH/4zVk1uFzn2Xngv5PGFU6YZFaCV+px71 tsgFx0aGFHR6cOErzLAOww2O3XzPQU70lt2kApF2Xs3DdYoy7DuD8zSVnVq+Mdy8BD+5 V/Rs33Ole3G6qapWzde0D1SAdxsspYBsIUrMYFCj4e1qDPN2R8ER0BM68kAp4Q0Ll5/2 OD4A== X-Gm-Message-State: AMke39nTI0h2/Z8Fmi4orhz2a+Gf0xhuI822ScF4gtm4fTo1I7VXtadR+DXpZnzh6z9uXQ== X-Received: by 10.25.217.153 with SMTP id s25mr2575902lfi.8.1488461020077; Thu, 02 Mar 2017 05:23:40 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 05:23:39 -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 1/6] bluetooth: Set 6 byte device addresses Date: Thu, 2 Mar 2017 15:23:30 +0200 Message-Id: <20170302132335.21192-2-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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Patrik Flykt Set BTLE MAC addresses that are 6 bytes long and not 8 bytes that are used in other places with 6lowpan. Signed-off-by: Patrik Flykt Signed-off-by: Luiz Augusto von Dentz Reviewed-by: Stefan Schmidt --- net/bluetooth/6lowpan.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 1904a93..1456b01 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -80,6 +80,8 @@ struct lowpan_btle_dev { struct delayed_work notify_peers; }; +static void set_addr(u8 *eui, u8 *addr, u8 addr_type); + static inline struct lowpan_btle_dev * lowpan_btle_dev(const struct net_device *netdev) { @@ -272,9 +274,10 @@ static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev) static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev, struct l2cap_chan *chan) { - const u8 *saddr, *daddr; + const u8 *saddr; struct lowpan_btle_dev *dev; struct lowpan_peer *peer; + unsigned char eui64_daddr[EUI64_ADDR_LEN]; dev = lowpan_btle_dev(netdev); @@ -285,9 +288,9 @@ static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev, return -EINVAL; saddr = peer->eui64_addr; - daddr = dev->netdev->dev_addr; + set_addr(&eui64_daddr[0], chan->src.b, chan->src_type); - return lowpan_header_decompress(skb, netdev, daddr, saddr); + return lowpan_header_decompress(skb, netdev, &eui64_daddr, saddr); } static int recv_pkt(struct sk_buff *skb, struct net_device *dev, @@ -681,13 +684,6 @@ static void set_addr(u8 *eui, u8 *addr, u8 addr_type) BT_DBG("type %d addr %*phC", addr_type, 8, eui); } -static void set_dev_addr(struct net_device *netdev, bdaddr_t *addr, - u8 addr_type) -{ - netdev->addr_assign_type = NET_ADDR_PERM; - set_addr(netdev->dev_addr, addr->b, addr_type); -} - static void ifup(struct net_device *netdev) { int err; @@ -803,7 +799,8 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev) if (!netdev) return -ENOMEM; - set_dev_addr(netdev, &chan->src, chan->src_type); + netdev->addr_assign_type = NET_ADDR_PERM; + baswap((void *)netdev->dev_addr, &chan->src); netdev->netdev_ops = &netdev_ops; SET_NETDEV_DEV(netdev, &chan->conn->hcon->hdev->dev);