All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address
@ 2016-03-22 13:14 Alexander Aring
  2016-03-22 13:14 ` [RFC bluetooth-next 01/19] ieee802154: cleanups for ieee802154.h Alexander Aring
                   ` (18 more replies)
  0 siblings, 19 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:14 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

Hi,

this patch series introduces a private neighbour dataroom for 6LoWPAN
interfaces. The first use case for such private neighbour data is short
address handling for 802.15.4 6LoWPAN networks.

This private data can also be useful for other upcomming 6lowpan handling,
which need to be stored inside each neighbour for IPv6 (6LoWPAN) neighbour
discovery.

The patch series introduces a generic 6LoWPAN specific neighbour private data
(which is currently emtpy) and an additional linklayer specific neighbour
private data. This linklayer data will be used by 802.15.4 to adding short
address handling.

Future work for generic 6LoWPAN (net/6lowpan) branch will introduce some
additional callbacks for handle generic 6lowpan neighbour private data.
e.g. 6LoWPAN Capability Indication Option [0].


Note:

There exists two notes about this implementation currently:

The first one is about the handling in net/ipv6/ndisc.c:
I am not sure if we should implement it in this way, with a lot of #ifdefs
and runtime decisions if the interface is a lowpan interface.

Maybe introduce some callback structure to handle "additional" things for
"net/ipv6/ndisc.c" OR create a own neighbour discovery cache inside of
"net/6lowpan/ndisc.c" which will use some function from "net/ipv6/ndisc.c"
(simple remove some static and add EXPORT_SYMBOL).

In my opinion the "net/6lowpan/ndisc.c" which use functions From
"net/ipv6/ndisc.c" will be the best option. There are too much outside and
the ipv6 ndisc implementation will be more complex if we put ipv6 and 6lowpan
nd implementation into one file. e.g. RFC 6775 [1] also describe a different
handling for 6LoWPAN-ND.

Of course, we need then an own UAPI and tool to dump the 6LoWPAN related
neighbour data.


The second note is: I have no glue if the short address handling is RFC
compliant.

How it works currently is that the short address is an optional address option
inside of NA/NS (of course we need also the address option in RS). It will not
work when an extended address option isn't there. In my opinion an extended
address field is always there because this address is always available.

If I am wrong, then we need to add some dummy extended addr (maybe all
zero-extended, but "ip -6 neigh will be look somewhat wrong then. :-) ).
We currently doesn't accept a NA/NS which don't has the extended address
inside the option fields.

If there exists a valid source address on the link, then extended address and
short address will be added to the option. The length field inside the option
field will be indicated if extended or short, see [2]. In case no valid source
address is there, then the extended address option will be added.


Another 6LoWPAN stack RIOT will do a complete different handling here:
It add extended address XOR short address to the NS/NA messages, depends on
configuration. It also drops NS/NA messages which contains two address options.
So I can't test it, I don't know which way is the correct way, if RIOT do it
right then I think we don't need to have a private data for each neighbour,
because we can handle dev->addr as extended or short then, but I think RIOT
is wrong here.

Future handling of this patch series:

I will try to get at first the 802.15.4/6LoWPAN stuff mainline which doesn't
include the ipv6/ndisc changes.

- Alex

[0] https://tools.ietf.org/html/rfc7400
[1] https://tools.ietf.org/html/rfc6775
[2] https://tools.ietf.org/html/rfc4944#section-8

Alexander Aring (19):
  ieee802154: cleanups for ieee802154.h
  ieee802154: add short address helpers
  nl802154: avoid address change while running lowpan
  ieee802154: 6lowpan: fix short addr hash
  6lowpan: change naming for lowpan private data
  6lowpan: move lowpan_802154_dev to 6lowpan
  6lowpan: iphc: rename add lowpan prefix
  6lowpan: iphc: remove unnecessary zero data
  6lowpan: move eui64 uncompress function
  6lowpan: add lowpan_is_ll function
  6lowpan: move mac802154 header
  6lowpan: add private neighbour data
  addrconf: add 802.15.4 short addr slaac
  ndisc: add addr_len parameter to ndisc_opt_addr_space
  ndisc: add addr_len parameter to ndisc_opt_addr_data
  ndisc: add addr_len parameter to ndisc_fill_addr_option
  ndisc: add short address to ndisc opts parsing
  ndisc: add support for short address option
  6lowpan: add support for 802.15.4 short addr handling

 include/linux/ieee802154.h         |  35 +++++-
 include/linux/netdevice.h          |   3 +-
 include/net/6lowpan.h              |  68 +++++++++++-
 include/net/mac802154.h            |  10 ++
 include/net/ndisc.h                |  20 ++--
 net/6lowpan/core.c                 |   8 +-
 net/6lowpan/debugfs.c              |  22 ++--
 net/6lowpan/iphc.c                 | 198 ++++++++++++++++++++--------------
 net/6lowpan/nhc_udp.c              |   2 +-
 net/bluetooth/6lowpan.c            |  84 ++++++++-------
 net/ieee802154/6lowpan/6lowpan_i.h |  14 +--
 net/ieee802154/6lowpan/core.c      |  18 +++-
 net/ieee802154/6lowpan/tx.c        | 131 ++++++++++++-----------
 net/ieee802154/nl802154.c          |  10 ++
 net/ipv6/addrconf.c                |  40 +++++++
 net/ipv6/ndisc.c                   | 214 ++++++++++++++++++++++++++++++++-----
 net/ipv6/route.c                   |   4 +-
 17 files changed, 628 insertions(+), 253 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 01/19] ieee802154: cleanups for ieee802154.h
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
@ 2016-03-22 13:14 ` Alexander Aring
  2016-03-23  9:59   ` Stefan Schmidt
  2016-03-22 13:14 ` [RFC bluetooth-next 02/19] ieee802154: add short address helpers Alexander Aring
                   ` (17 subsequent siblings)
  18 siblings, 1 reply; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:14 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch removes some const from non-pointer types and fixes the
function name for the ieee802154_is_valid_extended_unicast_addr
comment.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/linux/ieee802154.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index d3e4156..303f446 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -260,17 +260,17 @@ static inline bool ieee802154_is_intra_pan(__le16 fc)
  *
  * @len: psdu len with (MHR + payload + MFR)
  */
-static inline bool ieee802154_is_valid_psdu_len(const u8 len)
+static inline bool ieee802154_is_valid_psdu_len(u8 len)
 {
 	return (len == IEEE802154_ACK_PSDU_LEN ||
 		(len >= IEEE802154_MIN_PSDU_LEN && len <= IEEE802154_MTU));
 }
 
 /**
- * ieee802154_is_valid_psdu_len - check if extended addr is valid
+ * ieee802154_is_valid_extended_unicast_addr - check if extended addr is valid
  * @addr: extended addr to check
  */
-static inline bool ieee802154_is_valid_extended_unicast_addr(const __le64 addr)
+static inline bool ieee802154_is_valid_extended_unicast_addr(__le64 addr)
 {
 	/* Bail out if the address is all zero, or if the group
 	 * address bit is set.
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 02/19] ieee802154: add short address helpers
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
  2016-03-22 13:14 ` [RFC bluetooth-next 01/19] ieee802154: cleanups for ieee802154.h Alexander Aring
@ 2016-03-22 13:14 ` Alexander Aring
  2016-03-23  9:59   ` Stefan Schmidt
  2016-03-22 13:14 ` [RFC bluetooth-next 03/19] nl802154: avoid address change while running lowpan Alexander Aring
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:14 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch introduce some short address handling functionality into
ieee802154 headers.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/linux/ieee802154.h | 29 +++++++++++++++++++++++++++++
 include/net/mac802154.h    | 10 ++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index 303f446..3b3ea58 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -47,6 +47,7 @@
 #define IEEE802154_ADDR_SHORT_UNSPEC	0xfffe
 
 #define IEEE802154_EXTENDED_ADDR_LEN	8
+#define IEEE802154_SHORT_ADDR_LEN	2
 
 #define IEEE802154_LIFS_PERIOD		40
 #define IEEE802154_SIFS_PERIOD		12
@@ -280,6 +281,34 @@ static inline bool ieee802154_is_valid_extended_unicast_addr(__le64 addr)
 }
 
 /**
+ * ieee802154_is_broadcast_short_addr - check if short addr is broadcast
+ * @addr: short addr to check
+ */
+static inline bool ieee802154_is_broadcast_short_addr(__le16 addr)
+{
+	return addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST);
+}
+
+/**
+ * ieee802154_is_unspec_short_addr - check if short addr is unspecified
+ * @addr: short addr to check
+ */
+static inline bool ieee802154_is_unspec_short_addr(__le16 addr)
+{
+	return addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC);
+}
+
+/**
+ * ieee802154_is_valid_src_short_addr - check if source short address is valid
+ * @addr: short addr to check
+ */
+static inline bool ieee802154_is_valid_src_short_addr(__le16 addr)
+{
+	return !(ieee802154_is_broadcast_short_addr(addr) ||
+		 ieee802154_is_unspec_short_addr(addr));
+}
+
+/**
  * ieee802154_random_extended_addr - generates a random extended address
  * @addr: extended addr pointer to place the random address
  */
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 6cd7a70..e465c85 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -288,6 +288,16 @@ static inline void ieee802154_le16_to_be16(void *be16_dst, const void *le16_src)
 }
 
 /**
+ * ieee802154_be16_to_le16 - copies and convert be16 to le16
+ * @le16_dst: le16 destination pointer
+ * @be16_src: be16 source pointer
+ */
+static inline void ieee802154_be16_to_le16(void *le16_dst, const void *be16_src)
+{
+	put_unaligned_le16(get_unaligned_be16(be16_src), le16_dst);
+}
+
+/**
  * ieee802154_alloc_hw - Allocate a new hardware device
  *
  * This must be called once for each hardware device. The returned pointer
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 03/19] nl802154: avoid address change while running lowpan
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
  2016-03-22 13:14 ` [RFC bluetooth-next 01/19] ieee802154: cleanups for ieee802154.h Alexander Aring
  2016-03-22 13:14 ` [RFC bluetooth-next 02/19] ieee802154: add short address helpers Alexander Aring
@ 2016-03-22 13:14 ` Alexander Aring
  2016-03-23  9:59   ` Stefan Schmidt
  2016-03-22 13:15 ` [RFC bluetooth-next 04/19] ieee802154: 6lowpan: fix short addr hash Alexander Aring
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:14 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

he whole generating of autoconfiguration IPv6 link-local addresses based
on a notification on interface up. These addresses are based on mac
addresses and are not changeable during interface up of IPv6 interfaces.
This patch will disallow mac address changes while a lowpan interface
for a wpan interface is up.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 net/ieee802154/nl802154.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 16ef0d9..5f1dc4b 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -1074,6 +1074,11 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
 	if (netif_running(dev))
 		return -EBUSY;
 
+	if (wpan_dev->lowpan_dev) {
+		if (netif_running(wpan_dev->lowpan_dev))
+			return -EBUSY;
+	}
+
 	/* don't change address fields on monitor */
 	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR ||
 	    !info->attrs[NL802154_ATTR_PAN_ID])
@@ -1105,6 +1110,11 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
 	if (netif_running(dev))
 		return -EBUSY;
 
+	if (wpan_dev->lowpan_dev) {
+		if (netif_running(wpan_dev->lowpan_dev))
+			return -EBUSY;
+	}
+
 	/* don't change address fields on monitor */
 	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR ||
 	    !info->attrs[NL802154_ATTR_SHORT_ADDR])
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 04/19] ieee802154: 6lowpan: fix short addr hash
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (2 preceding siblings ...)
  2016-03-22 13:14 ` [RFC bluetooth-next 03/19] nl802154: avoid address change while running lowpan Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-23  9:58   ` Stefan Schmidt
  2016-03-22 13:15 ` [RFC bluetooth-next 05/19] 6lowpan: change naming for lowpan private data Alexander Aring
                   ` (14 subsequent siblings)
  18 siblings, 1 reply; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

The short address is unique in combination with the panid. This patch
will add the panid for generating an ieee802154 address hash.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 net/ieee802154/6lowpan/6lowpan_i.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
index b4e17a7..b4092a9 100644
--- a/net/ieee802154/6lowpan/6lowpan_i.h
+++ b/net/ieee802154/6lowpan/6lowpan_i.h
@@ -41,7 +41,7 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
 		return (((__force u64)a->extended_addr) >> 32) ^
 			(((__force u64)a->extended_addr) & 0xffffffff);
 	case IEEE802154_ADDR_SHORT:
-		return (__force u32)(a->short_addr);
+		return (__force u32)(a->short_addr + (a->pan_id << 16));
 	default:
 		return 0;
 	}
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 05/19] 6lowpan: change naming for lowpan private data
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (3 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 04/19] ieee802154: 6lowpan: fix short addr hash Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 06/19] 6lowpan: move lowpan_802154_dev to 6lowpan Alexander Aring
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch changes the naming for interface private data for lowpan
intefaces. The current private data scheme is:

-------------------------------------------------
|    6LoWPAN Generic   |    LinkLayer 6LoWPAN   |
-------------------------------------------------

the current naming schemes are:

- 6LoWPAN Generic:
  - lowpan_priv
- LinkLayer 6LoWPAN:
  - BTLE
    - lowpan_dev
  - 802.15.4:
    - lowpan_dev_info

the new naming scheme with this patch will be:

- 6LoWPAN Generic:
  - lowpan_dev
- LinkLayer 6LoWPAN:
  - BTLE
    - lowpan_802154_dev
  - 802.15.4:
    - lowpan_btle_dev

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/net/6lowpan.h              |  6 +--
 net/6lowpan/core.c                 |  8 ++--
 net/6lowpan/debugfs.c              | 22 +++++-----
 net/6lowpan/iphc.c                 | 38 +++++++++---------
 net/6lowpan/nhc_udp.c              |  2 +-
 net/bluetooth/6lowpan.c            | 82 ++++++++++++++++++++------------------
 net/ieee802154/6lowpan/6lowpan_i.h |  6 +--
 net/ieee802154/6lowpan/core.c      |  6 +--
 net/ieee802154/6lowpan/tx.c        | 14 +++----
 9 files changed, 94 insertions(+), 90 deletions(-)

diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index da3a77d..f204664 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -93,7 +93,7 @@ static inline bool lowpan_is_iphc(u8 dispatch)
 }
 
 #define LOWPAN_PRIV_SIZE(llpriv_size)	\
-	(sizeof(struct lowpan_priv) + llpriv_size)
+	(sizeof(struct lowpan_dev) + llpriv_size)
 
 enum lowpan_lltypes {
 	LOWPAN_LLTYPE_BTLE,
@@ -129,7 +129,7 @@ lowpan_iphc_ctx_is_compression(const struct lowpan_iphc_ctx *ctx)
 	return test_bit(LOWPAN_IPHC_CTX_FLAG_COMPRESSION, &ctx->flags);
 }
 
