Skip to contentSkip to conversation

6lowpan: debugfs and stateful compression support

RFC Superseded Alexander Aring 2 participants 8 messages Nov 11, 2015 – Nov 14, 2015

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

cover 6lowpan: debugfs and stateful compression support

Hi,

This patch based on the work of Lukasz Duda. It doesn't contain any interface lookup methods since we have a generic private dataroom per 6lowpan interface.

Also I dropped the list implementation and do a simple array one. It also contains support for multicast stateful compression.

To access the context we supporting a complete callback structure for operations, the include/net/6lowpan.h header contains static inline functions to call these operations. With such behaviour we don't get any module dependencies if we need upcomming runtime decisions inside the IPv6 stack. The alternative would be to do everything inside static inline functions, but there are few different to handling unicast and multicast context id's, so it's maybe better to do this as "ops callback structure".

Few things which I am not sure about if it's correct:
- I implement the dci multicast context table and dci unicast as different table. I don't know if when I have a context id "6" which is multicast then, I don't can have a unicast context id which is "6". I think they are different and we can indicate which table we need to use by the IPHC M bit (receiving side) or the multicast address scope (transmit side).
- Unicast context prefix length can be shorter than 64 bits. Yes this can be, but if somebody wants to do that he usually means "expand the bits until 64 with zeros". I forbid to add prefix below 64 bits for now.
Each stateful compression has cases for the IID bits (last 8 byte, use it as inline data/do compression, etc.). When I have a prefix 2000:: with prefix length 16, then I we hit the case of "Any remaining bits are zero." of stateful compression, this means it can be converted by "2000::" prefix length 64, then we don't need to care about that when doing a lookup of context.
- I tried to get wireshark know about the available context without success. What I successful get working is tell prefix length exact 64 bits long. I don't know if wireshark do a correct context handling here, but it's also possible to have a prefix length above 64 (In my opinion). E.g. unicast stateful compression in case of SAM/DAM 01:
"Bits covered by context information are always used. Any IID bits not
covered by context information are taken directly from the corresponding bits carried in-line.

This patch series do following handling for this case:
1. generate ipv6 address with inline IID data.
2. copy the prefix bits from context to the address, which _maybe_ overwrite the IID (last eight bytes) data which was carried as inline data.

