From patchwork Tue Feb 21 10:38:06 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: 9584221 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 019106042F for ; Tue, 21 Feb 2017 10:38:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8BB728805 for ; Tue, 21 Feb 2017 10:38:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD9E3288E2; Tue, 21 Feb 2017 10:38:56 +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 B544228805 for ; Tue, 21 Feb 2017 10:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751563AbdBUKiZ (ORCPT ); Tue, 21 Feb 2017 05:38:25 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:36813 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751629AbdBUKiR (ORCPT ); Tue, 21 Feb 2017 05:38:17 -0500 Received: by mail-lf0-f65.google.com with SMTP id 90so3246924lfr.3; Tue, 21 Feb 2017 02:38:16 -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=ox1pZ8t9eHhDyQKhemzWaVcahFumL1MJotk9htlHgqvJF2y0Py/IWdbDol+b8qyEMp UT7k1cXr4pIczX0TZIEExT7qYsyJasFSqeXLawc+Y0PJ8w/ERaGeX5FrP73IaTjyuyQ3 XGpd1anbryO4o0+qJd0FR7D2HB8S2eOeeDmVGTWFaeqOTLzlAX77QveIT7V2Uq3InUdS 3+TvedjmTtf4ufdGsyQrheW+XobZq3SfwQIyAwf/qn0pu4ybThrgL5wX98pNV6bM6As7 jGtUlEd/eSk8H+Mise1iPzzkMQrhHKpWi1/tuFadTO3NEfIU8Hn1wFJfwMy2LixEMlFS hNuQ== 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=AsEioXxLRdhrwToz+7qVt+YyODv1lAFmaYmXEefPBVJs75Jtig0KuR3d/7Ob/VMK6P dGOdZ+9tb/fZuh1IZdlyn3B0xez4RGWSKRJvg+jOwXEf5wkvchTrh+H7AbpYLz0lNd6u es7UDAvJ/26GeZhPZ5mJmAeqW0H87KkuU6egGns/JCBbzgoF92x/x3FsrJo+++Pgf82l 71VtLwL3s8Gsnm+KNmt77umFvIx+lGPf2eh8E1FyN76xMz0zTP86ttbKwVuDqSxhb2rS 6Ij32ZqLih5YCAT49Y0nPO8exptT2CuHXuF3KFsiaAiWO3HrlwYJyAoxNx8zCXRSRs7a KeaQ== X-Gm-Message-State: AMke39m/2qvtz5jDzu/QvBQxpjgUps2NpXYF7oR5aXEpT0cbj/Zute0jHN1RhH+Nr/PCzg== X-Received: by 10.25.168.132 with SMTP id r126mr6478960lfe.70.1487673495710; Tue, 21 Feb 2017 02:38:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Feb 2017 02:38:14 -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 1/5] bluetooth: Set 6 byte device addresses Date: Tue, 21 Feb 2017 12:38:06 +0200 Message-Id: <20170221103811.1506-2-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: 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);