-struct lowpan_priv {
+struct lowpan_dev {
 	enum lowpan_lltypes lltype;
 	struct dentry *iface_debugfs;
 	struct lowpan_iphc_ctx_table ctx;
@@ -139,7 +139,7 @@ struct lowpan_priv {
 };
 
 static inline
-struct lowpan_priv *lowpan_priv(const struct net_device *dev)
+struct lowpan_dev *lowpan_dev(const struct net_device *dev)
 {
 	return netdev_priv(dev);
 }
diff --git a/net/6lowpan/core.c b/net/6lowpan/core.c
index 34e44c0..7a240b3 100644
--- a/net/6lowpan/core.c
+++ b/net/6lowpan/core.c
@@ -27,11 +27,11 @@ int lowpan_register_netdevice(struct net_device *dev,
 	dev->mtu = IPV6_MIN_MTU;
 	dev->priv_flags |= IFF_NO_QUEUE;
 
-	lowpan_priv(dev)->lltype = lltype;
+	lowpan_dev(dev)->lltype = lltype;
 
-	spin_lock_init(&lowpan_priv(dev)->ctx.lock);
+	spin_lock_init(&lowpan_dev(dev)->ctx.lock);
 	for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
-		lowpan_priv(dev)->ctx.table[i].id = i;
+		lowpan_dev(dev)->ctx.table[i].id = i;
 
 	ret = register_netdevice(dev);
 	if (ret < 0)
@@ -85,7 +85,7 @@ static int lowpan_event(struct notifier_block *unused,
 	case NETDEV_DOWN:
 		for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
 			clear_bit(LOWPAN_IPHC_CTX_FLAG_ACTIVE,
-				  &lowpan_priv(dev)->ctx.table[i].flags);
+				  &lowpan_dev(dev)->ctx.table[i].flags);
 		break;
 	default:
 		return NOTIFY_DONE;
diff --git a/net/6lowpan/debugfs.c b/net/6lowpan/debugfs.c
index 0793a81..acbaa3d 100644
--- a/net/6lowpan/debugfs.c
+++ b/net/6lowpan/debugfs.c
@@ -172,7 +172,7 @@ static const struct file_operations lowpan_ctx_pfx_fops = {
 static int lowpan_dev_debugfs_ctx_init(struct net_device *dev,
 				       struct dentry *ctx, u8 id)
 {
-	struct lowpan_priv *lpriv = lowpan_priv(dev);
+	struct lowpan_dev *ldev = lowpan_dev(dev);
 	struct dentry *dentry, *root;
 	char buf[32];
 
@@ -185,25 +185,25 @@ static int lowpan_dev_debugfs_ctx_init(struct net_device *dev,
 		return -EINVAL;
 
 	dentry = debugfs_create_file("active", 0644, root,
-				     &lpriv->ctx.table[id],
+				     &ldev->ctx.table[id],
 				     &lowpan_ctx_flag_active_fops);
 	if (!dentry)
 		return -EINVAL;
 
 	dentry = debugfs_create_file("compression", 0644, root,
-				     &lpriv->ctx.table[id],
+				     &ldev->ctx.table[id],
 				     &lowpan_ctx_flag_c_fops);
 	if (!dentry)
 		return -EINVAL;
 
 	dentry = debugfs_create_file("prefix", 0644, root,
-				     &lpriv->ctx.table[id],
+				     &ldev->ctx.table[id],
 				     &lowpan_ctx_pfx_fops);
 	if (!dentry)
 		return -EINVAL;
 
 	dentry = debugfs_create_file("prefix_len", 0644, root,
-				     &lpriv->ctx.table[id],
+				     &ldev->ctx.table[id],
 				     &lowpan_ctx_plen_fops);
 	if (!dentry)
 		return -EINVAL;
@@ -247,21 +247,21 @@ static const struct file_operations lowpan_context_fops = {
 
 int lowpan_dev_debugfs_init(struct net_device *dev)
 {
-	struct lowpan_priv *lpriv = lowpan_priv(dev);
+	struct lowpan_dev *ldev = lowpan_dev(dev);
 	struct dentry *contexts, *dentry;
 	int ret, i;
 
 	/* creating the root */
-	lpriv->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs);
-	if (!lpriv->iface_debugfs)
+	ldev->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs);
+	if (!ldev->iface_debugfs)
 		goto fail;
 
-	contexts = debugfs_create_dir("contexts", lpriv->iface_debugfs);
+	contexts = debugfs_create_dir("contexts", ldev->iface_debugfs);
 	if (!contexts)
 		goto remove_root;
 
 	dentry = debugfs_create_file("show", 0644, contexts,
-				     &lowpan_priv(dev)->ctx,
+				     &lowpan_dev(dev)->ctx,
 				     &lowpan_context_fops);
 	if (!dentry)
 		goto remove_root;
@@ -282,7 +282,7 @@ fail:
 
 void lowpan_dev_debugfs_exit(struct net_device *dev)
 {
-	debugfs_remove_recursive(lowpan_priv(dev)->iface_debugfs);
+	debugfs_remove_recursive(lowpan_dev(dev)->iface_debugfs);
 }
 
 int __init lowpan_debugfs_init(void)
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index 99bb22a..798d5b2 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -202,7 +202,7 @@ static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
 static struct lowpan_iphc_ctx *
 lowpan_iphc_ctx_get_by_id(const struct net_device *dev, u8 id)
 {
-	struct lowpan_iphc_ctx *ret = &lowpan_priv(dev)->ctx.table[id];
+	struct lowpan_iphc_ctx *ret = &lowpan_dev(dev)->ctx.table[id];
 
 	if (!lowpan_iphc_ctx_is_active(ret))
 		return NULL;
@@ -214,7 +214,7 @@ static struct lowpan_iphc_ctx *
 lowpan_iphc_ctx_get_by_addr(const struct net_device *dev,
 			    const struct in6_addr *addr)
 {
-	struct lowpan_iphc_ctx *table = lowpan_priv(dev)->ctx.table;
+	struct lowpan_iphc_ctx *table = lowpan_dev(dev)->ctx.table;
 	struct lowpan_iphc_ctx *ret = NULL;
 	struct in6_addr addr_pfx;
 	u8 addr_plen;
@@ -258,7 +258,7 @@ static struct lowpan_iphc_ctx *
 lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev,
 				  const struct in6_addr *addr)
 {
-	struct lowpan_iphc_ctx *table = lowpan_priv(dev)->ctx.table;
+	struct lowpan_iphc_ctx *table = lowpan_dev(dev)->ctx.table;
 	struct lowpan_iphc_ctx *ret = NULL;
 	struct in6_addr addr_mcast, network_pfx = {};
 	int i;
@@ -327,7 +327,7 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
 	case LOWPAN_IPHC_SAM_11:
 	case LOWPAN_IPHC_DAM_11:
 		fail = false;
-		switch (lowpan_priv(dev)->lltype) {
+		switch (lowpan_dev(dev)->lltype) {
 		case LOWPAN_LLTYPE_IEEE802154:
 			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
 			break;
@@ -388,7 +388,7 @@ static int uncompress_ctx_addr(struct sk_buff *skb,
 	case LOWPAN_IPHC_SAM_11:
 	case LOWPAN_IPHC_DAM_11:
 		fail = false;
-		switch (lowpan_priv(dev)->lltype) {
+		switch (lowpan_dev(dev)->lltype) {
 		case LOWPAN_LLTYPE_IEEE802154:
 			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
 			break;
@@ -652,17 +652,17 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 	}
 
 	if (iphc1 & LOWPAN_IPHC_SAC) {
-		spin_lock_bh(&lowpan_priv(dev)->ctx.lock);
+		spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
 		ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_SCI(cid));
 		if (!ci) {
-			spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
+			spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 			return -EINVAL;
 		}
 
 		pr_debug("SAC bit is set. Handle context based source address.\n");
 		err = uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
 					  iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
-		spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
+		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 	} else {
 		/* Source address uncompression */
 		pr_debug("source address stateless compression\n");
@@ -676,10 +676,10 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 
 	switch (iphc1 & (LOWPAN_IPHC_M | LOWPAN_IPHC_DAC)) {
 	case LOWPAN_IPHC_M | LOWPAN_IPHC_DAC:
-		spin_lock_bh(&lowpan_priv(dev)->ctx.lock);
+		spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
 		ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_DCI(cid));
 		if (!ci) {
-			spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
+			spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 			return -EINVAL;
 		}
 
@@ -688,7 +688,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 		err = lowpan_uncompress_multicast_ctx_daddr(skb, ci,
 							    &hdr.daddr,
 							    iphc1 & LOWPAN_IPHC_DAM_MASK);
-		spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
+		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 		break;
 	case LOWPAN_IPHC_M:
 		/* multicast */
@@ -696,10 +696,10 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 							iphc1 & LOWPAN_IPHC_DAM_MASK);
 		break;
 	case LOWPAN_IPHC_DAC:
-		spin_lock_bh(&lowpan_priv(dev)->ctx.lock);
+		spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
 		ci = lowpan_iphc_ctx_get_by_id(dev, LOWPAN_IPHC_CID_DCI(cid));
 		if (!ci) {
-			spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
+			spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 			return -EINVAL;
 		}
 
@@ -707,7 +707,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 		pr_debug("DAC bit is set. Handle context based destination address.\n");
 		err = uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
 					  iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
-		spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
+		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 		break;
 	default:
 		err = uncompress_addr(skb, dev, &hdr.daddr,
@@ -731,7 +731,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 			return err;
 	}
 
-	switch (lowpan_priv(dev)->lltype) {
+	switch (lowpan_dev(dev)->lltype) {
 	case LOWPAN_LLTYPE_IEEE802154:
 		if (lowpan_802154_cb(skb)->d_size)
 			hdr.payload_len = htons(lowpan_802154_cb(skb)->d_size -
@@ -1028,7 +1028,7 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
 		       skb->data, skb->len);
 
 	ipv6_daddr_type = ipv6_addr_type(&hdr->daddr);
-	spin_lock_bh(&lowpan_priv(dev)->ctx.lock);
+	spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
 	if (ipv6_daddr_type & IPV6_ADDR_MULTICAST)
 		dci = lowpan_iphc_ctx_get_by_mcast_addr(dev, &hdr->daddr);
 	else
@@ -1037,15 +1037,15 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
 		memcpy(&dci_entry, dci, sizeof(*dci));
 		cid |= dci->id;
 	}
-	spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
+	spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 
-	spin_lock_bh(&lowpan_priv(dev)->ctx.lock);
+	spin_lock_bh(&lowpan_dev(dev)->ctx.lock);
 	sci = lowpan_iphc_ctx_get_by_addr(dev, &hdr->saddr);
 	if (sci) {
 		memcpy(&sci_entry, sci, sizeof(*sci));
 		cid |= (sci->id << 4);
 	}
-	spin_unlock_bh(&lowpan_priv(dev)->ctx.lock);
+	spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 
 	/* if cid is zero it will be compressed */
 	if (cid) {
diff --git a/net/6lowpan/nhc_udp.c b/net/6lowpan/nhc_udp.c
index 69537a2..225d919 100644
--- a/net/6lowpan/nhc_udp.c
+++ b/net/6lowpan/nhc_udp.c
@@ -91,7 +91,7 @@ static int udp_uncompress(struct sk_buff *skb, size_t needed)
 	 * here, we obtain the hint from the remaining size of the
 	 * frame
 	 */
-	switch (lowpan_priv(skb->dev)->lltype) {
+	switch (lowpan_dev(skb->dev)->lltype) {
 	case LOWPAN_LLTYPE_IEEE802154:
 		if (lowpan_802154_cb(skb)->d_size)
 			uh.len = htons(lowpan_802154_cb(skb)->d_size -
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 8a4cc2f..38e82dd 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -68,7 +68,7 @@ struct lowpan_peer {
 	struct in6_addr peer_addr;
 };
 
-struct lowpan_dev {
+struct lowpan_btle_dev {
 	struct list_head list;
 
 	struct hci_dev *hdev;
@@ -80,18 +80,21 @@ struct lowpan_dev {
 	struct delayed_work notify_peers;
 };
 
-static inline struct lowpan_dev *lowpan_dev(const struct net_device *netdev)
+static inline struct lowpan_btle_dev *
+lowpan_btle_dev(const struct net_device *netdev)
 {
-	return (struct lowpan_dev *)lowpan_priv(netdev)->priv;
+	return (struct lowpan_btle_dev *)lowpan_dev(netdev)->priv;
 }
 
-static inline void peer_add(struct lowpan_dev *dev, struct lowpan_peer *peer)
+static inline void peer_add(struct lowpan_btle_dev *dev,
+			    struct lowpan_peer *peer)
 {
 	list_add_rcu(&peer->list, &dev->peers);
 	atomic_inc(&dev->peer_count);
 }
 
-static inline bool peer_del(struct lowpan_dev *dev, struct lowpan_peer *peer)
+static inline bool peer_del(struct lowpan_btle_dev *dev,
+			    struct lowpan_peer *peer)
 {
 	list_del_rcu(&peer->list);
 	kfree_rcu(peer, rcu);
@@ -106,7 +109,7 @@ static inline bool peer_del(struct lowpan_dev *dev, struct lowpan_peer *peer)
 	return false;
 }
 
-static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_dev *dev,
+static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_btle_dev *dev,
 						 bdaddr_t *ba, __u8 type)
 {
 	struct lowpan_peer *peer;
@@ -134,8 +137,8 @@ static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_dev *dev,
 	return NULL;
 }
 
-static inline struct lowpan_peer *__peer_lookup_chan(struct lowpan_dev *dev,
-						     struct l2cap_chan *chan)
+static inline struct lowpan_peer *
+__peer_lookup_chan(struct lowpan_btle_dev *dev, struct l2cap_chan *chan)
 {
 	struct lowpan_peer *peer;
 
@@ -147,8 +150,8 @@ static inline struct lowpan_peer *__peer_lookup_chan(struct lowpan_dev *dev,
 	return NULL;
 }
 
-static inline struct lowpan_peer *__peer_lookup_conn(struct lowpan_dev *dev,
-						     struct l2cap_conn *conn)
+static inline struct lowpan_peer *
+__peer_lookup_conn(struct lowpan_btle_dev *dev, struct l2cap_conn *conn)
 {
 	struct lowpan_peer *peer;
 
@@ -160,7 +163,7 @@ static inline struct lowpan_peer *__peer_lookup_conn(struct lowpan_dev *dev,
 	return NULL;
 }
 
-static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_dev *dev,
+static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_btle_dev *dev,
 						  struct in6_addr *daddr,
 						  struct sk_buff *skb)
 {
@@ -220,7 +223,7 @@ static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_dev *dev,
 
 static struct lowpan_peer *lookup_peer(struct l2cap_conn *conn)
 {
-	struct lowpan_dev *entry;
+	struct lowpan_btle_dev *entry;
 	struct lowpan_peer *peer = NULL;
 
 	rcu_read_lock();
@@ -236,10 +239,10 @@ static struct lowpan_peer *lookup_peer(struct l2cap_conn *conn)
 	return peer;
 }
 
-static struct lowpan_dev *lookup_dev(struct l2cap_conn *conn)
+static struct lowpan_btle_dev *lookup_dev(struct l2cap_conn *conn)
 {
-	struct lowpan_dev *entry;
-	struct lowpan_dev *dev = NULL;
+	struct lowpan_btle_dev *entry;
+	struct lowpan_btle_dev *dev = NULL;
 
 	rcu_read_lock();
 
@@ -270,10 +273,10 @@ static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev,
 			   struct l2cap_chan *chan)
 {
 	const u8 *saddr, *daddr;
-	struct lowpan_dev *dev;
+	struct lowpan_btle_dev *dev;
 	struct lowpan_peer *peer;
 
-	dev = lowpan_dev(netdev);
+	dev = lowpan_btle_dev(netdev);
 
 	rcu_read_lock();
 	peer = __peer_lookup_chan(dev, chan);
@@ -375,7 +378,7 @@ drop:
 /* Packet from BT LE device */
 static int chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
 {
-	struct lowpan_dev *dev;
+	struct lowpan_btle_dev *dev;
 	struct lowpan_peer *peer;
 	int err;
 
@@ -431,13 +434,13 @@ static int setup_header(struct sk_buff *skb, struct net_device *netdev,
 			bdaddr_t *peer_addr, u8 *peer_addr_type)
 {
 	struct in6_addr ipv6_daddr;
-	struct lowpan_dev *dev;
+	struct lowpan_btle_dev *dev;
 	struct lowpan_peer *peer;
 	bdaddr_t addr, *any = BDADDR_ANY;
 	u8 *daddr = any->b;
 	int err, status = 0;
 
-	dev = lowpan_dev(netdev);
+	dev = lowpan_btle_dev(netdev);
 
 	memcpy(&ipv6_daddr, &lowpan_cb(skb)->addr, sizeof(ipv6_daddr));
 
@@ -543,19 +546,19 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb,
 static int send_mcast_pkt(struct sk_buff *skb, struct net_device *netdev)
 {
 	struct sk_buff *local_skb;
-	struct lowpan_dev *entry;
+	struct lowpan_btle_dev *entry;
 	int err = 0;
 
 	rcu_read_lock();
 
 	list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
 		struct lowpan_peer *pentry;
-		struct lowpan_dev *dev;
+		struct lowpan_btle_dev *dev;
 
 		if (entry->netdev != netdev)
 			continue;
 
-		dev = lowpan_dev(entry->netdev);
+		dev = lowpan_btle_dev(entry->netdev);
 
 		list_for_each_entry_rcu(pentry, &dev->peers, list) {
 			int ret;
@@ -723,8 +726,8 @@ static void ifdown(struct net_device *netdev)
 
 static void do_notify_peers(struct work_struct *work)
 {
-	struct lowpan_dev *dev = container_of(work, struct lowpan_dev,
-					      notify_peers.work);
+	struct lowpan_btle_dev *dev = container_of(work, struct lowpan_btle_dev,
+						   notify_peers.work);
 
 	netdev_notify_peers(dev->netdev); /* send neighbour adv at startup */
 }
@@ -766,7 +769,7 @@ static void set_ip_addr_bits(u8 addr_type, u8 *addr)
 }
 
 static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan,
-					struct lowpan_dev *dev)
+					struct lowpan_btle_dev *dev)
 {
 	struct lowpan_peer *peer;
 
@@ -803,12 +806,12 @@ static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan,
 	return peer->chan;
 }
 
-static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev)
+static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev)
 {
 	struct net_device *netdev;
 	int err = 0;
 
-	netdev = alloc_netdev(LOWPAN_PRIV_SIZE(sizeof(struct lowpan_dev)),
+	netdev = alloc_netdev(LOWPAN_PRIV_SIZE(sizeof(struct lowpan_btle_dev)),
 			      IFACE_NAME_TEMPLATE, NET_NAME_UNKNOWN,
 			      netdev_setup);
 	if (!netdev)
@@ -820,7 +823,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev)
 	SET_NETDEV_DEV(netdev, &chan->conn->hcon->hdev->dev);
 	SET_NETDEV_DEVTYPE(netdev, &bt_type);
 
-	*dev = lowpan_dev(netdev);
+	*dev = lowpan_btle_dev(netdev);
 	(*dev)->netdev = netdev;
 	(*dev)->hdev = chan->conn->hcon->hdev;
 	INIT_LIST_HEAD(&(*dev)->peers);
@@ -853,7 +856,7 @@ out:
 
 static inline void chan_ready_cb(struct l2cap_chan *chan)
 {
-	struct lowpan_dev *dev;
+	struct lowpan_btle_dev *dev;
 
 	dev = lookup_dev(chan->conn);
 
@@ -890,8 +893,9 @@ static inline struct l2cap_chan *chan_new_conn_cb(struct l2cap_chan *pchan)
 
 static void delete_netdev(struct work_struct *work)
 {
-	struct lowpan_dev *entry = container_of(work, struct lowpan_dev,
-						delete_netdev);
+	struct lowpan_btle_dev *entry = container_of(work,
+						     struct lowpan_btle_dev,
+						     delete_netdev);
 
 	lowpan_unregister_netdev(entry->netdev);
 
@@ -900,8 +904,8 @@ static void delete_netdev(struct work_struct *work)
 
 static void chan_close_cb(struct l2cap_chan *chan)
 {
-	struct lowpan_dev *entry;
-	struct lowpan_dev *dev = NULL;
+	struct lowpan_btle_dev *entry;
+	struct lowpan_btle_dev *dev = NULL;
 	struct lowpan_peer *peer;
 	int err = -ENOENT;
 	bool last = false, remove = true;
@@ -921,7 +925,7 @@ static void chan_close_cb(struct l2cap_chan *chan)
 	spin_lock(&devices_lock);
 
 	list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
-		dev = lowpan_dev(entry->netdev);
+		dev = lowpan_btle_dev(entry->netdev);
 		peer = __peer_lookup_chan(dev, chan);
 		if (peer) {
 			last = peer_del(dev, peer);
@@ -1131,7 +1135,7 @@ static int get_l2cap_conn(char *buf, bdaddr_t *addr, u8 *addr_type,
 
 static void disconnect_all_peers(void)
 {
-	struct lowpan_dev *entry;
+	struct lowpan_btle_dev *entry;
 	struct lowpan_peer *peer, *tmp_peer, *new_peer;
 	struct list_head peers;
 
@@ -1291,7 +1295,7 @@ static ssize_t lowpan_control_write(struct file *fp,
 
 static int lowpan_control_show(struct seq_file *f, void *ptr)
 {
-	struct lowpan_dev *entry;
+	struct lowpan_btle_dev *entry;
 	struct lowpan_peer *peer;
 
 	spin_lock(&devices_lock);
@@ -1322,7 +1326,7 @@ static const struct file_operations lowpan_control_fops = {
 
 static void disconnect_devices(void)
 {
-	struct lowpan_dev *entry, *tmp, *new_dev;
+	struct lowpan_btle_dev *entry, *tmp, *new_dev;
 	struct list_head devices;
 
 	INIT_LIST_HEAD(&devices);
@@ -1360,7 +1364,7 @@ static int device_event(struct notifier_block *unused,
 			unsigned long event, void *ptr)
 {
 	struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
-	struct lowpan_dev *entry;
+	struct lowpan_btle_dev *entry;
 
 	if (netdev->type != ARPHRD_6LOWPAN)
 		return NOTIFY_DONE;
diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
index b4092a9..b02b74d 100644
--- a/net/ieee802154/6lowpan/6lowpan_i.h
+++ b/net/ieee802154/6lowpan/6lowpan_i.h
@@ -48,15 +48,15 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
 }
 
 /* private device info */
-struct lowpan_dev_info {
+struct lowpan_802154_dev {
 	struct net_device	*wdev; /* wpan device ptr */
 	u16			fragment_tag;
 };
 
 static inline struct
-lowpan_dev_info *lowpan_dev_info(const struct net_device *dev)
+lowpan_802154_dev *lowpan_802154_dev(const struct net_device *dev)
 {
-	return (struct lowpan_dev_info *)lowpan_priv(dev)->priv;
+	return (struct lowpan_802154_dev *)lowpan_dev(dev)->priv;
 }
 
 int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type);
diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
index 0023c90..dd085db 100644
--- a/net/ieee802154/6lowpan/core.c
+++ b/net/ieee802154/6lowpan/core.c
@@ -148,7 +148,7 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
 		return -EBUSY;
 	}
 
-	lowpan_dev_info(ldev)->wdev = wdev;
+	lowpan_802154_dev(ldev)->wdev = wdev;
 	/* Set the lowpan hardware address to the wpan hardware address. */
 	memcpy(ldev->dev_addr, wdev->dev_addr, IEEE802154_ADDR_LEN);
 	/* We need headroom for possible wpan_dev_hard_header call and tailroom
@@ -173,7 +173,7 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
 
 static void lowpan_dellink(struct net_device *ldev, struct list_head *head)
 {
-	struct net_device *wdev = lowpan_dev_info(ldev)->wdev;
+	struct net_device *wdev = lowpan_802154_dev(ldev)->wdev;
 
 	ASSERT_RTNL();
 
@@ -184,7 +184,7 @@ static void lowpan_dellink(struct net_device *ldev, struct list_head *head)
 
 static struct rtnl_link_ops lowpan_link_ops __read_mostly = {
 	.kind		= "lowpan",
-	.priv_size	= LOWPAN_PRIV_SIZE(sizeof(struct lowpan_dev_info)),
+	.priv_size	= LOWPAN_PRIV_SIZE(sizeof(struct lowpan_802154_dev)),
 	.setup		= lowpan_setup,
 	.newlink	= lowpan_newlink,
 	.dellink	= lowpan_dellink,
diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c
index d4353fa..e459afd 100644
--- a/net/ieee802154/6lowpan/tx.c
+++ b/net/ieee802154/6lowpan/tx.c
@@ -84,7 +84,7 @@ static struct sk_buff*
 lowpan_alloc_frag(struct sk_buff *skb, int size,
 		  const struct ieee802154_hdr *master_hdr, bool frag1)
 {
-	struct net_device *wdev = lowpan_dev_info(skb->dev)->wdev;
+	struct net_device *wdev = lowpan_802154_dev(skb->dev)->wdev;
 	struct sk_buff *frag;
 	int rc;
 
@@ -148,8 +148,8 @@ lowpan_xmit_fragmented(struct sk_buff *skb, struct net_device *ldev,
 	int frag_cap, frag_len, payload_cap, rc;
 	int skb_unprocessed, skb_offset;
 
-	frag_tag = htons(lowpan_dev_info(ldev)->fragment_tag);
-	lowpan_dev_info(ldev)->fragment_tag++;
+	frag_tag = htons(lowpan_802154_dev(ldev)->fragment_tag);
+	lowpan_802154_dev(ldev)->fragment_tag++;
 
 	frag_hdr[0] = LOWPAN_DISPATCH_FRAG1 | ((dgram_size >> 8) & 0x07);
 	frag_hdr[1] = dgram_size & 0xff;
@@ -208,7 +208,7 @@ err:
 static int lowpan_header(struct sk_buff *skb, struct net_device *ldev,
 			 u16 *dgram_size, u16 *dgram_offset)
 {
-	struct wpan_dev *wpan_dev = lowpan_dev_info(ldev)->wdev->ieee802154_ptr;
+	struct wpan_dev *wpan_dev = lowpan_802154_dev(ldev)->wdev->ieee802154_ptr;
 	struct ieee802154_addr sa, da;
 	struct ieee802154_mac_cb *cb = mac_cb_init(skb);
 	struct lowpan_addr_info info;
@@ -248,8 +248,8 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *ldev,
 		cb->ackreq = wpan_dev->ackreq;
 	}
 
-	return wpan_dev_hard_header(skb, lowpan_dev_info(ldev)->wdev, &da, &sa,
-				    0);
+	return wpan_dev_hard_header(skb, lowpan_802154_dev(ldev)->wdev, &da,
+				    &sa, 0);
 }
 
 netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev)
@@ -283,7 +283,7 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev)
 	max_single = ieee802154_max_payload(&wpan_hdr);
 
 	if (skb_tail_pointer(skb) - skb_network_header(skb) <= max_single) {
-		skb->dev = lowpan_dev_info(ldev)->wdev;
+		skb->dev = lowpan_802154_dev(ldev)->wdev;
 		ldev->stats.tx_packets++;
 		ldev->stats.tx_bytes += dgram_size;
 		return dev_queue_xmit(skb);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 06/19] 6lowpan: move lowpan_802154_dev to 6lowpan
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (4 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 05/19] 6lowpan: change naming for lowpan private data Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-23 10:08   ` Stefan Schmidt
  2016-03-22 13:15 ` [RFC bluetooth-next 07/19] 6lowpan: iphc: rename add lowpan prefix Alexander Aring
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch moves the 802.15.4 link layer specific structures to generic
6lowpan. This is necessary for special 802.15.4 6lowpan handling in
upper layers.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/net/6lowpan.h              | 12 ++++++++++++
 net/ieee802154/6lowpan/6lowpan_i.h | 12 ------------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index f204664..a0c01f5 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -144,6 +144,18 @@ struct lowpan_dev *lowpan_dev(const struct net_device *dev)
 	return netdev_priv(dev);
 }
 
+/* private device info */
+struct lowpan_802154_dev {
+	struct net_device	*wdev; /* wpan device ptr */
+	u16			fragment_tag;
+};
+
+static inline struct
+lowpan_802154_dev *lowpan_802154_dev(const struct net_device *dev)
+{
+	return (struct lowpan_802154_dev *)lowpan_dev(dev)->priv;
+}
+
 struct lowpan_802154_cb {
 	u16 d_tag;
 	unsigned int d_size;
diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
index b02b74d..5ac7789 100644
--- a/net/ieee802154/6lowpan/6lowpan_i.h
+++ b/net/ieee802154/6lowpan/6lowpan_i.h
@@ -47,18 +47,6 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
 	}
 }
 
-/* private device info */
-struct lowpan_802154_dev {
-	struct net_device	*wdev; /* wpan device ptr */
-	u16			fragment_tag;
-};
-
-static inline struct
-lowpan_802154_dev *lowpan_802154_dev(const struct net_device *dev)
-{
-	return (struct lowpan_802154_dev *)lowpan_dev(dev)->priv;
-}
-
 int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type);
 void lowpan_net_frag_exit(void);
 int lowpan_net_frag_init(void);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 07/19] 6lowpan: iphc: rename add lowpan prefix
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (5 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 06/19] 6lowpan: move lowpan_802154_dev to 6lowpan Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-23 10:09   ` Stefan Schmidt
  2016-03-22 13:15 ` [RFC bluetooth-next 08/19] 6lowpan: iphc: remove unnecessary zero data Alexander Aring
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch adds a lowpan prefix to each functions which doesn't have
such prefix currently.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 net/6lowpan/iphc.c | 56 ++++++++++++++++++++++++++++++------------------------
 1 file changed, 31 insertions(+), 25 deletions(-)

diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index 798d5b2..d5a72e3 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -151,8 +151,8 @@
 #define LOWPAN_IPHC_CID_DCI(cid)	(cid & 0x0f)
 #define LOWPAN_IPHC_CID_SCI(cid)	((cid & 0xf0) >> 4)
 
-static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
-						const void *lladdr)
+static inline void lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
+						       const void *lladdr)
 {
 	/* fe:80::XXXX:XXXX:XXXX:XXXX
 	 *        \_________________/
@@ -167,8 +167,9 @@ static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
 	ipaddr->s6_addr[8] ^= 0x02;
 }
 
-static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
-						 const void *lladdr)
+static inline void
+lowpan_iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
+				     const void *lladdr)
 {
 	const struct ieee802154_addr *addr = lladdr;
 	u8 eui64[EUI64_ADDR_LEN] = { };
@@ -176,7 +177,7 @@ static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
 	switch (addr->mode) {
 	case IEEE802154_ADDR_LONG:
 		ieee802154_le64_to_be64(eui64, &addr->extended_addr);
-		iphc_uncompress_eui64_lladdr(ipaddr, eui64);
+		lowpan_iphc_uncompress_eui64_lladdr(ipaddr, eui64);
 		break;
 	case IEEE802154_ADDR_SHORT:
 		/* fe:80::ff:fe00:XXXX
@@ -296,9 +297,10 @@ lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev,
  *
  * address_mode is the masked value for sam or dam value
  */
-static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
-			   struct in6_addr *ipaddr, u8 address_mode,
-			   const void *lladdr)
+static int lowpan_iphc_uncompress_addr(struct sk_buff *skb,
+				       const struct net_device *dev,
+				       struct in6_addr *ipaddr,
+				       u8 address_mode, const void *lladdr)
 {
 	bool fail;
 
@@ -329,10 +331,10 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
 		fail = false;
 		switch (lowpan_dev(dev)->lltype) {
 		case LOWPAN_LLTYPE_IEEE802154:
-			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
+			lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr);
 			break;
 		default:
-			iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
+			lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
 			break;
 		}
 		break;
@@ -355,11 +357,11 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
 /* Uncompress address function for source context
  * based address(non-multicast).
  */
-static int uncompress_ctx_addr(struct sk_buff *skb,
-			       const struct net_device *dev,
-			       const struct lowpan_iphc_ctx *ctx,
-			       struct in6_addr *ipaddr, u8 address_mode,
-			       const void *lladdr)
+static int lowpan_iphc_uncompress_ctx_addr(struct sk_buff *skb,
+					   const struct net_device *dev,
+					   const struct lowpan_iphc_ctx *ctx,
+					   struct in6_addr *ipaddr,
+					   u8 address_mode, const void *lladdr)
 {
 	bool fail;
 
@@ -390,10 +392,10 @@ static int uncompress_ctx_addr(struct sk_buff *skb,
 		fail = false;
 		switch (lowpan_dev(dev)->lltype) {
 		case LOWPAN_LLTYPE_IEEE802154:
-			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
+			lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr);
 			break;
 		default:
-			iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
+			lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
 			break;
 		}
 		ipv6_addr_prefix_copy(ipaddr, &ctx->pfx, ctx->plen);
@@ -660,14 +662,16 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 		}
 
 		pr_debug("SAC bit is set. Handle context based source address.\n");
-		err = uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
-					  iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
+		err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
+						      iphc1 & LOWPAN_IPHC_SAM_MASK,
+						      saddr);
 		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 	} else {
 		/* Source address uncompression */
 		pr_debug("source address stateless compression\n");
-		err = uncompress_addr(skb, dev, &hdr.saddr,
-				      iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
+		err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.saddr,
+						  iphc1 & LOWPAN_IPHC_SAM_MASK,
+						  saddr);
 	}
 
 	/* Check on error of previous branch */
@@ -705,13 +709,15 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 
 		/* Destination address context based uncompression */
 		pr_debug("DAC bit is set. Handle context based destination address.\n");
-		err = uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
-					  iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
+		err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
+						      iphc1 & LOWPAN_IPHC_DAM_MASK,
+						      daddr);
 		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
 		break;
 	default:
-		err = uncompress_addr(skb, dev, &hdr.daddr,
-				      iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
+		err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.daddr,
+						  iphc1 & LOWPAN_IPHC_DAM_MASK,
+						  daddr);
 		pr_debug("dest: stateless compression mode %d dest %pI6c\n",
 			 iphc1 & LOWPAN_IPHC_DAM_MASK, &hdr.daddr);
 		break;
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 08/19] 6lowpan: iphc: remove unnecessary zero data
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (6 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 07/19] 6lowpan: iphc: rename add lowpan prefix Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 09/19] 6lowpan: move eui64 uncompress function Alexander Aring
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch removes unnecessary zero data for a stack variable.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 net/6lowpan/iphc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index d5a72e3..bad4f89 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -172,7 +172,7 @@ lowpan_iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
 				     const void *lladdr)
 {
 	const struct ieee802154_addr *addr = lladdr;
-	u8 eui64[EUI64_ADDR_LEN] = { };
+	u8 eui64[EUI64_ADDR_LEN];
 
 	switch (addr->mode) {
 	case IEEE802154_ADDR_LONG:
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 09/19] 6lowpan: move eui64 uncompress function
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (7 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 08/19] 6lowpan: iphc: remove unnecessary zero data Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 10/19] 6lowpan: add lowpan_is_ll function Alexander Aring
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This function will be use in later functionality in other branches than
generic 6lowpan, so we move it to the global 6lowpan header.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/net/6lowpan.h | 16 ++++++++++++++++
 net/6lowpan/iphc.c    | 16 ----------------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index a0c01f5..04b877c 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -169,6 +169,22 @@ struct lowpan_802154_cb *lowpan_802154_cb(const struct sk_buff *skb)
 	return (struct lowpan_802154_cb *)skb->cb;
 }
 
+static inline void lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
+						       const void *lladdr)
+{
+	/* fe:80::XXXX:XXXX:XXXX:XXXX
+	 *        \_________________/
+	 *              hwaddr
+	 */
+	ipaddr->s6_addr[0] = 0xFE;
+	ipaddr->s6_addr[1] = 0x80;
+	memcpy(&ipaddr->s6_addr[8], lladdr, EUI64_ADDR_LEN);
+	/* second bit-flip (Universe/Local)
+	 * is done according RFC2464
+	 */
+	ipaddr->s6_addr[8] ^= 0x02;
+}
+
 #ifdef DEBUG
 /* print data in line */
 static inline void raw_dump_inline(const char *caller, char *msg,
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index bad4f89..a3ea5f6 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -151,22 +151,6 @@
 #define LOWPAN_IPHC_CID_DCI(cid)	(cid & 0x0f)
 #define LOWPAN_IPHC_CID_SCI(cid)	((cid & 0xf0) >> 4)
 
-static inline void lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
-						       const void *lladdr)
-{
-	/* fe:80::XXXX:XXXX:XXXX:XXXX
-	 *        \_________________/
-	 *              hwaddr
-	 */
-	ipaddr->s6_addr[0] = 0xFE;
-	ipaddr->s6_addr[1] = 0x80;
-	memcpy(&ipaddr->s6_addr[8], lladdr, EUI64_ADDR_LEN);
-	/* second bit-flip (Universe/Local)
-	 * is done according RFC2464
-	 */
-	ipaddr->s6_addr[8] ^= 0x02;
-}
-
 static inline void
 lowpan_iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
 				     const void *lladdr)
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 10/19] 6lowpan: add lowpan_is_ll function
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (8 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 09/19] 6lowpan: move eui64 uncompress function Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 11/19] 6lowpan: move mac802154 header Alexander Aring
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch adds the lowpan_is_ll function, which can be used to make a
special 6lowpan linklayer handling for a specific 6lowpan linklayer
type.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/net/6lowpan.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index 04b877c..6c09d01 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -144,6 +144,13 @@ struct lowpan_dev *lowpan_dev(const struct net_device *dev)
 	return netdev_priv(dev);
 }
 
+static inline bool lowpan_is_ll(const struct net_device *dev,
+				enum lowpan_lltypes lltype)
+{
+	return (dev->type == ARPHRD_6LOWPAN &&
+		lowpan_dev(dev)->lltype == lltype);
+}
+
 /* private device info */
 struct lowpan_802154_dev {
 	struct net_device	*wdev; /* wpan device ptr */
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 11/19] 6lowpan: move mac802154 header
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (9 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 10/19] 6lowpan: add lowpan_is_ll function Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 12/19] 6lowpan: add private neighbour data Alexander Aring
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

In case of link-layer specific handling for 802.15.4 we need to cast to
802.15.4 sepcific structures. Simple add this header when include the
6lowpan header.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/net/6lowpan.h | 3 +++
 net/6lowpan/iphc.c    | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index 6c09d01..4e465c7 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -58,6 +58,9 @@
 #include <net/ipv6.h>
 #include <net/net_namespace.h>
 
+/* special link-layer handling */
+#include <net/mac802154.h>
+
 #define EUI64_ADDR_LEN		8
 
 #define LOWPAN_NHC_MAX_ID_LEN	1
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index a3ea5f6..d167ce5bd1 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -53,9 +53,6 @@
 #include <net/6lowpan.h>
 #include <net/ipv6.h>
 
-/* special link-layer handling */
-#include <net/mac802154.h>
-
 #include "6lowpan_i.h"
 #include "nhc.h"
 
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 12/19] 6lowpan: add private neighbour data
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (10 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 11/19] 6lowpan: move mac802154 header Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 13/19] addrconf: add 802.15.4 short addr slaac Alexander Aring
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch will introduce a 6lowpan neighbour private data. Like the
interface private data we handle private data for generic 6lowpan and
for link-layer specific 6lowpan.

The current first use case if to save the short address for a 802.15.4
6lowpan neighbour.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/linux/netdevice.h     |  3 +--
 include/net/6lowpan.h         | 24 ++++++++++++++++++++++++
 net/bluetooth/6lowpan.c       |  2 ++
 net/ieee802154/6lowpan/core.c | 12 ++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index be693b3..26e1c8f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1478,8 +1478,7 @@ enum netdev_priv_flags {
  * 	@perm_addr:		Permanent hw address
  * 	@addr_assign_type:	Hw address assignment type
  * 	@addr_len:		Hardware address length
- * 	@neigh_priv_len;	Used in neigh_alloc(),
- * 				initialized only in atm/clip.c
+ *	@neigh_priv_len;	Used in neigh_alloc()
  * 	@dev_id:		Used to differentiate devices that share
  * 				the same link layer address
  * 	@dev_port:		Used to differentiate devices that share
diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index 4e465c7..5784db7 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -98,6 +98,9 @@ static inline bool lowpan_is_iphc(u8 dispatch)
 #define LOWPAN_PRIV_SIZE(llpriv_size)	\
 	(sizeof(struct lowpan_dev) + llpriv_size)
 
+#define LOWPAN_NEIGH_PRIV_SIZE(llneigh_priv_size)	\
+	(sizeof(struct lowpan_neigh) + llneigh_priv_size)
+
 enum lowpan_lltypes {
 	LOWPAN_LLTYPE_BTLE,
 	LOWPAN_LLTYPE_IEEE802154,
@@ -141,6 +144,27 @@ struct lowpan_dev {
 	u8 priv[0] __aligned(sizeof(void *));
 };
 
+struct lowpan_neigh {
+	/* 6LoWPAN neigh private data */
+	/* must be last */
+	u8 priv[0] __aligned(sizeof(void *));
+};
+
+struct lowpan_802154_neigh {
+	__le16 short_addr;
+};
+
+static inline struct lowpan_neigh *lowpan_neigh(void *neigh_priv)
+{
+	return neigh_priv;
+}
+
+static inline
+struct lowpan_802154_neigh *lowpan_802154_neigh(void *neigh_priv)
+{
+	return (struct lowpan_802154_neigh *)lowpan_neigh(neigh_priv)->priv;
+}
+
 static inline
 struct lowpan_dev *lowpan_dev(const struct net_device *dev)
 {
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 38e82dd..b7c4efa 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -833,6 +833,8 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev)
 	list_add_rcu(&(*dev)->list, &bt_6lowpan_devices);
 	spin_unlock(&devices_lock);
 
+	netdev->neigh_priv_len = LOWPAN_NEIGH_PRIV_SIZE(0);
+
 	err = lowpan_register_netdev(netdev, LOWPAN_LLTYPE_BTLE);
 	if (err < 0) {
 		BT_INFO("register_netdev failed %d", err);
diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
index dd085db..3162632 100644
--- a/net/ieee802154/6lowpan/core.c
+++ b/net/ieee802154/6lowpan/core.c
@@ -92,11 +92,21 @@ static int lowpan_stop(struct net_device *dev)
 	return 0;
 }
 
+static int lowpan_neigh_construct(struct neighbour *n)
+{
+	struct lowpan_802154_neigh *neigh = lowpan_802154_neigh(neighbour_priv(n));
+
+	/* default no short_addr is available for a neighbour */
+	neigh->short_addr = cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC);
+	return 0;
+}
+
 static const struct net_device_ops lowpan_netdev_ops = {
 	.ndo_init		= lowpan_dev_init,
 	.ndo_start_xmit		= lowpan_xmit,
 	.ndo_open		= lowpan_open,
 	.ndo_stop		= lowpan_stop,
+	.ndo_neigh_construct    = lowpan_neigh_construct,
 };
 
 static void lowpan_setup(struct net_device *ldev)
@@ -161,6 +171,8 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
 				wdev->needed_headroom;
 	ldev->needed_tailroom = wdev->needed_tailroom;
 
+	ldev->neigh_priv_len = LOWPAN_NEIGH_PRIV_SIZE(sizeof(struct lowpan_802154_neigh));
+
 	ret = lowpan_register_netdevice(ldev, LOWPAN_LLTYPE_IEEE802154);
 	if (ret < 0) {
 		dev_put(wdev);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 13/19] addrconf: add 802.15.4 short addr slaac
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (11 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 12/19] 6lowpan: add private neighbour data Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-23 10:50   ` Hannes Frederic Sowa
  2016-03-22 13:15 ` [RFC bluetooth-next 14/19] ndisc: add addr_len parameter to ndisc_opt_addr_space Alexander Aring
                   ` (5 subsequent siblings)
  18 siblings, 1 reply; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch adds the autoconfiguration if a valid 802.15.4 short address
is available for 802.15.4 6LoWPAN interfaces.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 net/ipv6/addrconf.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 27aed1a..eb3e3fb 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3058,6 +3058,37 @@ static void ipv6_gen_mode_random_init(struct inet6_dev *idev)
 	s->initialized = true;
 }
 
+#ifdef CONFIG_IEEE802154_6LOWPAN
+static int addrconf_ifid_ieee802154(u8 *eui, struct net_device *dev)
+{
+	struct wpan_dev *wpan_dev = lowpan_802154_dev(dev)->wdev->ieee802154_ptr;
+
+	/* Set short_addr autoconfiguration if short_addr is present only */
+	if (!ieee802154_is_valid_src_short_addr(wpan_dev->short_addr))
+		return -1;
+
+	/* For either address format, all zero addresses MUST NOT be used */
+	if (wpan_dev->pan_id == cpu_to_le16(0x0000) &&
+	    wpan_dev->short_addr == cpu_to_le16(0x0000))
+		return -1;
+
+	/* Alternatively, if no PAN ID is known, 16 zero bits may be used */
+	if (wpan_dev->pan_id == cpu_to_le16(IEEE802154_PAN_ID_BROADCAST))
+		memset(eui, 0, 2);
+	else
+		ieee802154_le16_to_be16(eui, &wpan_dev->pan_id);
+
+	/* The "Universal/Local" (U/L) bit shall be set to zero */
+	eui[0] &= ~2;
+	eui[2] = 0;
+	eui[3] = 0xFF;
+	eui[4] = 0xFE;
+	eui[5] = 0;
+	ieee802154_le16_to_be16(&eui[6], &wpan_dev->short_addr);
+	return 0;
+}
+#endif
+
 static void addrconf_addr_gen(struct inet6_dev *idev, bool prefix_route)
 {
 	struct in6_addr addr;
@@ -3088,6 +3119,15 @@ static void addrconf_addr_gen(struct inet6_dev *idev, bool prefix_route)
 			addrconf_add_linklocal(idev, &addr, 0);
 		else if (prefix_route)
 			addrconf_prefix_route(&addr, 64, idev->dev, 0, 0);
+
+#ifdef CONFIG_IEEE802154_6LOWPAN
+		/* 802.15.4 6LoWPAN short address slaac handling */
+		if (lowpan_is_ll(idev->dev, LOWPAN_LLTYPE_IEEE802154)) {
+			if (addrconf_ifid_ieee802154(addr.s6_addr + 8,
+						     idev->dev) == 0)
+				addrconf_add_linklocal(idev, &addr, 0);
+		}
+#endif
 		break;
 	case IN6_ADDR_GEN_MODE_NONE:
 	default:
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 14/19] ndisc: add addr_len parameter to ndisc_opt_addr_space
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (12 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 13/19] addrconf: add 802.15.4 short addr slaac Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 15/19] ndisc: add addr_len parameter to ndisc_opt_addr_data Alexander Aring
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch makes the address length as argument for the
ndisc_opt_addr_space function. This is necessary to handle addresses
which don't use dev->addr_len as address length.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/net/ndisc.h |  8 ++++----
 net/ipv6/ndisc.c    | 10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 2d8edaa..ef43e88 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -127,10 +127,10 @@ static inline int ndisc_addr_option_pad(unsigned short type)
 	}
 }
 
-static inline int ndisc_opt_addr_space(struct net_device *dev)
+static inline int ndisc_opt_addr_space(struct net_device *dev,
+				       unsigned char addr_len)
 {
-	return NDISC_OPT_SPACE(dev->addr_len +
-			       ndisc_addr_option_pad(dev->type));
+	return NDISC_OPT_SPACE(addr_len + ndisc_addr_option_pad(dev->type));
 }
 
 static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p,
@@ -139,7 +139,7 @@ static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p,
 	u8 *lladdr = (u8 *)(p + 1);
 	int lladdrlen = p->nd_opt_len << 3;
 	int prepad = ndisc_addr_option_pad(dev->type);
-	if (lladdrlen != ndisc_opt_addr_space(dev))
+	if (lladdrlen != ndisc_opt_addr_space(dev, dev->addr_len))
 		return NULL;
 	return lladdr + prepad;
 }
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index c245895..69e20e3 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -154,7 +154,7 @@ static void ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data)
 {
 	int pad   = ndisc_addr_option_pad(skb->dev->type);
 	int data_len = skb->dev->addr_len;
-	int space = ndisc_opt_addr_space(skb->dev);
+	int space = ndisc_opt_addr_space(skb->dev, skb->dev->addr_len);
 	u8 *opt = skb_put(skb, space);
 
 	opt[0] = type;
@@ -509,7 +509,7 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
 	if (!dev->addr_len)
 		inc_opt = 0;
 	if (inc_opt)
-		optlen += ndisc_opt_addr_space(dev);
+		optlen += ndisc_opt_addr_space(dev, dev->addr_len);
 
 	skb = ndisc_alloc_skb(dev, sizeof(*msg) + optlen);
 	if (!skb)
@@ -574,7 +574,7 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
 	if (ipv6_addr_any(saddr))
 		inc_opt = false;
 	if (inc_opt)
-		optlen += ndisc_opt_addr_space(dev);
+		optlen += ndisc_opt_addr_space(dev, dev->addr_len);
 
 	skb = ndisc_alloc_skb(dev, sizeof(*msg) + optlen);
 	if (!skb)
@@ -626,7 +626,7 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
 	}
 #endif
 	if (send_sllao)
-		optlen += ndisc_opt_addr_space(dev);
+		optlen += ndisc_opt_addr_space(dev, dev->addr_len);
 
 	skb = ndisc_alloc_skb(dev, sizeof(*msg) + optlen);
 	if (!skb)
@@ -1563,7 +1563,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 			memcpy(ha_buf, neigh->ha, dev->addr_len);
 			read_unlock_bh(&neigh->lock);
 			ha = ha_buf;
-			optlen += ndisc_opt_addr_space(dev);
+			optlen += ndisc_opt_addr_space(dev, dev->addr_len);
 		} else
 			read_unlock_bh(&neigh->lock);
 
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 15/19] ndisc: add addr_len parameter to ndisc_opt_addr_data
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (13 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 14/19] ndisc: add addr_len parameter to ndisc_opt_addr_space Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 16/19] ndisc: add addr_len parameter to ndisc_fill_addr_option Alexander Aring
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch makes the address length as argument for the
ndisc_opt_addr_data function. This is necessary to handle addresses
which don't use dev->addr_len as address length.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/net/ndisc.h |  5 +++--
 net/ipv6/ndisc.c    | 11 +++++++----
 net/ipv6/route.c    |  2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index ef43e88..aac868e 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -134,12 +134,13 @@ static inline int ndisc_opt_addr_space(struct net_device *dev,
 }
 
 static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p,
-				      struct net_device *dev)
+				      struct net_device *dev,
+				      unsigned char addr_len)
 {
 	u8 *lladdr = (u8 *)(p + 1);
 	int lladdrlen = p->nd_opt_len << 3;
 	int prepad = ndisc_addr_option_pad(dev->type);
-	if (lladdrlen != ndisc_opt_addr_space(dev, dev->addr_len))
+	if (lladdrlen != ndisc_opt_addr_space(dev, addr_len))
 		return NULL;
 	return lladdr + prepad;
 }
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 69e20e3..4e91d5e 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -744,7 +744,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 	}
 
 	if (ndopts.nd_opts_src_lladdr) {
-		lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, dev);
+		lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, dev,
+					     dev->addr_len);
 		if (!lladdr) {
 			ND_PRINTK(2, warn,
 				  "NS: invalid link-layer address length\n");
@@ -916,7 +917,8 @@ static void ndisc_recv_na(struct sk_buff *skb)
 		return;
 	}
 	if (ndopts.nd_opts_tgt_lladdr) {
-		lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, dev);
+		lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, dev,
+					     dev->addr_len);
 		if (!lladdr) {
 			ND_PRINTK(2, warn,
 				  "NA: invalid link-layer address length\n");
@@ -1024,7 +1026,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
 
 	if (ndopts.nd_opts_src_lladdr) {
 		lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
-					     skb->dev);
+					     skb->dev, skb->dev->addr_len);
 		if (!lladdr)
 			goto out;
 	}
@@ -1322,7 +1324,8 @@ skip_linkparms:
 		u8 *lladdr = NULL;
 		if (ndopts.nd_opts_src_lladdr) {
 			lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
-						     skb->dev);
+						     skb->dev,
+						     skb->dev->addr_len);
 			if (!lladdr) {
 				ND_PRINTK(2, warn,
 					  "RA: invalid link-layer address length\n");
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index ed44663..cc180b3 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2157,7 +2157,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
 	lladdr = NULL;
 	if (ndopts.nd_opts_tgt_lladdr) {
 		lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr,
-					     skb->dev);
+					     skb->dev, skb->dev->addr_len);
 		if (!lladdr) {
 			net_dbg_ratelimited("rt6_redirect: invalid link-layer address length\n");
 			return;
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 16/19] ndisc: add addr_len parameter to ndisc_fill_addr_option
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (14 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 15/19] ndisc: add addr_len parameter to ndisc_opt_addr_data Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 17/19] ndisc: add short address to ndisc opts parsing Alexander Aring
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch makes the address length as argument for the
ndisc_fill_addr_option function. This is necessary to handle addresses
which don't use dev->addr_len as address length.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 net/ipv6/ndisc.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 4e91d5e..176c7c4 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -150,11 +150,11 @@ struct neigh_table nd_tbl = {
 };
 EXPORT_SYMBOL_GPL(nd_tbl);
 
-static void ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data)
+static void ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
+				   int data_len)
 {
 	int pad   = ndisc_addr_option_pad(skb->dev->type);
-	int data_len = skb->dev->addr_len;
-	int space = ndisc_opt_addr_space(skb->dev, skb->dev->addr_len);
+	int space = ndisc_opt_addr_space(skb->dev, data_len);
 	u8 *opt = skb_put(skb, space);
 
 	opt[0] = type;
@@ -528,7 +528,7 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
 
 	if (inc_opt)
 		ndisc_fill_addr_option(skb, ND_OPT_TARGET_LL_ADDR,
-				       dev->dev_addr);
+				       dev->dev_addr, dev->addr_len);
 
 
 	ndisc_send_skb(skb, daddr, src_addr);
@@ -590,7 +590,7 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
 
 	if (inc_opt)
 		ndisc_fill_addr_option(skb, ND_OPT_SOURCE_LL_ADDR,
-				       dev->dev_addr);
+				       dev->dev_addr, dev->addr_len);
 
 	ndisc_send_skb(skb, daddr, saddr);
 }
@@ -641,7 +641,7 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
 
 	if (send_sllao)
 		ndisc_fill_addr_option(skb, ND_OPT_SOURCE_LL_ADDR,
-				       dev->dev_addr);
+				       dev->dev_addr, dev->addr_len);
 
 	ndisc_send_skb(skb, daddr, saddr);
 }
@@ -1597,7 +1597,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	 */
 
 	if (ha)
-		ndisc_fill_addr_option(buff, ND_OPT_TARGET_LL_ADDR, ha);
+		ndisc_fill_addr_option(buff, ND_OPT_TARGET_LL_ADDR, ha,
+				       dev->addr_len);
 
 	/*
 	 *	build redirect option and copy skb over to the new packet.
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 17/19] ndisc: add short address to ndisc opts parsing
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (15 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 16/19] ndisc: add addr_len parameter to ndisc_fill_addr_option Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 18/19] ndisc: add support for short address option Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 19/19] 6lowpan: add support for 802.15.4 short addr handling Alexander Aring
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch adds support for parsing the short address in case of
source/target link-layer address option. The short address is inidcated
by length option field equal to 1, otherwise the extended address will
be handled like the normal length option fields.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 include/net/ndisc.h |  9 ++++++++-
 net/ipv6/ndisc.c    | 54 +++++++++++++++++++++++++++++++++++++++++++++++------
 net/ipv6/route.c    |  2 +-
 3 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index aac868e..495750e 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -93,6 +93,9 @@ struct nd_opt_hdr {
 /* ND options */
 struct ndisc_options {
 	struct nd_opt_hdr *nd_opt_array[__ND_OPT_ARRAY_MAX];
+#ifdef CONFIG_IEEE802154_6LOWPAN
+	struct nd_opt_hdr *nd_802154_opt_array[__ND_OPT_ARRAY_MAX];
+#endif
 #ifdef CONFIG_IPV6_ROUTE_INFO
 	struct nd_opt_hdr *nd_opts_ri;
 	struct nd_opt_hdr *nd_opts_ri_end;
@@ -108,9 +111,13 @@ struct ndisc_options {
 #define nd_opts_rh		nd_opt_array[ND_OPT_REDIRECT_HDR]
 #define nd_opts_mtu		nd_opt_array[ND_OPT_MTU]
 
+#define nd_802154_opts_src_lladdr	nd_802154_opt_array[ND_OPT_SOURCE_LL_ADDR]
+#define nd_802154_opts_tgt_lladdr	nd_802154_opt_array[ND_OPT_TARGET_LL_ADDR]
+
 #define NDISC_OPT_SPACE(len) (((len)+2+7)&~7)
 
-struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
+struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
+					  u8 *opt, int opt_len,
 					  struct ndisc_options *ndopts);
 
 /*
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 176c7c4..5c96ec6 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -60,6 +60,7 @@
 #include <net/ip6_route.h>
 #include <net/addrconf.h>
 #include <net/icmp.h>
+#include <net/6lowpan.h>
 
 #include <net/netlink.h>
 #include <linux/rtnetlink.h>
@@ -202,7 +203,42 @@ static struct nd_opt_hdr *ndisc_next_useropt(struct nd_opt_hdr *cur,
 	return cur <= end && ndisc_is_useropt(cur) ? cur : NULL;
 }
 
-struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
+#ifdef CONFIG_IEEE802154_6LOWPAN
+
+#define NDISC_802154_EXTENDED_ADDR_LENGTH	2
+#define NDISC_802154_SHORT_ADDR_LENGTH		1
+
+static void ndisc_802154_parse_addr_options(struct ndisc_options *ndopts,
+					    struct nd_opt_hdr *nd_opt)
+{
+	switch (nd_opt->nd_opt_len) {
+	case NDISC_802154_EXTENDED_ADDR_LENGTH:
+		if (ndopts->nd_opt_array[nd_opt->nd_opt_type])
+			ND_PRINTK(2, warn,
+				  "%s: duplicated extended addr ND6 option found: type=%d\n",
+				  __func__, nd_opt->nd_opt_type);
+		else
+			ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
+		break;
+	case NDISC_802154_SHORT_ADDR_LENGTH:
+		if (ndopts->nd_802154_opt_array[nd_opt->nd_opt_type])
+			ND_PRINTK(2, warn,
+				  "%s: duplicated short addr ND6 option found: type=%d\n",
+				  __func__, nd_opt->nd_opt_type);
+		else
+			ndopts->nd_802154_opt_array[nd_opt->nd_opt_type] = nd_opt;
+		break;
+	default:
+		ND_PRINTK(2, warn,
+			  "%s: invalid length detected: type=%d\n",
+			  __func__, nd_opt->nd_opt_type);
+		break;
+	}
+}
+#endif
+
+struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
+					  u8 *opt, int opt_len,
 					  struct ndisc_options *ndopts)
 {
 	struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)opt;
@@ -220,6 +256,12 @@ struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
 		switch (nd_opt->nd_opt_type) {
 		case ND_OPT_SOURCE_LL_ADDR:
 		case ND_OPT_TARGET_LL_ADDR:
+#ifdef CONFIG_IEEE802154_6LOWPAN
+			if (lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154)) {
+				ndisc_802154_parse_addr_options(ndopts, nd_opt);
+				break;
+			}
+#endif
 		case ND_OPT_MTU:
 		case ND_OPT_REDIRECT_HDR:
 			if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
@@ -738,7 +780,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 		return;
 	}
 
-	if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
+	if (!ndisc_parse_options(dev, msg->opt, ndoptlen, &ndopts)) {
 		ND_PRINTK(2, warn, "NS: invalid ND options\n");
 		return;
 	}
@@ -912,7 +954,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
 	    idev->cnf.drop_unsolicited_na)
 		return;
 
-	if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
+	if (!ndisc_parse_options(dev, msg->opt, ndoptlen, &ndopts)) {
 		ND_PRINTK(2, warn, "NS: invalid ND option\n");
 		return;
 	}
@@ -1019,7 +1061,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
 		goto out;
 
 	/* Parse ND options */
-	if (!ndisc_parse_options(rs_msg->opt, ndoptlen, &ndopts)) {
+	if (!ndisc_parse_options(skb->dev, rs_msg->opt, ndoptlen, &ndopts)) {
 		ND_PRINTK(2, notice, "NS: invalid ND option, ignored\n");
 		goto out;
 	}
@@ -1137,7 +1179,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 		return;
 	}
 
-	if (!ndisc_parse_options(opt, optlen, &ndopts)) {
+	if (!ndisc_parse_options(skb->dev, opt, optlen, &ndopts)) {
 		ND_PRINTK(2, warn, "RA: invalid ND options\n");
 		return;
 	}
@@ -1462,7 +1504,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 		return;
 	}
 
-	if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts))
+	if (!ndisc_parse_options(skb->dev, msg->opt, ndoptlen, &ndopts))
 		return;
 
 	if (!ndopts.nd_opts_rh) {
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index cc180b3..5fa276d 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2149,7 +2149,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
 	 *	first-hop router for the specified ICMP Destination Address.
 	 */
 
-	if (!ndisc_parse_options(msg->opt, optlen, &ndopts)) {
+	if (!ndisc_parse_options(skb->dev, msg->opt, optlen, &ndopts)) {
 		net_dbg_ratelimited("rt6_redirect: invalid ND options\n");
 		return;
 	}
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 18/19] ndisc: add support for short address option
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (16 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 17/19] ndisc: add short address to ndisc opts parsing Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  2016-03-22 13:15 ` [RFC bluetooth-next 19/19] 6lowpan: add support for 802.15.4 short addr handling Alexander Aring
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch will add 802.15.4 6lowpan handling when parsing NS and NA
messages. The 802.15.4 6lowpan neighbour has a parivate data room for
storing an optional address which is available via link layer address
option fields.

This option field will currently always be written if a neighbour was
returned by neighbour lookup functionality.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 net/ipv6/ndisc.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 121 insertions(+), 5 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 5c96ec6..6d9768e 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -235,6 +235,52 @@ static void ndisc_802154_parse_addr_options(struct ndisc_options *ndopts,
 		break;
 	}
 }
+
+static void ndisc_802154_neigh_update(struct neighbour *n, void *priv)
+{
+	struct lowpan_802154_neigh *neigh = lowpan_802154_neigh(neighbour_priv(n));
+
+	write_lock_bh(&n->lock);
+	if (priv)
+		ieee802154_be16_to_le16(&neigh->short_addr, priv);
+	else
+		neigh->short_addr = cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC);
+	write_unlock_bh(&n->lock);
+}
+
+static inline int ndisc_802154_short_addr_space(struct net_device *dev)
+{
+	struct wpan_dev *wpan_dev;
+	int addr_space = 0;
+
+	if (lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154)) {
+		wpan_dev = lowpan_802154_dev(dev)->wdev->ieee802154_ptr;
+
+		if (ieee802154_is_valid_src_short_addr(wpan_dev->short_addr))
+			addr_space = ndisc_opt_addr_space(dev, IEEE802154_SHORT_ADDR_LEN);
+	}
+
+	return addr_space;
+}
+
+static inline void ndisc_802154_short_addr_option(struct net_device *dev,
+						  struct sk_buff *skb,
+						  int type)
+{
+	struct wpan_dev *wpan_dev;
+	__be16 short_addr;
+
+	if (lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154)) {
+		wpan_dev = lowpan_802154_dev(dev)->wdev->ieee802154_ptr;
+
+		if (ieee802154_is_valid_src_short_addr(wpan_dev->short_addr)) {
+			ieee802154_le16_to_be16(&short_addr,
+						&wpan_dev->short_addr);
+			ndisc_fill_addr_option(skb, type, &short_addr,
+					       IEEE802154_SHORT_ADDR_LEN);
+		}
+	}
+}
 #endif
 
 struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
@@ -550,8 +596,12 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
 
 	if (!dev->addr_len)
 		inc_opt = 0;
-	if (inc_opt)
+	if (inc_opt) {
 		optlen += ndisc_opt_addr_space(dev, dev->addr_len);
+#ifdef CONFIG_IEEE802154_6LOWPAN
+		optlen += ndisc_802154_short_addr_space(dev);
+#endif
+	}
 
 	skb = ndisc_alloc_skb(dev, sizeof(*msg) + optlen);
 	if (!skb)
@@ -568,9 +618,14 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
 		.target = *solicited_addr,
 	};
 
-	if (inc_opt)
+	if (inc_opt) {
 		ndisc_fill_addr_option(skb, ND_OPT_TARGET_LL_ADDR,
 				       dev->dev_addr, dev->addr_len);
+#ifdef CONFIG_IEEE802154_6LOWPAN
+		ndisc_802154_short_addr_option(dev, skb,
+					       ND_OPT_TARGET_LL_ADDR);
+#endif
+	}
 
 
 	ndisc_send_skb(skb, daddr, src_addr);
@@ -615,8 +670,12 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
 
 	if (ipv6_addr_any(saddr))
 		inc_opt = false;
-	if (inc_opt)
+	if (inc_opt) {
 		optlen += ndisc_opt_addr_space(dev, dev->addr_len);
+#ifdef CONFIG_IEEE802154_6LOWPAN
+		optlen += ndisc_802154_short_addr_space(dev);
+#endif
+	}
 
 	skb = ndisc_alloc_skb(dev, sizeof(*msg) + optlen);
 	if (!skb)
@@ -630,9 +689,14 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
 		.target = *solicit,
 	};
 
-	if (inc_opt)
+	if (inc_opt) {
 		ndisc_fill_addr_option(skb, ND_OPT_SOURCE_LL_ADDR,
 				       dev->dev_addr, dev->addr_len);
+#ifdef CONFIG_IEEE802154_6LOWPAN
+		ndisc_802154_short_addr_option(dev, skb,
+					       ND_OPT_SOURCE_LL_ADDR);
+#endif
+	}
 
 	ndisc_send_skb(skb, daddr, saddr);
 }
@@ -760,6 +824,9 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 	int dad = ipv6_addr_any(saddr);
 	bool inc;
 	int is_router = -1;
+#ifdef CONFIG_IEEE802154_6LOWPAN
+	u8 *lladdr_short = NULL;
+#endif
 
 	if (skb->len < sizeof(struct nd_msg)) {
 		ND_PRINTK(2, warn, "NS: packet too short\n");
@@ -806,6 +873,30 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 		}
 	}
 
+#ifdef CONFIG_IEEE802154_6LOWPAN
+	if (lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154) &&
+	    ndopts.nd_802154_opts_src_lladdr) {
+		lladdr_short = ndisc_opt_addr_data(ndopts.nd_802154_opts_src_lladdr,
+						   dev, IEEE802154_SHORT_ADDR_LEN);
+		if (!lladdr_short) {
+			ND_PRINTK(2, warn,
+				  "NS: invalid short link-layer address length\n");
+			return;
+		}
+
+		/* RFC2461 7.1.1:
+		 *	If the IP source address is the unspecified address,
+		 *	there MUST NOT be source link-layer address option
+		 *	in the message.
+		 */
+		if (dad) {
+			ND_PRINTK(2, warn,
+				  "NS: bad DAD packet (short link-layer address option)\n");
+			return;
+		}
+	}
+#endif
+
 	inc = ipv6_addr_is_multicast(daddr);
 
 	ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
@@ -898,10 +989,15 @@ have_ifp:
 	 */
 	neigh = __neigh_lookup(&nd_tbl, saddr, dev,
 			       !inc || lladdr || !dev->addr_len);
-	if (neigh)
+	if (neigh) {
 		neigh_update(neigh, lladdr, NUD_STALE,
 			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
 			     NEIGH_UPDATE_F_OVERRIDE);
+#ifdef CONFIG_IEEE802154_6LOWPAN
+		if (lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154))
+			ndisc_802154_neigh_update(neigh, lladdr_short);
+#endif
+	}
 	if (neigh || !dev->header_ops) {
 		ndisc_send_na(dev, saddr, &msg->target, !!is_router,
 			      true, (ifp != NULL && inc), inc);
@@ -929,6 +1025,9 @@ static void ndisc_recv_na(struct sk_buff *skb)
 	struct inet6_dev *idev = __in6_dev_get(dev);
 	struct inet6_ifaddr *ifp;
 	struct neighbour *neigh;
+#ifdef CONFIG_IEEE802154_6LOWPAN
+	u8 *lladdr_short = NULL;
+#endif
 
 	if (skb->len < sizeof(struct nd_msg)) {
 		ND_PRINTK(2, warn, "NA: packet too short\n");
@@ -967,6 +1066,18 @@ static void ndisc_recv_na(struct sk_buff *skb)
 			return;
 		}
 	}