This means, if my context is a full address 2001::1/128, then it will be the case of SAM/DAM = 11, which means the address is fully elided. (Don't care about the IID bits, which will be reconstructed from encapsulating header.

All others SAM/DAM cases has a similar handling.

Nevertheless I don't know how I can tell that wireshark, I can tell prefix which are 64 bit's long only.

Any comments are welcome.

- Alex

Alexander Aring (4):
6lowpan: add debugfs support
6lowpan: iphc: add check for reserved values 6lowpan: iphc: remove handling when dam is zero 6lowpan: iphc: add support for stateful compression

 include/net/6lowpan.h         |  64 ++++-
 net/6lowpan/6lowpan_i.h       |  28 +++
 net/6lowpan/Kconfig           |   7 +
 net/6lowpan/Makefile          |   1 +
 net/6lowpan/core.c            |  36 ++-
 net/6lowpan/debugfs.c         | 158 ++++++++++++
 net/6lowpan/iphc.c            | 542 +++++++++++++++++++++++++++++++++++++-----
 net/bluetooth/6lowpan.c       |  17 +-
 net/ieee802154/6lowpan/core.c |  14 +-
 9 files changed, 793 insertions(+), 74 deletions(-)
 create mode 100644 net/6lowpan/6lowpan_i.h
 create mode 100644 net/6lowpan/debugfs.c
Signature · 1 line
2.6.1
author maintainer
#1 lore raw

RFC 1/4 6lowpan: add debugfs support

This patch will introduce a 6lowpan entry into the debugfs if enabled. Inside this 6lowpan directory we create a subdirectories of all 6lowpan interfaces to offer a per interface debugfs support.

---
 include/net/6lowpan.h         |  2 +-
 net/6lowpan/6lowpan_i.h       | 25 +++++++++++++++++++++
 net/6lowpan/Kconfig           |  7 ++++++
 net/6lowpan/Makefile          |  1 +
 net/6lowpan/core.c            | 19 +++++++++++++++-
 net/6lowpan/debugfs.c         | 51 +++++++++++++++++++++++++++++++++++++++++++
 net/bluetooth/6lowpan.c       | 17 +++++++++------
 net/ieee802154/6lowpan/core.c | 14 +++++++-----
 8 files changed, 122 insertions(+), 14 deletions(-)
 create mode 100644 net/6lowpan/6lowpan_i.h
 create mode 100644 net/6lowpan/debugfs.c
include/net/6lowpan.h +1 -1
index cf3bc56..edce9a1 100644
@@ -185,7 +185,7 @@ static inline void lowpan_push_hc_data(u8 **hc_ptr, const void *data,
 	*hc_ptr += len;
 }
 
-void lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype);
+int lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype);
 
 /**
  * lowpan_header_decompress - replace 6LoWPAN header with IPv6 header
net/6lowpan/6lowpan_i.h new file +25 -0
new file mode 100644
index 0000000..102c2a4
@@ -0,0 +1,25 @@
+#ifndef __6LOWPAN_I_H
+#define __6LOWPAN_I_H
+
+#include <linux/netdevice.h>
+
+#ifdef CONFIG_6LOWPAN_DEBUGFS
+int lowpan_dev_debugfs_init(struct net_device *dev);
+
+int __init lowpan_debugfs_init(void);
+void lowpan_debugfs_exit(void);
+#else
+static inline int lowpan_dev_debugfs_init(struct net_device *dev)
+{
+	return 0;
+}
+
+static inline int __init lowpan_debugfs_init(void)
+{
+	return 0;
+}
+
+static inline void lowpan_debugfs_exit(void) { }
+#endif /* CONFIG_6LOWPAN_DEBUGFS */
+
+#endif /* __6LOWPAN_I_H */
net/6lowpan/Kconfig +7 -0
index 7fa0f38..01c901c 100644
@@ -5,6 +5,13 @@ menuconfig 6LOWPAN
 	  This enables IPv6 over Low power Wireless Personal Area Network -
 	  "6LoWPAN" which is supported by IEEE 802.15.4 or Bluetooth stacks.
 
+config 6LOWPAN_DEBUGFS
+	bool "6LoWPAN debugfs support"
+	depends on 6LOWPAN
+	---help---
+	  This enables 6LoWPAN debugfs support. For example to manipulate
+	  IPHC context information at runtime.
+
 menuconfig 6LOWPAN_NHC
 	tristate "Next Header Compression Support"
 	depends on 6LOWPAN
net/6lowpan/Makefile +1 -0
index c6ffc55..54cad8d 100644
@@ -1,6 +1,7 @@
 obj-$(CONFIG_6LOWPAN) += 6lowpan.o
 
 6lowpan-y := core.o iphc.o nhc.o
+6lowpan-$(CONFIG_6LOWPAN_DEBUGFS) += debugfs.o
 
 #rfc6282 nhcs
 obj-$(CONFIG_6LOWPAN_NHC_DEST) += nhc_dest.o
net/6lowpan/core.c +18 -1
index 83b19e0..7f46c7e 100644
@@ -15,7 +15,9 @@
 
 #include <net/6lowpan.h>
 
-void lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype)
+#include "6lowpan_i.h"
+
+int lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype)
 {
 	dev->addr_len = EUI64_ADDR_LEN;
 	dev->type = ARPHRD_6LOWPAN;
@@ -23,11 +25,19 @@ void lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype)
 	dev->priv_flags |= IFF_NO_QUEUE;
 
 	lowpan_priv(dev)->lltype = lltype;
