All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josua Mayer <josua.mayer@jm0.eu>
To: linux-bluetooth@vger.kernel.org
Cc: Josua Mayer <josua.mayer@jm0.eu>,
	Jukka Rissanen <jukka.rissanen@linux.intel.com>,
	Michael Scott <mike@foundries.io>,
	Marcel Holtmann <marcel@holtmann.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH RESEND v2 2/3] bluetooth: 6lowpan: check neighbour table for SLAAC
Date: Mon, 13 May 2019 12:12:47 +0200	[thread overview]
Message-ID: <fe6f7db8-d20f-3dd4-3cfa-c9864d0c6f38@jm0.eu> (raw)
In-Reply-To: <20190312191626.20634-1-josua.mayer@jm0.eu>

Like any IPv6 capable device, 6LNs can have multiple addresses assigned
using SLAAC and made known through neighbour advertisements.
After checking the destination address against all peers link-local
addresses, consult the neighbour cache for additional known addresses.

RFC7668 defines the scope of Neighbor Advertisements in Section 3.2.3:
1. "A Bluetooth LE 6LN MUST NOT register its link-local address"
2. "A Bluetooth LE 6LN MUST register its non-link-local addresses with
the 6LBR by sending Neighbor Solicitation (NS) messages ..."

Due to these constranits both the link-local addresses tracked in the
list of 6lowpan peers, and the neighbour cache have to be used when
identifying the 6lowpan peer for a destination address.

Acked-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Tested-by: Michael Scott <mike@foundries.io>
Signed-off-by: Josua Mayer <josua.mayer@jm0.eu>
---
 net/bluetooth/6lowpan.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 50530561da98..29a4f3d65348 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -171,6 +171,7 @@ static inline struct lowpan_peer
*peer_lookup_dst(struct lowpan_btle_dev *dev,
 	struct in6_addr *nexthop;
 	struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
 	int count = atomic_read(&dev->peer_count);
+	struct neighbour *neigh;
  	BT_DBG("peers %d addr %pI6c rt %p", count, daddr, rt);
 @@ -222,6 +223,20 @@ static inline struct lowpan_peer
*peer_lookup_dst(struct lowpan_btle_dev *dev,
 		}
 	}
 +	/* use the neighbour cache for matching addresses assigned by SLAAC
+	 */
+	neigh = __ipv6_neigh_lookup(dev->netdev, nexthop);
+	if (neigh) {
+		list_for_each_entry_rcu(peer, &dev->peers, list) {
+			if (!memcmp(neigh->ha, peer->lladdr, ETH_ALEN)) {
+				neigh_release(neigh);
+				rcu_read_unlock();
+				return peer;
+			}
+		}
+		neigh_release(neigh);
+	}
+
 	rcu_read_unlock();
  	return NULL;
-- 
2.21.0


  parent reply	other threads:[~2019-05-13 10:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-08 15:25 [PATCH 0/3] bluetooth: 6lowpan: multiple peers and addresses Josua Mayer
2019-02-08 15:25 ` [PATCH 1/3] bluetooth: 6lowpan: search for destination address in all peers Josua Mayer
2019-02-08 15:25 ` [PATCH 2/3] bluetooth: 6lowpan: check neighbour table for SLAAC Josua Mayer
2019-03-07 10:41   ` Johan Hedberg
2019-03-12 16:23     ` Josua Mayer
2019-02-08 15:25 ` [PATCH 3/3] bluetooth: 6lowpan: always check destination address Josua Mayer
2019-02-28 20:00 ` [PATCH 0/3] bluetooth: 6lowpan: multiple peers and addresses Josua Mayer
2019-02-28 20:30   ` Michael Scott
2019-03-06 18:10     ` Michael Scott
2019-03-07  9:16       ` Jukka Rissanen
2019-03-12 19:16 ` [PATCH v2 " Josua Mayer
2019-03-12 19:16   ` [PATCH v2 1/3] bluetooth: 6lowpan: search for destination address in all peers Josua Mayer
2019-03-12 19:16   ` [PATCH v2 2/3] bluetooth: 6lowpan: check neighbour table for SLAAC Josua Mayer
2019-03-12 19:16   ` [PATCH v2 3/3] bluetooth: 6lowpan: always check destination address Josua Mayer
2019-03-30 15:51   ` [PATCH v2 0/3] bluetooth: 6lowpan: multiple peers and addresses Josua Mayer
2019-05-13 10:11   ` [PATCH RESEND v2 1/3] bluetooth: 6lowpan: search for destination address in all peers Josua Mayer
2019-05-13 10:12   ` [PATCH RESEND v2 3/3] bluetooth: 6lowpan: always check destination address Josua Mayer
2019-05-13 10:12   ` Josua Mayer [this message]
2019-05-13 10:11 ` [PATCH RESEND v2 0/3] bluetooth: 6lowpan: multiple peers and addresses Josua Mayer
2019-07-06 11:11   ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe6f7db8-d20f-3dd4-3cfa-c9864d0c6f38@jm0.eu \
    --to=josua.mayer@jm0.eu \
    --cc=davem@davemloft.net \
    --cc=johan.hedberg@gmail.com \
    --cc=jukka.rissanen@linux.intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mike@foundries.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.