+#ifdef CONFIG_IEEE802154_6LOWPAN
+	if (lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154) &&
+	    ndopts.nd_802154_opts_tgt_lladdr) {
+		lladdr_short = ndisc_opt_addr_data(ndopts.nd_802154_opts_tgt_lladdr,
+						   dev, IEEE802154_SHORT_ADDR_LEN);
+		if (!lladdr_short) {
+			ND_PRINTK(2, warn,
+				  "NA: invalid short link-layer address length\n");
+			return;
+		}
+	}
+#endif
 	ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
 	if (ifp) {
 		if (skb->pkt_type != PACKET_LOOPBACK
@@ -1018,6 +1129,11 @@ static void ndisc_recv_na(struct sk_buff *skb)
 			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
 			     (msg->icmph.icmp6_router ? NEIGH_UPDATE_F_ISROUTER : 0));
 
+#ifdef CONFIG_IEEE802154_6LOWPAN
+		if (lowpan_is_ll(dev, LOWPAN_LLTYPE_IEEE802154))
+			ndisc_802154_neigh_update(neigh, lladdr_short);
+#endif
+
 		if ((old_flags & ~neigh->flags) & NTF_ROUTER) {
 			/*
 			 * Change: router to host
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [RFC bluetooth-next 19/19] 6lowpan: add support for 802.15.4 short addr handling
  2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
                   ` (17 preceding siblings ...)
  2016-03-22 13:15 ` [RFC bluetooth-next 18/19] ndisc: add support for short address option Alexander Aring
@ 2016-03-22 13:15 ` Alexander Aring
  18 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-03-22 13:15 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, jukka.rissanen, hannes, stefan, mcr, werner, Alexander Aring

This patch adds necessary handling for use the short address for
802.15.4 6lowpan. It contains support for IPHC address compression
and new matching algorithmn to decide which link layer address will be
used for 802.15.4 frame.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
 net/6lowpan/iphc.c          |  87 ++++++++++++++++++++++++-------
 net/ieee802154/6lowpan/tx.c | 121 ++++++++++++++++++++++++--------------------
 2 files changed, 135 insertions(+), 73 deletions(-)

diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index d167ce5bd1..d161cfb 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -808,28 +808,84 @@ out:
 		return dam;
 }
 
-static u8 lowpan_compress_addr_64(u8 **hc_ptr, const struct in6_addr *ipaddr,
+static inline bool lowpan_iphc_compress_802154_lladdr(const struct in6_addr *ipaddr,
+						      const void *lladdr)
+{
+	const struct ieee802154_addr *addr = lladdr;
+	unsigned char extended_addr[EUI64_ADDR_LEN];
+	struct in6_addr tmp = {};
+	bool lladdr_compress = false;
+
+	switch (addr->mode) {
+	case IEEE802154_ADDR_LONG:
+		ieee802154_le64_to_be64(&extended_addr, &addr->extended_addr);
+		if (is_addr_mac_addr_based(ipaddr, extended_addr))
+			lladdr_compress = true;
+		break;
+	case IEEE802154_ADDR_SHORT:
+		/* fe:80::ff:fe00:XXXX
+		 *                \__/
+		 *             short_addr
+		 *
+		 * Universe/Local bit is zero.
+		 */
+		tmp.s6_addr[0] = 0xFE;
+		tmp.s6_addr[1] = 0x80;
+		tmp.s6_addr[11] = 0xFF;
+		tmp.s6_addr[12] = 0xFE;
+		ieee802154_le16_to_be16(&tmp.s6_addr16[7],
+					&addr->short_addr);
+		if (ipv6_addr_equal(&tmp, ipaddr))
+			lladdr_compress = true;
+		break;
+	default:
+		/* should never handled and filtered by 802154 6lowpan */
+		WARN_ON_ONCE(1);
+		break;
+	}
+
+	return lladdr_compress;
+}
+
+static u8 lowpan_compress_addr_64(u8 **hc_ptr, const struct net_device *dev,
+				  const struct in6_addr *ipaddr,
 				  const unsigned char *lladdr, bool sam)
 {
-	u8 dam = LOWPAN_IPHC_DAM_00;
+	u8 dam = LOWPAN_IPHC_DAM_01;
 
-	if (is_addr_mac_addr_based(ipaddr, lladdr)) {
-		dam = LOWPAN_IPHC_DAM_11; /* 0-bits */
-		pr_debug("address compression 0 bits\n");
-	} else if (lowpan_is_iid_16_bit_compressable(ipaddr)) {
+	switch (lowpan_dev(dev)->lltype) {
+	case LOWPAN_LLTYPE_IEEE802154:
+		if (lowpan_iphc_compress_802154_lladdr(ipaddr, lladdr)) {
+			dam = LOWPAN_IPHC_DAM_11; /* 0-bits */
+			pr_debug("address compression 0 bits\n");
+			goto out;
+		}
+		break;
+	default:
+		if (is_addr_mac_addr_based(ipaddr, lladdr)) {
+			dam = LOWPAN_IPHC_DAM_11; /* 0-bits */
+			pr_debug("address compression 0 bits\n");
+			goto out;
+		}
+		break;
+	}
+
+	if (lowpan_is_iid_16_bit_compressable(ipaddr)) {
 		/* compress IID to 16 bits xxxx::XXXX */
 		lowpan_push_hc_data(hc_ptr, &ipaddr->s6_addr16[7], 2);
 		dam = LOWPAN_IPHC_DAM_10; /* 16-bits */
 		raw_dump_inline(NULL, "Compressed ipv6 addr is (16 bits)",
 				*hc_ptr - 2, 2);
-	} else {
-		/* do not compress IID => xxxx::IID */
-		lowpan_push_hc_data(hc_ptr, &ipaddr->s6_addr16[4], 8);
-		dam = LOWPAN_IPHC_DAM_01; /* 64-bits */
-		raw_dump_inline(NULL, "Compressed ipv6 addr is (64 bits)",
-				*hc_ptr - 8, 8);
+		goto out;
 	}
 
+	/* do not compress IID => xxxx::IID */
+	lowpan_push_hc_data(hc_ptr, &ipaddr->s6_addr16[4], 8);
+	raw_dump_inline(NULL, "Compressed ipv6 addr is (64 bits)",
+			*hc_ptr - 8, 8);
+
+out:
+
 	if (sam)
 		return lowpan_iphc_dam_to_sam_value[dam];
 	else
@@ -1008,9 +1064,6 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
 	iphc0 = LOWPAN_DISPATCH_IPHC;
 	iphc1 = 0;
 
-	raw_dump_inline(__func__, "saddr", saddr, EUI64_ADDR_LEN);
-	raw_dump_inline(__func__, "daddr", daddr, EUI64_ADDR_LEN);
-
 	raw_dump_table(__func__, "sending raw skb network uncompressed packet",
 		       skb->data, skb->len);
 
@@ -1089,7 +1142,7 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
 			iphc1 |= LOWPAN_IPHC_SAC;
 		} else {
 			if (ipv6_saddr_type & IPV6_ADDR_LINKLOCAL) {
-				iphc1 |= lowpan_compress_addr_64(&hc_ptr,
+				iphc1 |= lowpan_compress_addr_64(&hc_ptr, dev,
 								 &hdr->saddr,
 								 saddr, true);
 				pr_debug("source address unicast link-local %pI6c iphc1 0x%02x\n",
@@ -1123,7 +1176,7 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
 			iphc1 |= LOWPAN_IPHC_DAC;
 		} else {
 			if (ipv6_daddr_type & IPV6_ADDR_LINKLOCAL) {
-				iphc1 |= lowpan_compress_addr_64(&hc_ptr,
+				iphc1 |= lowpan_compress_addr_64(&hc_ptr, dev,
 								 &hdr->daddr,
 								 daddr, false);
 				pr_debug("dest address unicast link-local %pI6c iphc1 0x%02x\n",
diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c
index e459afd..05753a3 100644
--- a/net/ieee802154/6lowpan/tx.c
+++ b/net/ieee802154/6lowpan/tx.c
@@ -9,6 +9,7 @@
  */
 
 #include <net/6lowpan.h>
+#include <net/ndisc.h>
 #include <net/ieee802154_netdev.h>
 #include <net/mac802154.h>
 
@@ -17,19 +18,9 @@
 #define LOWPAN_FRAG1_HEAD_SIZE	0x4
 #define LOWPAN_FRAGN_HEAD_SIZE	0x5
 
-/* don't save pan id, it's intra pan */
-struct lowpan_addr {
-	u8 mode;
-	union {
-		/* IPv6 needs big endian here */
-		__be64 extended_addr;
-		__be16 short_addr;
-	} u;
-};
-
 struct lowpan_addr_info {
-	struct lowpan_addr daddr;
-	struct lowpan_addr saddr;
+	struct ieee802154_addr daddr;
+	struct ieee802154_addr saddr;
 };
 
 static inline struct
@@ -48,12 +39,14 @@ lowpan_addr_info *lowpan_skb_priv(const struct sk_buff *skb)
  * RAW/DGRAM sockets.
  */
 int lowpan_header_create(struct sk_buff *skb, struct net_device *ldev,
-			 unsigned short type, const void *_daddr,
-			 const void *_saddr, unsigned int len)
+			 unsigned short type, const void *daddr,
+			 const void *saddr, unsigned int len)
 {
-	const u8 *saddr = _saddr;
-	const u8 *daddr = _daddr;
-	struct lowpan_addr_info *info;
+	struct wpan_dev *wpan_dev = lowpan_802154_dev(ldev)->wdev->ieee802154_ptr;
+	struct lowpan_addr_info *info = lowpan_skb_priv(skb);
+	struct lowpan_802154_neigh *llneigh = NULL;
+	const struct ipv6hdr *hdr = ipv6_hdr(skb);
+	struct neighbour *n;
 
 	/* TODO:
 	 * if this package isn't ipv6 one, where should it be routed?
@@ -61,21 +54,58 @@ int lowpan_header_create(struct sk_buff *skb, struct net_device *ldev,
 	if (type != ETH_P_IPV6)
 		return 0;
 
-	if (!saddr)
-		saddr = ldev->dev_addr;
+	/* intra-pan communication */
+	info->saddr.pan_id = wpan_dev->pan_id;
+	info->daddr.pan_id = info->saddr.pan_id;
+
+	if (!memcmp(daddr, ldev->broadcast, EUI64_ADDR_LEN)) {
+		info->daddr.short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
+		info->daddr.mode = IEEE802154_ADDR_SHORT;
+	} else {
+		struct in6_addr daddr_extended = {};
+
+		lowpan_iphc_uncompress_eui64_lladdr(&daddr_extended, daddr);
+		info->daddr.mode = IEEE802154_ADDR_LONG;
+		ieee802154_be64_to_le64(&info->daddr.extended_addr, daddr);
+
+		n = neigh_lookup(&nd_tbl, &hdr->daddr, ldev);
+		if (n)
+			llneigh = lowpan_802154_neigh(neighbour_priv(n));
+
+		/* check for possible short addr handling and overwrite
+		 * extended. Only if extended_addr will be compressed
+		 * then use extended address. Indicated when daddr_extended
+		 * and daddr is equal.
+		 */
+		if (!ipv6_addr_equal(&daddr_extended, &hdr->daddr) && llneigh) {
+			if (ieee802154_is_valid_src_short_addr(llneigh->short_addr)) {
+				info->daddr.mode = IEEE802154_ADDR_SHORT;
+				info->daddr.short_addr = llneigh->short_addr;
+			}
+		}
 
-	raw_dump_inline(__func__, "saddr", (unsigned char *)saddr, 8);
-	raw_dump_inline(__func__, "daddr", (unsigned char *)daddr, 8);
+		if (n)
+			neigh_release(n);
+	}
 
-	info = lowpan_skb_priv(skb);
+	if (!saddr) {
+		struct in6_addr saddr_extended = {};
+		__be64 _saddr;
 
-	/* TODO: Currently we only support extended_addr */
-	info->daddr.mode = IEEE802154_ADDR_LONG;
-	memcpy(&info->daddr.u.extended_addr, daddr,
-	       sizeof(info->daddr.u.extended_addr));
-	info->saddr.mode = IEEE802154_ADDR_LONG;
-	memcpy(&info->saddr.u.extended_addr, saddr,
-	       sizeof(info->daddr.u.extended_addr));
+		ieee802154_le64_to_be64(&_saddr, &wpan_dev->extended_addr);
+		lowpan_iphc_uncompress_eui64_lladdr(&saddr_extended, &_saddr);
+		if (ieee802154_is_valid_src_short_addr(wpan_dev->short_addr) &&
+		    !ipv6_addr_equal(&saddr_extended, &hdr->saddr)) {
+			info->saddr.mode = IEEE802154_ADDR_SHORT;
+			info->saddr.short_addr = wpan_dev->short_addr;
+		} else {
+			info->saddr.mode = IEEE802154_ADDR_LONG;
+			info->saddr.extended_addr = wpan_dev->extended_addr;
+		}
+	} else {
+		info->saddr.mode = IEEE802154_ADDR_LONG;
+		ieee802154_be64_to_le64(&info->saddr.extended_addr, saddr);
+	}
 
 	return 0;
 }
@@ -209,47 +239,26 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *ldev,
 			 u16 *dgram_size, u16 *dgram_offset)
 {
 	struct wpan_dev *wpan_dev = lowpan_802154_dev(ldev)->wdev->ieee802154_ptr;
-	struct ieee802154_addr sa, da;
 	struct ieee802154_mac_cb *cb = mac_cb_init(skb);
 	struct lowpan_addr_info info;
-	void *daddr, *saddr;
 
 	memcpy(&info, lowpan_skb_priv(skb), sizeof(info));
 
-	/* TODO: Currently we only support extended_addr */
-	daddr = &info.daddr.u.extended_addr;
-	saddr = &info.saddr.u.extended_addr;
-
 	*dgram_size = skb->len;
-	lowpan_header_compress(skb, ldev, daddr, saddr);
+	lowpan_header_compress(skb, ldev, &info.daddr, &info.saddr);
 	/* dgram_offset = (saved bytes after compression) + lowpan header len */
 	*dgram_offset = (*dgram_size - skb->len) + skb_network_header_len(skb);
 
 	cb->type = IEEE802154_FC_TYPE_DATA;
 
-	/* prepare wpan address data */
-	sa.mode = IEEE802154_ADDR_LONG;
-	sa.pan_id = wpan_dev->pan_id;
-	sa.extended_addr = ieee802154_devaddr_from_raw(saddr);
-
-	/* intra-PAN communications */
-	da.pan_id = sa.pan_id;
-
-	/* if the destination address is the broadcast address, use the
-	 * corresponding short address
-	 */
-	if (!memcmp(daddr, ldev->broadcast, EUI64_ADDR_LEN)) {
-		da.mode = IEEE802154_ADDR_SHORT;
-		da.short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
+	if (info.daddr.mode == IEEE802154_ADDR_SHORT &&
+	    ieee802154_is_broadcast_short_addr(info.daddr.short_addr))
 		cb->ackreq = false;
-	} else {
-		da.mode = IEEE802154_ADDR_LONG;
-		da.extended_addr = ieee802154_devaddr_from_raw(daddr);
+	else
 		cb->ackreq = wpan_dev->ackreq;
-	}
 
-	return wpan_dev_hard_header(skb, lowpan_802154_dev(ldev)->wdev, &da,
-				    &sa, 0);
+	return wpan_dev_hard_header(skb, lowpan_802154_dev(ldev)->wdev,
+				    &info.daddr, &info.saddr, 0);
 }
 
 netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev)
-- 
2.7.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 04/19] ieee802154: 6lowpan: fix short addr hash
  2016-03-22 13:15 ` [RFC bluetooth-next 04/19] ieee802154: 6lowpan: fix short addr hash Alexander Aring
@ 2016-03-23  9:58   ` Stefan Schmidt
  0 siblings, 0 replies; 30+ messages in thread
From: Stefan Schmidt @ 2016-03-23  9:58 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, jukka.rissanen, hannes, mcr, werner

Hello.

On 22/03/16 14:15, Alexander Aring wrote:
> The short address is unique in combination with the panid. This patch
> will add the panid for generating an ieee802154 address hash.
>
> Signed-off-by: Alexander Aring <aar@pengutronix.de>
> ---
>   net/ieee802154/6lowpan/6lowpan_i.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
> index b4e17a7..b4092a9 100644
> --- a/net/ieee802154/6lowpan/6lowpan_i.h
> +++ b/net/ieee802154/6lowpan/6lowpan_i.h
> @@ -41,7 +41,7 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
>   		return (((__force u64)a->extended_addr) >> 32) ^
>   			(((__force u64)a->extended_addr) & 0xffffffff);
>   	case IEEE802154_ADDR_SHORT:
> -		return (__force u32)(a->short_addr);
> +		return (__force u32)(a->short_addr + (a->pan_id << 16));
>   	default:
>   		return 0;
>   	}

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 01/19] ieee802154: cleanups for ieee802154.h
  2016-03-22 13:14 ` [RFC bluetooth-next 01/19] ieee802154: cleanups for ieee802154.h Alexander Aring
@ 2016-03-23  9:59   ` Stefan Schmidt
  0 siblings, 0 replies; 30+ messages in thread
From: Stefan Schmidt @ 2016-03-23  9:59 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, jukka.rissanen, hannes, mcr, werner

Hello.

On 22/03/16 14:14, Alexander Aring wrote:
> This patch removes some const from non-pointer types and fixes the
> function name for the ieee802154_is_valid_extended_unicast_addr
> comment.
>
> Signed-off-by: Alexander Aring<aar@pengutronix.de>
> ---
>   include/linux/ieee802154.h | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
> index d3e4156..303f446 100644
> --- a/include/linux/ieee802154.h
> +++ b/include/linux/ieee802154.h
> @@ -260,17 +260,17 @@ static inline bool ieee802154_is_intra_pan(__le16 fc)
>    *
>    * @len: psdu len with (MHR + payload + MFR)
>    */
> -static inline bool ieee802154_is_valid_psdu_len(const u8 len)
> +static inline bool ieee802154_is_valid_psdu_len(u8 len)
>   {
>   	return (len == IEEE802154_ACK_PSDU_LEN ||
>   		(len >= IEEE802154_MIN_PSDU_LEN && len <= IEEE802154_MTU));
>   }
>   
>   /**
> - * ieee802154_is_valid_psdu_len - check if extended addr is valid
> + * ieee802154_is_valid_extended_unicast_addr - check if extended addr is valid
>    * @addr: extended addr to check
>    */
> -static inline bool ieee802154_is_valid_extended_unicast_addr(const __le64 addr)
> +static inline bool ieee802154_is_valid_extended_unicast_addr(__le64 addr)
>   {
>   	/* Bail out if the address is all zero, or if the group
>   	 * address bit is set.

Looks fine. This one does not need to wait for the rest of the patches 
to go in either.

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 02/19] ieee802154: add short address helpers
  2016-03-22 13:14 ` [RFC bluetooth-next 02/19] ieee802154: add short address helpers Alexander Aring
@ 2016-03-23  9:59   ` Stefan Schmidt
  0 siblings, 0 replies; 30+ messages in thread
From: Stefan Schmidt @ 2016-03-23  9:59 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, jukka.rissanen, hannes, mcr, werner

Hello.

On 22/03/16 14:14, Alexander Aring wrote:
> This patch introduce some short address handling functionality into
> ieee802154 headers.
>
> Signed-off-by: Alexander Aring<aar@pengutronix.de>
> ---
>   include/linux/ieee802154.h | 29 +++++++++++++++++++++++++++++
>   include/net/mac802154.h    | 10 ++++++++++
>   2 files changed, 39 insertions(+)
>
> diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
> index 303f446..3b3ea58 100644
> --- a/include/linux/ieee802154.h
> +++ b/include/linux/ieee802154.h
> @@ -47,6 +47,7 @@
>   #define IEEE802154_ADDR_SHORT_UNSPEC	0xfffe
>   
>   #define IEEE802154_EXTENDED_ADDR_LEN	8
> +#define IEEE802154_SHORT_ADDR_LEN	2
>   
>   #define IEEE802154_LIFS_PERIOD		40
>   #define IEEE802154_SIFS_PERIOD		12
> @@ -280,6 +281,34 @@ static inline bool ieee802154_is_valid_extended_unicast_addr(__le64 addr)
>   }
>   
>   /**
> + * ieee802154_is_broadcast_short_addr - check if short addr is broadcast
> + * @addr: short addr to check
> + */
> +static inline bool ieee802154_is_broadcast_short_addr(__le16 addr)
> +{
> +	return addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST);

If I wrote this I would put it into parenthesis like this for clarity:

return (addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST));

But this is basically a nitpick and I honestly do not know what the kernel coding style has to say about it.


> +}
> +
> +/**
> + * ieee802154_is_unspec_short_addr - check if short addr is unspecified
> + * @addr: short addr to check
> + */
> +static inline bool ieee802154_is_unspec_short_addr(__le16 addr)
> +{
> +	return addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC);
> +}
> +
> +/**
> + * ieee802154_is_valid_src_short_addr - check if source short address is valid
> + * @addr: short addr to check
> + */
> +static inline bool ieee802154_is_valid_src_short_addr(__le16 addr)
> +{
> +	return !(ieee802154_is_broadcast_short_addr(addr) ||
> +		 ieee802154_is_unspec_short_addr(addr));
> +}
> +
> +/**
>    * ieee802154_random_extended_addr - generates a random extended address
>    * @addr: extended addr pointer to place the random address
>    */
> diff --git a/include/net/mac802154.h b/include/net/mac802154.h
> index 6cd7a70..e465c85 100644
> --- a/include/net/mac802154.h
> +++ b/include/net/mac802154.h
> @@ -288,6 +288,16 @@ static inline void ieee802154_le16_to_be16(void *be16_dst, const void *le16_src)
>   }
>   
>   /**
> + * ieee802154_be16_to_le16 - copies and convert be16 to le16
> + * @le16_dst: le16 destination pointer
> + * @be16_src: be16 source pointer
> + */
> +static inline void ieee802154_be16_to_le16(void *le16_dst, const void *be16_src)
> +{
> +	put_unaligned_le16(get_unaligned_be16(be16_src), le16_dst);
> +}
> +
> +/**
>    * ieee802154_alloc_hw - Allocate a new hardware device
>    *
>    * This must be called once for each hardware device. The returned pointer

Besides the nitpick this looks fine to me as well.

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 03/19] nl802154: avoid address change while running lowpan
  2016-03-22 13:14 ` [RFC bluetooth-next 03/19] nl802154: avoid address change while running lowpan Alexander Aring
@ 2016-03-23  9:59   ` Stefan Schmidt
  0 siblings, 0 replies; 30+ messages in thread
From: Stefan Schmidt @ 2016-03-23  9:59 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, jukka.rissanen, hannes, mcr, werner

Hello.

On 22/03/16 14:14, Alexander Aring wrote:
> he whole generating of autoconfiguration IPv6 link-local addresses based
> on a notification on interface up.
Maybe this?

"The generation of autoconfigured IPv6 link-local addresses starts with 
a notification on interface up."

> These addresses are based on mac
> addresses and are not changeable during interface up of IPv6 interfaces.
> This patch will disallow mac address changes while a lowpan interface
> for a wpan interface is up.

It might be worthwhile mentioning why we disallow the change of pan_id 
and short address here while you talk about the mac address. Knowing 
that pan_id plus some padding plus short address can be used as 
permanent address for SLA is not common knowledge.

> Signed-off-by: Alexander Aring<aar@pengutronix.de>
> ---
>   net/ieee802154/nl802154.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
> index 16ef0d9..5f1dc4b 100644
> --- a/net/ieee802154/nl802154.c
> +++ b/net/ieee802154/nl802154.c
> @@ -1074,6 +1074,11 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
>   	if (netif_running(dev))
>   		return -EBUSY;
>   
> +	if (wpan_dev->lowpan_dev) {
> +		if (netif_running(wpan_dev->lowpan_dev))
> +			return -EBUSY;
> +	}
> +
>   	/* don't change address fields on monitor */
>   	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR ||
>   	    !info->attrs[NL802154_ATTR_PAN_ID])
> @@ -1105,6 +1110,11 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
>   	if (netif_running(dev))
>   		return -EBUSY;
>   
> +	if (wpan_dev->lowpan_dev) {
> +		if (netif_running(wpan_dev->lowpan_dev))
> +			return -EBUSY;
> +	}
> +
>   	/* don't change address fields on monitor */
>   	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR ||
>   	    !info->attrs[NL802154_ATTR_SHORT_ADDR])