+
+	return lowpan_dev_debugfs_init(dev);
 }
 EXPORT_SYMBOL(lowpan_netdev_setup);
 
 static int __init lowpan_module_init(void)
 {
+	int ret;
+
+	ret = lowpan_debugfs_init();
+	if (ret < 0)
+		return ret;
+
 	request_module_nowait("ipv6");
 
 	request_module_nowait("nhc_dest");
@@ -40,6 +50,13 @@ static int __init lowpan_module_init(void)
 
 	return 0;
 }
+
+static void __exit lowpan_module_exit(void)
+{
+	lowpan_debugfs_exit();
+}
+
 module_init(lowpan_module_init);
+module_exit(lowpan_module_exit);
 
 MODULE_LICENSE("GPL");
net/6lowpan/debugfs.c new file +51 -0

51 lines not on this page · raw message

net/bluetooth/6lowpan.c +10 -7
index 9e9cca3..57aa5ff 100644
@@ -825,16 +825,14 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev)
 	list_add_rcu(&(*dev)->list, &bt_6lowpan_devices);
 	spin_unlock(&devices_lock);
 
-	lowpan_netdev_setup(netdev, LOWPAN_LLTYPE_BTLE);
+	err = lowpan_netdev_setup(netdev, LOWPAN_LLTYPE_BTLE);
+	if (err < 0)
+		goto free_netdev;
 
 	err = register_netdev(netdev);
 	if (err < 0) {
 		BT_INFO("register_netdev failed %d", err);
-		spin_lock(&devices_lock);
-		list_del_rcu(&(*dev)->list);
-		spin_unlock(&devices_lock);
-		free_netdev(netdev);
-		goto out;
+		goto free_netdev;
 	}
 
 	BT_DBG("ifindex %d peer bdaddr %pMR type %d my addr %pMR type %d",
@@ -844,7 +842,12 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev)
 
 	return 0;
 
-out:
+free_netdev:
+	spin_lock(&devices_lock);
+	list_del_rcu(&(*dev)->list);
+	spin_unlock(&devices_lock);
+	free_netdev(netdev);
+
 	return err;
 }
 
net/ieee802154/6lowpan/core.c +9 -5
index 20c49c7..67ed7dc 100644
@@ -161,16 +161,20 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
 				wdev->needed_headroom;
 	ldev->needed_tailroom = wdev->needed_tailroom;
 
-	lowpan_netdev_setup(ldev, LOWPAN_LLTYPE_IEEE802154);
+	ret = lowpan_netdev_setup(ldev, LOWPAN_LLTYPE_IEEE802154);
+	if (ret < 0)
+		goto dev_put;
 
 	ret = register_netdevice(ldev);
-	if (ret < 0) {
-		dev_put(wdev);
-		return ret;
-	}
+	if (ret < 0)
+		goto dev_put;
 
 	wdev->ieee802154_ptr->lowpan_dev = ldev;
 	return 0;
+
+dev_put:
+	dev_put(wdev);
+	return ret;
 }
 
 static void lowpan_dellink(struct net_device *ldev, struct list_head *head)
Signature · 1 line
2.6.1
author maintainer
#3 lore raw

RFC 2/4 6lowpan: iphc: add check for reserved values

In reply to Alexander Aring

This patch adds a check on reserved values for IPHC header. We should at first check on these fields instead of doing parsing before. Afterwards we can be sure there are no reserved values anymore. The reserved bits doesn't contain reserved values for NHC headers. This need to be handled inside the next layer.

---
 net/6lowpan/iphc.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
net/6lowpan/iphc.c +16 -1
index 346b5c1..13f5424 100644
@@ -455,6 +455,20 @@ static const u8 lowpan_ttl_values[] = {
 	[LOWPAN_IPHC_HLIM_11] = 255,
 };
 