While I truly dislike behaviour changes I consider this one an actual 
bug fix as changing these values during runtime would not trigger a SLA 
change and we would thus be out of sync address wise which can lead to 
reall problematic situations.

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 06/19] 6lowpan: move lowpan_802154_dev to 6lowpan
  2016-03-22 13:15 ` [RFC bluetooth-next 06/19] 6lowpan: move lowpan_802154_dev to 6lowpan Alexander Aring
@ 2016-03-23 10:08   ` Stefan Schmidt
  0 siblings, 0 replies; 30+ messages in thread
From: Stefan Schmidt @ 2016-03-23 10:08 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, jukka.rissanen, hannes, mcr, werner

Hello.

On 22/03/16 14:15, Alexander Aring wrote:
> This patch moves the 802.15.4 link layer specific structures to generic
> 6lowpan. This is necessary for special 802.15.4 6lowpan handling in
> upper layers.
>
> Signed-off-by: Alexander Aring <aar@pengutronix.de>
> ---
>   include/net/6lowpan.h              | 12 ++++++++++++
>   net/ieee802154/6lowpan/6lowpan_i.h | 12 ------------
>   2 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
> index f204664..a0c01f5 100644
> --- a/include/net/6lowpan.h
> +++ b/include/net/6lowpan.h
> @@ -144,6 +144,18 @@ struct lowpan_dev *lowpan_dev(const struct net_device *dev)
>   	return netdev_priv(dev);
>   }
>   
> +/* private device info */
> +struct lowpan_802154_dev {
> +	struct net_device	*wdev; /* wpan device ptr */
> +	u16			fragment_tag;
> +};
> +
> +static inline struct
> +lowpan_802154_dev *lowpan_802154_dev(const struct net_device *dev)
> +{
> +	return (struct lowpan_802154_dev *)lowpan_dev(dev)->priv;
> +}
> +
>   struct lowpan_802154_cb {
>   	u16 d_tag;
>   	unsigned int d_size;
> diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
> index b02b74d..5ac7789 100644
> --- a/net/ieee802154/6lowpan/6lowpan_i.h
> +++ b/net/ieee802154/6lowpan/6lowpan_i.h
> @@ -47,18 +47,6 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
>   	}
>   }
>   
> -/* private device info */
> -struct lowpan_802154_dev {
> -	struct net_device	*wdev; /* wpan device ptr */
> -	u16			fragment_tag;
> -};
> -
> -static inline struct
> -lowpan_802154_dev *lowpan_802154_dev(const struct net_device *dev)
> -{
> -	return (struct lowpan_802154_dev *)lowpan_dev(dev)->priv;
> -}
> -
>   int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type);
>   void lowpan_net_frag_exit(void);
>   int lowpan_net_frag_init(void);

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 07/19] 6lowpan: iphc: rename add lowpan prefix
  2016-03-22 13:15 ` [RFC bluetooth-next 07/19] 6lowpan: iphc: rename add lowpan prefix Alexander Aring
@ 2016-03-23 10:09   ` Stefan Schmidt
  2016-04-08 17:36     ` Marcel Holtmann
  0 siblings, 1 reply; 30+ messages in thread
From: Stefan Schmidt @ 2016-03-23 10:09 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, jukka.rissanen, hannes, mcr, werner

Hello.

On 22/03/16 14:15, Alexander Aring wrote:
> This patch adds a lowpan prefix to each functions which doesn't have
> such prefix currently.
>
> Signed-off-by: Alexander Aring <aar@pengutronix.de>
> ---
>   net/6lowpan/iphc.c | 56 ++++++++++++++++++++++++++++++------------------------
>   1 file changed, 31 insertions(+), 25 deletions(-)
>
> diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
> index 798d5b2..d5a72e3 100644
> --- a/net/6lowpan/iphc.c
> +++ b/net/6lowpan/iphc.c
> @@ -151,8 +151,8 @@
>   #define LOWPAN_IPHC_CID_DCI(cid)	(cid & 0x0f)
>   #define LOWPAN_IPHC_CID_SCI(cid)	((cid & 0xf0) >> 4)
>   
> -static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
> -						const void *lladdr)
> +static inline void lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
> +						       const void *lladdr)
>   {
>   	/* fe:80::XXXX:XXXX:XXXX:XXXX
>   	 *        \_________________/
> @@ -167,8 +167,9 @@ static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
>   	ipaddr->s6_addr[8] ^= 0x02;
>   }
>   
> -static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
> -						 const void *lladdr)
> +static inline void
> +lowpan_iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
> +				     const void *lladdr)
>   {
>   	const struct ieee802154_addr *addr = lladdr;
>   	u8 eui64[EUI64_ADDR_LEN] = { };
> @@ -176,7 +177,7 @@ static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
>   	switch (addr->mode) {
>   	case IEEE802154_ADDR_LONG:
>   		ieee802154_le64_to_be64(eui64, &addr->extended_addr);
> -		iphc_uncompress_eui64_lladdr(ipaddr, eui64);
> +		lowpan_iphc_uncompress_eui64_lladdr(ipaddr, eui64);
>   		break;
>   	case IEEE802154_ADDR_SHORT:
>   		/* fe:80::ff:fe00:XXXX
> @@ -296,9 +297,10 @@ lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev,
>    *
>    * address_mode is the masked value for sam or dam value
>    */
> -static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
> -			   struct in6_addr *ipaddr, u8 address_mode,
> -			   const void *lladdr)
> +static int lowpan_iphc_uncompress_addr(struct sk_buff *skb,
> +				       const struct net_device *dev,
> +				       struct in6_addr *ipaddr,
> +				       u8 address_mode, const void *lladdr)
>   {
>   	bool fail;
>   
> @@ -329,10 +331,10 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
>   		fail = false;
>   		switch (lowpan_dev(dev)->lltype) {
>   		case LOWPAN_LLTYPE_IEEE802154:
> -			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
> +			lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>   			break;
>   		default:
> -			iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
> +			lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>   			break;
>   		}
>   		break;
> @@ -355,11 +357,11 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
>   /* Uncompress address function for source context
>    * based address(non-multicast).
>    */
> -static int uncompress_ctx_addr(struct sk_buff *skb,
> -			       const struct net_device *dev,
> -			       const struct lowpan_iphc_ctx *ctx,
> -			       struct in6_addr *ipaddr, u8 address_mode,
> -			       const void *lladdr)
> +static int lowpan_iphc_uncompress_ctx_addr(struct sk_buff *skb,
> +					   const struct net_device *dev,
> +					   const struct lowpan_iphc_ctx *ctx,
> +					   struct in6_addr *ipaddr,
> +					   u8 address_mode, const void *lladdr)
>   {
>   	bool fail;
>   
> @@ -390,10 +392,10 @@ static int uncompress_ctx_addr(struct sk_buff *skb,
>   		fail = false;
>   		switch (lowpan_dev(dev)->lltype) {
>   		case LOWPAN_LLTYPE_IEEE802154:
> -			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
> +			lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>   			break;
>   		default:
> -			iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
> +			lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>   			break;
>   		}
>   		ipv6_addr_prefix_copy(ipaddr, &ctx->pfx, ctx->plen);
> @@ -660,14 +662,16 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
>   		}
>   
>   		pr_debug("SAC bit is set. Handle context based source address.\n");
> -		err = uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
> -					  iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
> +		err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
> +						      iphc1 & LOWPAN_IPHC_SAM_MASK,
> +						      saddr);
>   		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
>   	} else {
>   		/* Source address uncompression */
>   		pr_debug("source address stateless compression\n");
> -		err = uncompress_addr(skb, dev, &hdr.saddr,
> -				      iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
> +		err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.saddr,
> +						  iphc1 & LOWPAN_IPHC_SAM_MASK,
> +						  saddr);
>   	}
>   
>   	/* Check on error of previous branch */
> @@ -705,13 +709,15 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
>   
>   		/* Destination address context based uncompression */
>   		pr_debug("DAC bit is set. Handle context based destination address.\n");
> -		err = uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
> -					  iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
> +		err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
> +						      iphc1 & LOWPAN_IPHC_DAM_MASK,
> +						      daddr);
>   		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
>   		break;
>   	default:
> -		err = uncompress_addr(skb, dev, &hdr.daddr,
> -				      iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
> +		err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.daddr,
> +						  iphc1 & LOWPAN_IPHC_DAM_MASK,
> +						  daddr);
>   		pr_debug("dest: stateless compression mode %d dest %pI6c\n",
>   			 iphc1 & LOWPAN_IPHC_DAM_MASK, &hdr.daddr);
>   		break;

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 13/19] addrconf: add 802.15.4 short addr slaac
  2016-03-22 13:15 ` [RFC bluetooth-next 13/19] addrconf: add 802.15.4 short addr slaac Alexander Aring
@ 2016-03-23 10:50   ` Hannes Frederic Sowa
  2016-04-05  8:20     ` Alexander Aring
  0 siblings, 1 reply; 30+ messages in thread
From: Hannes Frederic Sowa @ 2016-03-23 10:50 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, jukka.rissanen, stefan, mcr, werner

On 22.03.2016 14:15, Alexander Aring wrote:
> This patch adds the autoconfiguration if a valid 802.15.4 short address
> is available for 802.15.4 6LoWPAN interfaces.
>
> Signed-off-by: Alexander Aring <aar@pengutronix.de>
> ---
>   net/ipv6/addrconf.c | 40 ++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 40 insertions(+)
>
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 27aed1a..eb3e3fb 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -3058,6 +3058,37 @@ static void ipv6_gen_mode_random_init(struct inet6_dev *idev)
>   	s->initialized = true;
>   }
>
> +#ifdef CONFIG_IEEE802154_6LOWPAN
> +static int addrconf_ifid_ieee802154(u8 *eui, struct net_device *dev)
> +{
> +	struct wpan_dev *wpan_dev = lowpan_802154_dev(dev)->wdev->ieee802154_ptr;
> +
> +	/* Set short_addr autoconfiguration if short_addr is present only */
> +	if (!ieee802154_is_valid_src_short_addr(wpan_dev->short_addr))
> +		return -1;
> +
> +	/* For either address format, all zero addresses MUST NOT be used */
> +	if (wpan_dev->pan_id == cpu_to_le16(0x0000) &&
> +	    wpan_dev->short_addr == cpu_to_le16(0x0000))
> +		return -1;
> +
> +	/* Alternatively, if no PAN ID is known, 16 zero bits may be used */
> +	if (wpan_dev->pan_id == cpu_to_le16(IEEE802154_PAN_ID_BROADCAST))
> +		memset(eui, 0, 2);
> +	else
> +		ieee802154_le16_to_be16(eui, &wpan_dev->pan_id);
> +
> +	/* The "Universal/Local" (U/L) bit shall be set to zero */
> +	eui[0] &= ~2;
> +	eui[2] = 0;
> +	eui[3] = 0xFF;
> +	eui[4] = 0xFE;
> +	eui[5] = 0;
> +	ieee802154_le16_to_be16(&eui[6], &wpan_dev->short_addr);
> +	return 0;
> +}