+static inline bool lowpan_iphc_is_reserved(u8 iphc1)
+{
+	switch (iphc1 & (LOWPAN_IPHC_DAC | LOWPAN_IPHC_M |
+			 LOWPAN_IPHC_DAM_MASK)) {
+	case LOWPAN_IPHC_DAC | LOWPAN_IPHC_DAM_00:
+	case LOWPAN_IPHC_DAC | LOWPAN_IPHC_M | LOWPAN_IPHC_DAM_01:
+	case LOWPAN_IPHC_DAC | LOWPAN_IPHC_M | LOWPAN_IPHC_DAM_10:
+	case LOWPAN_IPHC_DAC | LOWPAN_IPHC_M | LOWPAN_IPHC_DAM_11:
+		return true;
+	default:
+		return false;
+	}
+}
+
 int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 			     const void *daddr, const void *saddr)
 {
@@ -466,7 +480,8 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 		       skb->data, skb->len);
 
 	if (lowpan_fetch_skb(skb, &iphc0, sizeof(iphc0)) ||
-	    lowpan_fetch_skb(skb, &iphc1, sizeof(iphc1)))
+	    lowpan_fetch_skb(skb, &iphc1, sizeof(iphc1)) ||
+	    lowpan_iphc_is_reserved(iphc1))
 		return -EINVAL;
 
 	/* another if the CID flag is set */
Signature · 1 line
2.6.1
author maintainer
#4 lore raw

RFC 3/4 6lowpan: iphc: remove handling when dam is zero

In reply to Alexander Aring

This patch removes handling of LOWPAN_IPHC_DAM_00 inside the lowpan_compress_addr_64 function. The case of LOWPAN_IPHC_DAM_00 can never occur. there exists a if branch which use LOWPAN_IPHC_DAM_11 and LOWPAN_IPHC_DAM_10 and inside the else branch LOWPAN_IPHC_DAM_01. So LOWPAN_IPHC_DAM_00 can never occur.

---
 net/6lowpan/iphc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/6lowpan/iphc.c +1 -2