static void configure lowpan_addrconf(idev, addr)
{
 > +			if (addrconf_ifid_ieee802154(addr.s6_addr + 8,
 > +						     idev->dev) == 0)
 > +				addrconf_add_linklocal(idev, &addr, 0);
}

#else

static void configure lowpan_addrconf(idev, addr)
{
}

> +#endif

So we don't need the ifdef in addrconf_addr_gen. I think it pretty much 
reflects what upstream wants.

> +
>   static void addrconf_addr_gen(struct inet6_dev *idev, bool prefix_route)
>   {
>   	struct in6_addr addr;
> @@ -3088,6 +3119,15 @@ static void addrconf_addr_gen(struct inet6_dev *idev, bool prefix_route)
>   			addrconf_add_linklocal(idev, &addr, 0);
>   		else if (prefix_route)
>   			addrconf_prefix_route(&addr, 64, idev->dev, 0, 0);
> +
> +		/* 802.15.4 6LoWPAN short address slaac handling */
> +		if (lowpan_is_ll(idev->dev, LOWPAN_LLTYPE_IEEE802154)) {
> +		}

Do you think it makes sense to put this under the label 
IN_ADDR_GEN_MODE_EUI64? I don't see a real issue with it, maybe it 
conflicts a little bit with the naming.

Otherwise I don't have any issue with the change.

Bye,
Hannes


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 13/19] addrconf: add 802.15.4 short addr slaac
  2016-03-23 10:50   ` Hannes Frederic Sowa
@ 2016-04-05  8:20     ` Alexander Aring
  0 siblings, 0 replies; 30+ messages in thread
From: Alexander Aring @ 2016-04-05  8:20 UTC (permalink / raw)
  To: Hannes Frederic Sowa, linux-wpan
  Cc: kernel, jukka.rissanen, stefan, mcr, werner

Hi Hannes,

thanks for your answer.

Am 03/23/2016 um 11:50 AM schrieb Hannes Frederic Sowa:
> On 22.03.2016 14:15, Alexander Aring wrote:
>> This patch adds the autoconfiguration if a valid 802.15.4 short address
>> is available for 802.15.4 6LoWPAN interfaces.
>>
>> Signed-off-by: Alexander Aring <aar@pengutronix.de>
>> ---
>>   net/ipv6/addrconf.c | 40 ++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 40 insertions(+)
>>
>> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>> index 27aed1a..eb3e3fb 100644
>> --- a/net/ipv6/addrconf.c
>> +++ b/net/ipv6/addrconf.c
>> @@ -3058,6 +3058,37 @@ static void ipv6_gen_mode_random_init(struct inet6_dev *idev)
>>       s->initialized = true;
>>   }
>>
>> +#ifdef CONFIG_IEEE802154_6LOWPAN
>> +static int addrconf_ifid_ieee802154(u8 *eui, struct net_device *dev)
>> +{
>> +    struct wpan_dev *wpan_dev = lowpan_802154_dev(dev)->wdev->ieee802154_ptr;
>> +
>> +    /* Set short_addr autoconfiguration if short_addr is present only */
>> +    if (!ieee802154_is_valid_src_short_addr(wpan_dev->short_addr))
>> +        return -1;
>> +
>> +    /* For either address format, all zero addresses MUST NOT be used */
>> +    if (wpan_dev->pan_id == cpu_to_le16(0x0000) &&
>> +        wpan_dev->short_addr == cpu_to_le16(0x0000))
>> +        return -1;
>> +
>> +    /* Alternatively, if no PAN ID is known, 16 zero bits may be used */
>> +    if (wpan_dev->pan_id == cpu_to_le16(IEEE802154_PAN_ID_BROADCAST))
>> +        memset(eui, 0, 2);
>> +    else
>> +        ieee802154_le16_to_be16(eui, &wpan_dev->pan_id);
>> +
>> +    /* The "Universal/Local" (U/L) bit shall be set to zero */
>> +    eui[0] &= ~2;
>> +    eui[2] = 0;
>> +    eui[3] = 0xFF;
>> +    eui[4] = 0xFE;
>> +    eui[5] = 0;
>> +    ieee802154_le16_to_be16(&eui[6], &wpan_dev->short_addr);
>> +    return 0;
>> +}
>
> static void configure lowpan_addrconf(idev, addr)
> {
> > +            if (addrconf_ifid_ieee802154(addr.s6_addr + 8,
> > +                             idev->dev) == 0)
> > +                addrconf_add_linklocal(idev, &addr, 0);
> }
>
> #else
>
> static void configure lowpan_addrconf(idev, addr)
> {
> }
>
>> +#endif
>
> So we don't need the ifdef in addrconf_addr_gen. I think it pretty much reflects what upstream wants.
>
>> +
>>   static void addrconf_addr_gen(struct inet6_dev *idev, bool prefix_route)
>>   {
>>       struct in6_addr addr;
>> @@ -3088,6 +3119,15 @@ static void addrconf_addr_gen(struct inet6_dev *idev, bool prefix_route)
>>               addrconf_add_linklocal(idev, &addr, 0);
>>           else if (prefix_route)
>>               addrconf_prefix_route(&addr, 64, idev->dev, 0, 0);
>> +
>> +        /* 802.15.4 6LoWPAN short address slaac handling */
>> +        if (lowpan_is_ll(idev->dev, LOWPAN_LLTYPE_IEEE802154)) {
>> +        }
>
> Do you think it makes sense to put this under the label IN_ADDR_GEN_MODE_EUI64? I don't see a real issue with it, maybe it conflicts a little bit with the naming.
>
> Otherwise I don't have any issue with the change.

I moved the complete part of generating such address into net/6lowpan/, there we have another
netdev notifier functionality for 6lowpan interfaces only.

I think this stuff is very 802.15.4 specific and it's good when we can move it outside the net/ipv6
implementation. I just need to add a "EXPORT_SYMBOL(addrconf_add_linklocal);", so I can
access that function from 6lowpan module.

For the ndisc parts, I added a ndisc_ops structure and add a net/6lowpan/ndisc.c file.
I will send a RFCv2 soon.

- Alex

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 07/19] 6lowpan: iphc: rename add lowpan prefix
  2016-03-23 10:09   ` Stefan Schmidt
@ 2016-04-08 17:36     ` Marcel Holtmann
  2016-04-11 17:00       ` Stefan Schmidt
  0 siblings, 1 reply; 30+ messages in thread
From: Marcel Holtmann @ 2016-04-08 17:36 UTC (permalink / raw)
  To: Stefan Schmidt
  Cc: Alexander Aring, linux-wpan, kernel, jukka.rissanen, hannes, mcr, werner

Hi Alex,

>> This patch adds a lowpan prefix to each functions which doesn't have
>> such prefix currently.
>> 
>> Signed-off-by: Alexander Aring <aar@pengutronix.de>
>> ---
>>  net/6lowpan/iphc.c | 56 ++++++++++++++++++++++++++++++------------------------
>>  1 file changed, 31 insertions(+), 25 deletions(-)
>> 
>> diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
>> index 798d5b2..d5a72e3 100644
>> --- a/net/6lowpan/iphc.c
>> +++ b/net/6lowpan/iphc.c
>> @@ -151,8 +151,8 @@
>>  #define LOWPAN_IPHC_CID_DCI(cid)	(cid & 0x0f)
>>  #define LOWPAN_IPHC_CID_SCI(cid)	((cid & 0xf0) >> 4)
>>  -static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
>> -						const void *lladdr)
>> +static inline void lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
>> +						       const void *lladdr)
>>  {
>>  	/* fe:80::XXXX:XXXX:XXXX:XXXX
>>  	 *        \_________________/
>> @@ -167,8 +167,9 @@ static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
>>  	ipaddr->s6_addr[8] ^= 0x02;
>>  }
>>  -static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
>> -						 const void *lladdr)
>> +static inline void
>> +lowpan_iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
>> +				     const void *lladdr)
>>  {
>>  	const struct ieee802154_addr *addr = lladdr;
>>  	u8 eui64[EUI64_ADDR_LEN] = { };
>> @@ -176,7 +177,7 @@ static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
>>  	switch (addr->mode) {
>>  	case IEEE802154_ADDR_LONG:
>>  		ieee802154_le64_to_be64(eui64, &addr->extended_addr);
>> -		iphc_uncompress_eui64_lladdr(ipaddr, eui64);
>> +		lowpan_iphc_uncompress_eui64_lladdr(ipaddr, eui64);
>>  		break;
>>  	case IEEE802154_ADDR_SHORT:
>>  		/* fe:80::ff:fe00:XXXX
>> @@ -296,9 +297,10 @@ lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev,
>>   *
>>   * address_mode is the masked value for sam or dam value
>>   */
>> -static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
>> -			   struct in6_addr *ipaddr, u8 address_mode,
>> -			   const void *lladdr)
>> +static int lowpan_iphc_uncompress_addr(struct sk_buff *skb,
>> +				       const struct net_device *dev,
>> +				       struct in6_addr *ipaddr,
>> +				       u8 address_mode, const void *lladdr)
>>  {
>>  	bool fail;
>>  @@ -329,10 +331,10 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
>>  		fail = false;
>>  		switch (lowpan_dev(dev)->lltype) {
>>  		case LOWPAN_LLTYPE_IEEE802154:
>> -			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>> +			lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>>  			break;
>>  		default:
>> -			iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>> +			lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>>  			break;
>>  		}
>>  		break;
>> @@ -355,11 +357,11 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
>>  /* Uncompress address function for source context
>>   * based address(non-multicast).
>>   */
>> -static int uncompress_ctx_addr(struct sk_buff *skb,
>> -			       const struct net_device *dev,
>> -			       const struct lowpan_iphc_ctx *ctx,
>> -			       struct in6_addr *ipaddr, u8 address_mode,
>> -			       const void *lladdr)
>> +static int lowpan_iphc_uncompress_ctx_addr(struct sk_buff *skb,
>> +					   const struct net_device *dev,
>> +					   const struct lowpan_iphc_ctx *ctx,
>> +					   struct in6_addr *ipaddr,
>> +					   u8 address_mode, const void *lladdr)
>>  {
>>  	bool fail;
>>  @@ -390,10 +392,10 @@ static int uncompress_ctx_addr(struct sk_buff *skb,
>>  		fail = false;
>>  		switch (lowpan_dev(dev)->lltype) {
>>  		case LOWPAN_LLTYPE_IEEE802154:
>> -			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>> +			lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>>  			break;
>>  		default:
>> -			iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>> +			lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>>  			break;
>>  		}
>>  		ipv6_addr_prefix_copy(ipaddr, &ctx->pfx, ctx->plen);
>> @@ -660,14 +662,16 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
>>  		}
>>    		pr_debug("SAC bit is set. Handle context based source address.\n");
>> -		err = uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
>> -					  iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
>> +		err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
>> +						      iphc1 & LOWPAN_IPHC_SAM_MASK,
>> +						      saddr);
>>  		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
>>  	} else {
>>  		/* Source address uncompression */
>>  		pr_debug("source address stateless compression\n");
>> -		err = uncompress_addr(skb, dev, &hdr.saddr,
>> -				      iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
>> +		err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.saddr,
>> +						  iphc1 & LOWPAN_IPHC_SAM_MASK,
>> +						  saddr);
>>  	}
>>    	/* Check on error of previous branch */
>> @@ -705,13 +709,15 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
>>    		/* Destination address context based uncompression */
>>  		pr_debug("DAC bit is set. Handle context based destination address.\n");
>> -		err = uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
>> -					  iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
>> +		err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
>> +						      iphc1 & LOWPAN_IPHC_DAM_MASK,
>> +						      daddr);
>>  		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
>>  		break;
>>  	default:
>> -		err = uncompress_addr(skb, dev, &hdr.daddr,
>> -				      iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
>> +		err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.daddr,
>> +						  iphc1 & LOWPAN_IPHC_DAM_MASK,
>> +						  daddr);
>>  		pr_debug("dest: stateless compression mode %d dest %pI6c\n",
>>  			 iphc1 & LOWPAN_IPHC_DAM_MASK, &hdr.daddr);
>>  		break;
> 
> Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>

if these are good to be merged, then I need a patch series without the RFC designation.

Regards

Marcel


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [RFC bluetooth-next 07/19] 6lowpan: iphc: rename add lowpan prefix
  2016-04-08 17:36     ` Marcel Holtmann