index 13f5424..f7f175c 100644
@@ -594,7 +594,6 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 EXPORT_SYMBOL_GPL(lowpan_header_decompress);
 
 static const u8 lowpan_iphc_dam_to_sam_value[] = {
-	[LOWPAN_IPHC_DAM_00] = LOWPAN_IPHC_SAM_00,
 	[LOWPAN_IPHC_DAM_01] = LOWPAN_IPHC_SAM_01,
 	[LOWPAN_IPHC_DAM_10] = LOWPAN_IPHC_SAM_10,
 	[LOWPAN_IPHC_DAM_11] = LOWPAN_IPHC_SAM_11,
@@ -603,7 +602,7 @@ static const u8 lowpan_iphc_dam_to_sam_value[] = {
 static u8 lowpan_compress_addr_64(u8 **hc_ptr, const struct in6_addr *ipaddr,
 				  const unsigned char *lladdr, bool sam)
 {
-	u8 dam = LOWPAN_IPHC_DAM_00;
+	u8 dam;
 
 	if (is_addr_mac_addr_based(ipaddr, lladdr)) {
 		dam = LOWPAN_IPHC_DAM_11; /* 0-bits */
Signature · 1 line
2.6.1
author maintainer
#5 lore raw

RFC 4/4 6lowpan: iphc: add support for stateful compression

In reply to Alexander Aring

This patch introduce support for IPHC stateful address compression. It will offer three debugfs per interface entries, which are:

- dci_table: destination context indentifier table
- sci_table: source context indentifier table
- mcast_sci_table: multicast context identifier table

Example to setup a context id:

A "cat /sys/kernel/debug/6lowpan/lowpan0/dci_table" will display all contexts which are available. Example:

ID ipv6-address/prefix-length state

0  0000:0000:0000:0000:0000:0000:0000:0000/000 0
1  0000:0000:0000:0000:0000:0000:0000:0000/000 0
2  0000:0000:0000:0000:0000:0000:0000:0000/000 0
3  0000:0000:0000:0000:0000:0000:0000:0000/000 0
4  0000:0000:0000:0000:0000:0000:0000:0000/000 0
5  0000:0000:0000:0000:0000:0000:0000:0000/000 0
6  0000:0000:0000:0000:0000:0000:0000:0000/000 0
7  0000:0000:0000:0000:0000:0000:0000:0000/000 0
8  0000:0000:0000:0000:0000:0000:0000:0000/000 0
9  0000:0000:0000:0000:0000:0000:0000:0000/000 0

10 0000:0000:0000:0000:0000:0000:0000:0000/000 0
11 0000:0000:0000:0000:0000:0000:0000:0000/000 0
12 0000:0000:0000:0000:0000:0000:0000:0000/000 0
13 0000:0000:0000:0000:0000:0000:0000:0000/000 0
14 0000:0000:0000:0000:0000:0000:0000:0000/000 0
15 0000:0000:0000:0000:0000:0000:0000:0000/000 0

For setting a context e.g. context id 0, context 2001::, prefix-length 64.

Hint: Simple copy one line and then maniuplate it.

echo "0 2001:0000:0000:0000:0000:0000:0000:0000/64 1" > /sys/kernel/debug/6lowpan/lowpan0/dci_table

The state will display currently if the context is disabled(0) or enabled(1).

On transmit side:

The IPHC code will automatically search for a context which would be match for the address. Then it will be use the context which the best compression, means the longest prefix which match will be used.

Example:

2001::/126 vs 2001::/127 - the 2001::/127 can be full compressed if the last bit of the address which has the prefix 2001::/127 is the same like the IID from the Encapsulating Header. A context ID can also be a 2001::1/128, which is then a full ipv6 address.

On Receive side:

If there is a context defined (when CID not available then it's the default context 0) then it will be used, if the header doesn't set SAC or DAC bit thens, it will be dropped.

---
 include/net/6lowpan.h   |  62 ++++++
 net/6lowpan/6lowpan_i.h |   3 +
 net/6lowpan/core.c      |  17 ++
 net/6lowpan/debugfs.c   | 109 +++++++++-
 net/6lowpan/iphc.c      | 522 ++++++++++++++++++++++++++++++++++++++++++------
 5 files changed, 655 insertions(+), 58 deletions(-)
include/net/6lowpan.h +62 -0
index edce9a1..18898db 100644
@@ -73,6 +73,8 @@
 #define LOWPAN_IPHC_MAX_HC_BUF_LEN	(sizeof(struct ipv6hdr) +	\
 					 LOWPAN_IPHC_MAX_HEADER_LEN +	\
 					 LOWPAN_NHC_MAX_HDR_LEN)
+/* SCI/DCI is 4 bit width, so we have maximum 16 entries */
+#define LOWPAN_IPHC_CI_TABLE_SIZE	(1 << 4)
 
 #define LOWPAN_DISPATCH_IPV6		0x41 /* 01000001 = 65 */
 #define LOWPAN_DISPATCH_IPHC		0x60 /* 011xxxxx = ... */
@@ -96,8 +98,44 @@ enum lowpan_lltypes {
 	LOWPAN_LLTYPE_IEEE802154,
 };
 
+enum lowpan_iphc_ctx_states {
+	LOWPAN_IPHC_CTX_STATE_DISABLED,
+	LOWPAN_IPHC_CTX_STATE_ENABLED,
+
+	__LOWPAN_IPHC_CTX_STATE_INVALID,
+	LOWPAN_IPHC_CTX_STATE_MAX = __LOWPAN_IPHC_CTX_STATE_INVALID - 1,
+};
+
+struct lowpan_iphc_ctx {
+	enum lowpan_iphc_ctx_states state;
+	u8 id;
+	struct in6_addr addr;
+	u8 prefix_len;
+};
+
+struct lowpan_iphc_ctx_ops {
+	bool (*valid_prefix)(const struct lowpan_iphc_ctx *ctx);
+	int (*update)(struct lowpan_iphc_ctx *table,
+		      const struct lowpan_iphc_ctx *ctx);
+	struct lowpan_iphc_ctx *(*get_by_id)(const struct net_device *dev,
+					     struct lowpan_iphc_ctx *table,
+					     u8 id);
+	struct lowpan_iphc_ctx *(*get_by_addr)(const struct net_device *dev,
+					       struct lowpan_iphc_ctx *table,
+					       const struct in6_addr *addr);
+};
+
+struct lowpan_iphc_ctx_table {
+	spinlock_t lock;
+	const struct lowpan_iphc_ctx_ops *ops;
+	struct lowpan_iphc_ctx table[LOWPAN_IPHC_CI_TABLE_SIZE];
+};
+
 struct lowpan_priv {
 	enum lowpan_lltypes lltype;
+	struct lowpan_iphc_ctx_table iphc_dci;
+	struct lowpan_iphc_ctx_table iphc_sci;
+	struct lowpan_iphc_ctx_table iphc_mcast_dci;
 
 	/* must be last */
 	u8 priv[0] __aligned(sizeof(void *));
@@ -122,6 +160,30 @@ struct lowpan_802154_cb *lowpan_802154_cb(const struct sk_buff *skb)
 	return (struct lowpan_802154_cb *)skb->cb;
 }
 
+static inline int lowpan_ctx_update(struct lowpan_iphc_ctx_table *t,
+				    const struct lowpan_iphc_ctx *ctx)
+{
+	if (!t->ops->valid_prefix(ctx))
+		return -EINVAL;
+
+	return t->ops->update(t->table, ctx);
+}
+
+static inline struct lowpan_iphc_ctx *
+lowpan_ctx_by_id(const struct net_device *dev, struct lowpan_iphc_ctx_table *t,
+		 u8 id)
+{
+	return t->ops->get_by_id(dev, t->table, id);
+}
+
+static inline struct lowpan_iphc_ctx *
+lowpan_ctx_by_addr(const struct net_device *dev,
+		   struct lowpan_iphc_ctx_table *t,
+		   const struct in6_addr *addr)
+{
+	return t->ops->get_by_addr(dev, t->table, addr);
+}
+
 #ifdef DEBUG
 /* print data in line */
 static inline void raw_dump_inline(const char *caller, char *msg,
net/6lowpan/6lowpan_i.h +3 -0
index 102c2a4..531444f 100644
@@ -3,6 +3,9 @@
 
 #include <linux/netdevice.h>
 
+extern const struct lowpan_iphc_ctx_ops iphc_ctx_unicast_ops;
+extern const struct lowpan_iphc_ctx_ops iphc_ctx_mcast_ops;
+
 #ifdef CONFIG_6LOWPAN_DEBUGFS
 int lowpan_dev_debugfs_init(struct net_device *dev);
 
net/6lowpan/core.c +17 -0
index 7f46c7e..9e6a0a9 100644
@@ -19,6 +19,8 @@
 
 int lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype)
 {
+	int i;
+
 	dev->addr_len = EUI64_ADDR_LEN;
 	dev->type = ARPHRD_6LOWPAN;
 	dev->mtu = IPV6_MIN_MTU;
@@ -26,6 +28,21 @@ int lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype)
 
 	lowpan_priv(dev)->lltype = lltype;
 
+	spin_lock_init(&lowpan_priv(dev)->iphc_dci.lock);
+	lowpan_priv(dev)->iphc_dci.ops = &iphc_ctx_unicast_ops;
+
+	spin_lock_init(&lowpan_priv(dev)->iphc_sci.lock);
+	lowpan_priv(dev)->iphc_sci.ops = &iphc_ctx_unicast_ops;
+
+	spin_lock_init(&lowpan_priv(dev)->iphc_mcast_dci.lock);
+	lowpan_priv(dev)->iphc_mcast_dci.ops = &iphc_ctx_mcast_ops;
+
+	for (i = 0; i < LOWPAN_IPHC_CI_TABLE_SIZE; i++) {
+		lowpan_priv(dev)->iphc_dci.table[i].id = i;
+		lowpan_priv(dev)->iphc_sci.table[i].id = i;
+		lowpan_priv(dev)->iphc_mcast_dci.table[i].id = i;
+	}
+
 	return lowpan_dev_debugfs_init(dev);
 }
 EXPORT_SYMBOL(lowpan_netdev_setup);
net/6lowpan/debugfs.c +108 -1

123 lines not on this page · raw message

net/6lowpan/iphc.c +465 -57

647 lines not on this page · raw message

Signature · 1 line
2.6.1
author maintainer
#2 lore raw

Re: [RFC bluetooth-next 1/4] 6lowpan: add debugfs support

In reply to Alexander Aring

On Wed, Nov 11, 2015 at 06:14:36PM +0100, Alexander Aring wrote:
...

net/6lowpan/Kconfig menuconfig 6LOWPAN · line 10

Quoted 3 lines
net/6lowpan/Kconfig +3 -0
+config 6LOWPAN_DEBUGFS
+	bool "6LoWPAN debugfs support"
+	depends on 6LOWPAN

missing:

depends on DEBUG_FS

Quoted 16 lines
net/6lowpan/Kconfig +4 -0
+	---help---
+	  This enables 6LoWPAN debugfs support. For example to manipulate
+	  IPHC context information at runtime.
+
 menuconfig 6LOWPAN_NHC
 	tristate "Next Header Compression Support"
 	depends on 6LOWPAN
net/6lowpan/Makefile +1 -0
index c6ffc55..54cad8d 100644
@@ -1,6 +1,7 @@
 obj-$(CONFIG_6LOWPAN) += 6lowpan.o
 
 6lowpan-y := core.o iphc.o nhc.o
+6lowpan-$(CONFIG_6LOWPAN_DEBUGFS) += debugfs.o

...

Quoted 4 lines
net/6lowpan/Makefile +4 -0
+
+int lowpan_dev_debugfs_init(struct net_device *dev)
+{
+	static struct dentry *iface;

net/6lowpan/Makefile

Quoted 10 lines
net/6lowpan/Makefile +10 -0
+
+	/* creating the root */
+	iface = debugfs_create_dir(dev->name, lowpan_debugfs);
+	if (!iface)
+		goto fail;
+
+	return 0;
+
+fail:
+	lowpan_debugfs_exit();

This is broken, this will delete everything also the "$DEBUGFS_MOUNTPOINT/6lowpan" directory. What we need is a debugfs_remove_recursive(iface); call here, which deletes everything which is registered at iface dentry.

Also we need to call this when a lowpan interface will be unregistered, otherwise we have still the debugfs entries when an interface doesn't exist anymore.

I will fix this issues for the next try.

- Alex

#6 lore raw

Re: [RFC bluetooth-next 4/4] 6lowpan: iphc: add support for stateful compression

In reply to Alexander Aring

These patches are very nice to have, I will attempt to test them out. I am waiting for a JTAG programmer to unwedge my openmote, and then I'll put RIOT on that, but in the meantime I'll be testing against Contiki on Econotag.

One thing that I wanted to add was a counter per type of HC header decoded. I seemed to recall that the was some RCU-ish way to do lock-less 64-bit counters, but I haven't tracked down the right reference.

--

]               Never tell me the odds!                 | ipv6 mesh networks [
]   Michael Richardson, Sandelman Software Works        | network architect  [
]     [email protected]  http://www.sandelman.ca/        |   ruby on rails    [
author maintainer
#7 lore raw

Re: [RFC bluetooth-next 4/4] 6lowpan: iphc: add support for stateful compression

Hi Michael,

Quoted 6 lines · Michael Richardson

These patches are very nice to have, I will attempt to test them out. I am waiting for a JTAG programmer to unwedge my openmote, and then I'll put RIOT on that, but in the meantime I'll be testing against Contiki on Econotag.

ok, thanks.

Quoted 4 lines

One thing that I wanted to add was a counter per type of HC header decoded. I seemed to recall that the was some RCU-ish way to do lock-less 64-bit counters, but I haven't tracked down the right reference.

Do you want to have this per interface or overall? We could make both. For the lock-less part a per-cpu counter would be fit here, it will summarize then all counters per-cpu if they will be requested.

- Alex