@ 2016-04-11 17:00       ` Stefan Schmidt
  0 siblings, 0 replies; 30+ messages in thread
From: Stefan Schmidt @ 2016-04-11 17:00 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Alexander Aring, linux-wpan, kernel, jukka.rissanen, hannes, mcr, werner

Hello.

On 08/04/16 19:36, Marcel Holtmann wrote:
> Hi Alex,
>
>>> This patch adds a lowpan prefix to each functions which doesn't have
>>> such prefix currently.
>>>
>>> Signed-off-by: Alexander Aring <aar@pengutronix.de>
>>> ---
>>>   net/6lowpan/iphc.c | 56 ++++++++++++++++++++++++++++++------------------------
>>>   1 file changed, 31 insertions(+), 25 deletions(-)
>>>
>>> diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
>>> index 798d5b2..d5a72e3 100644
>>> --- a/net/6lowpan/iphc.c
>>> +++ b/net/6lowpan/iphc.c
>>> @@ -151,8 +151,8 @@
>>>   #define LOWPAN_IPHC_CID_DCI(cid)	(cid & 0x0f)
>>>   #define LOWPAN_IPHC_CID_SCI(cid)	((cid & 0xf0) >> 4)
>>>   -static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
>>> -						const void *lladdr)
>>> +static inline void lowpan_iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
>>> +						       const void *lladdr)
>>>   {
>>>   	/* fe:80::XXXX:XXXX:XXXX:XXXX
>>>   	 *        \_________________/
>>> @@ -167,8 +167,9 @@ static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
>>>   	ipaddr->s6_addr[8] ^= 0x02;
>>>   }
>>>   -static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
>>> -						 const void *lladdr)
>>> +static inline void
>>> +lowpan_iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
>>> +				     const void *lladdr)
>>>   {
>>>   	const struct ieee802154_addr *addr = lladdr;
>>>   	u8 eui64[EUI64_ADDR_LEN] = { };
>>> @@ -176,7 +177,7 @@ static inline void iphc_uncompress_802154_lladdr(struct in6_addr *ipaddr,
>>>   	switch (addr->mode) {
>>>   	case IEEE802154_ADDR_LONG:
>>>   		ieee802154_le64_to_be64(eui64, &addr->extended_addr);
>>> -		iphc_uncompress_eui64_lladdr(ipaddr, eui64);
>>> +		lowpan_iphc_uncompress_eui64_lladdr(ipaddr, eui64);
>>>   		break;
>>>   	case IEEE802154_ADDR_SHORT:
>>>   		/* fe:80::ff:fe00:XXXX
>>> @@ -296,9 +297,10 @@ lowpan_iphc_ctx_get_by_mcast_addr(const struct net_device *dev,
>>>    *
>>>    * address_mode is the masked value for sam or dam value
>>>    */
>>> -static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
>>> -			   struct in6_addr *ipaddr, u8 address_mode,
>>> -			   const void *lladdr)
>>> +static int lowpan_iphc_uncompress_addr(struct sk_buff *skb,
>>> +				       const struct net_device *dev,
>>> +				       struct in6_addr *ipaddr,
>>> +				       u8 address_mode, const void *lladdr)
>>>   {
>>>   	bool fail;
>>>   @@ -329,10 +331,10 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
>>>   		fail = false;
>>>   		switch (lowpan_dev(dev)->lltype) {
>>>   		case LOWPAN_LLTYPE_IEEE802154:
>>> -			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>>> +			lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>>>   			break;
>>>   		default:
>>> -			iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>>> +			lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>>>   			break;
>>>   		}
>>>   		break;
>>> @@ -355,11 +357,11 @@ static int uncompress_addr(struct sk_buff *skb, const struct net_device *dev,
>>>   /* Uncompress address function for source context
>>>    * based address(non-multicast).
>>>    */
>>> -static int uncompress_ctx_addr(struct sk_buff *skb,
>>> -			       const struct net_device *dev,
>>> -			       const struct lowpan_iphc_ctx *ctx,
>>> -			       struct in6_addr *ipaddr, u8 address_mode,
>>> -			       const void *lladdr)
>>> +static int lowpan_iphc_uncompress_ctx_addr(struct sk_buff *skb,
>>> +					   const struct net_device *dev,
>>> +					   const struct lowpan_iphc_ctx *ctx,
>>> +					   struct in6_addr *ipaddr,
>>> +					   u8 address_mode, const void *lladdr)
>>>   {
>>>   	bool fail;
>>>   @@ -390,10 +392,10 @@ static int uncompress_ctx_addr(struct sk_buff *skb,
>>>   		fail = false;
>>>   		switch (lowpan_dev(dev)->lltype) {
>>>   		case LOWPAN_LLTYPE_IEEE802154:
>>> -			iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>>> +			lowpan_iphc_uncompress_802154_lladdr(ipaddr, lladdr);
>>>   			break;
>>>   		default:
>>> -			iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>>> +			lowpan_iphc_uncompress_eui64_lladdr(ipaddr, lladdr);
>>>   			break;
>>>   		}
>>>   		ipv6_addr_prefix_copy(ipaddr, &ctx->pfx, ctx->plen);
>>> @@ -660,14 +662,16 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
>>>   		}
>>>     		pr_debug("SAC bit is set. Handle context based source address.\n");
>>> -		err = uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
>>> -					  iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
>>> +		err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.saddr,
>>> +						      iphc1 & LOWPAN_IPHC_SAM_MASK,
>>> +						      saddr);
>>>   		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
>>>   	} else {
>>>   		/* Source address uncompression */
>>>   		pr_debug("source address stateless compression\n");
>>> -		err = uncompress_addr(skb, dev, &hdr.saddr,
>>> -				      iphc1 & LOWPAN_IPHC_SAM_MASK, saddr);
>>> +		err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.saddr,
>>> +						  iphc1 & LOWPAN_IPHC_SAM_MASK,
>>> +						  saddr);
>>>   	}
>>>     	/* Check on error of previous branch */
>>> @@ -705,13 +709,15 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
>>>     		/* Destination address context based uncompression */
>>>   		pr_debug("DAC bit is set. Handle context based destination address.\n");
>>> -		err = uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
>>> -					  iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
>>> +		err = lowpan_iphc_uncompress_ctx_addr(skb, dev, ci, &hdr.daddr,
>>> +						      iphc1 & LOWPAN_IPHC_DAM_MASK,
>>> +						      daddr);
>>>   		spin_unlock_bh(&lowpan_dev(dev)->ctx.lock);
>>>   		break;
>>>   	default:
>>> -		err = uncompress_addr(skb, dev, &hdr.daddr,
>>> -				      iphc1 & LOWPAN_IPHC_DAM_MASK, daddr);
>>> +		err = lowpan_iphc_uncompress_addr(skb, dev, &hdr.daddr,
>>> +						  iphc1 & LOWPAN_IPHC_DAM_MASK,
>>> +						  daddr);
>>>   		pr_debug("dest: stateless compression mode %d dest %pI6c\n",
>>>   			 iphc1 & LOWPAN_IPHC_DAM_MASK, &hdr.daddr);
>>>   		break;
>> Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
> if these are good to be merged, then I need a patch series without the RFC designation.

The beginning of the patchset was ready but the ndisc changes might need 
another RFC round.
Alex did split out the patches which are ready to be merged and sent 
them as a separate patchset now to make it easier for you to pick them up.
See "6lowpan: prepare for 6lowpan ndisc implementation" from today.

I just finished up reviewed the ones I did not have so far and the whole 
series is good to go from my point of view.

The rest will follow later.

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2016-04-11 17:00 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-22 13:14 [RFC bluetooth-next 00/19] 6lowpan: l2 neighbour data and short address Alexander Aring
2016-03-22 13:14 ` [RFC bluetooth-next 01/19] ieee802154: cleanups for ieee802154.h Alexander Aring
2016-03-23  9:59   ` Stefan Schmidt
2016-03-22 13:14 ` [RFC bluetooth-next 02/19] ieee802154: add short address helpers Alexander Aring
2016-03-23  9:59   ` Stefan Schmidt
2016-03-22 13:14 ` [RFC bluetooth-next 03/19] nl802154: avoid address change while running lowpan Alexander Aring
2016-03-23  9:59   ` Stefan Schmidt
2016-03-22 13:15 ` [RFC bluetooth-next 04/19] ieee802154: 6lowpan: fix short addr hash Alexander Aring
2016-03-23  9:58   ` Stefan Schmidt
2016-03-22 13:15 ` [RFC bluetooth-next 05/19] 6lowpan: change naming for lowpan private data Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 06/19] 6lowpan: move lowpan_802154_dev to 6lowpan Alexander Aring
2016-03-23 10:08   ` Stefan Schmidt
2016-03-22 13:15 ` [RFC bluetooth-next 07/19] 6lowpan: iphc: rename add lowpan prefix Alexander Aring
2016-03-23 10:09   ` Stefan Schmidt
2016-04-08 17:36     ` Marcel Holtmann
2016-04-11 17:00       ` Stefan Schmidt
2016-03-22 13:15 ` [RFC bluetooth-next 08/19] 6lowpan: iphc: remove unnecessary zero data Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 09/19] 6lowpan: move eui64 uncompress function Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 10/19] 6lowpan: add lowpan_is_ll function Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 11/19] 6lowpan: move mac802154 header Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 12/19] 6lowpan: add private neighbour data Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 13/19] addrconf: add 802.15.4 short addr slaac Alexander Aring
2016-03-23 10:50   ` Hannes Frederic Sowa
2016-04-05  8:20     ` Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 14/19] ndisc: add addr_len parameter to ndisc_opt_addr_space Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 15/19] ndisc: add addr_len parameter to ndisc_opt_addr_data Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 16/19] ndisc: add addr_len parameter to ndisc_fill_addr_option Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 17/19] ndisc: add short address to ndisc opts parsing Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 18/19] ndisc: add support for short address option Alexander Aring
2016-03-22 13:15 ` [RFC bluetooth-next 19/19] 6lowpan: add support for 802.15.4 short addr handling Alexander Aring

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.