6lowpan: introduce nhc framework
Alexander Aring
maintainerv2 cover 6lowpan: introduce nhc framework
This patch series introduce the next header compression framework. Currently we support udp compression/uncompression only. This framework allow to add new next header compression formats easily.
If somebody wants to add a new header compression format and some information are missing while calling compression and uncompression callbacks. Please feel free to make framework changes according these callbacks.
Note:
If building 6lowpan_udp as module please make sure it's loaded before running rfc6282 udp connection. If it's not loaded we send 6lowpan with raw udp header and next header compression bit isn't set. Nevertheless if you use rfc6282 connection and 6lowpan_udp isn't loaded following will be printed:
"ieee802154 wpan-phy0 wpan0: received nhc which is not supported. Dropping."
changes since v2:
- make udp nhc as module as suggested by Marcel Holtmann
- fix comment header in nhc_udp.c
I didn't make the lowpan_nhc declaration "const" because this will occur issues with rb_node, id and idmask array. Which will manipulated during runtime.
Alexander Aring (2):
6lowpan: add generic nhc layer interface
6lowpan: add udp compression via nhc layer
net/6lowpan/Kconfig | 7 ++ net/6lowpan/Makefile | 6 +- net/6lowpan/iphc.c | 176 ++++---------------------------------------------- net/6lowpan/nhc.c | 175 +++++++++++++++++++++++++++++++++++++++++++++++++ net/6lowpan/nhc.h | 130 +++++++++++++++++++++++++++++++++++++ net/6lowpan/nhc_udp.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 497 insertions(+), 166 deletions(-) create mode 100644 net/6lowpan/nhc.c create mode 100644 net/6lowpan/nhc.h create mode 100644 net/6lowpan/nhc_udp.c
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH v2 1/2 6lowpan: add generic nhc layer interface
This patch adds a generic next header compression layer interface. There exists various methods to do a header compression after 6LoWPAN header to save payload. This introduce a generic nhc header which allow a simple adding of a new header compression format instead of a static implementation inside the 6LoWPAN header compression and uncompression function.
--- net/6lowpan/Makefile | 2 +- net/6lowpan/nhc.c | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++ net/6lowpan/nhc.h | 130 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 net/6lowpan/nhc.c create mode 100644 net/6lowpan/nhc.h
net/6lowpan/Makefile +1 -1
@@ -1,3 +1,3 @@ obj-$(CONFIG_6LOWPAN) := 6lowpan.o -6lowpan-y := iphc.o +6lowpan-y := iphc.o nhc.o
net/6lowpan/nhc.c new file +175 -0
175 lines not on this page · raw message
net/6lowpan/nhc.h new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.1.3
Alexander Aring
maintainerRe: [PATCHv2 bluetooth-next 1/2] 6lowpan: add generic nhc layer interface
Quoted 144 lines · Alexander Aring
This patch adds a generic next header compression layer interface. There exists various methods to do a header compression after 6LoWPAN header to save payload. This introduce a generic nhc header which allow a simple adding of a new header compression format instead of a static implementation inside the 6LoWPAN header compression and uncompression function.
Signed-off-by Alexander Aring <[email protected]>Cc Jukka Rissanen <[email protected]>Cc Martin Townsend <[email protected]>--- net/6lowpan/Makefile | 2 +- net/6lowpan/nhc.c | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++ net/6lowpan/nhc.h | 130 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 net/6lowpan/nhc.c create mode 100644 net/6lowpan/nhc.hnet/6lowpan/Makefile +1
-1@@ -1,3 +1,3 @@ obj-$(CONFIG_6LOWPAN) := 6lowpan.o -6lowpan-y := iphc.o +6lowpan-y := iphc.o nhc.onet/6lowpan/nhc.c new file +111
-0@@ -0,0 +1,175 @@ +/* +* 6LoWPAN next header compression +* +* +* Authors: +* Alexander Aring <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#include <linux/netdevice.h> + +#include <net/ipv6.h> + +#include "nhc.h" + +static struct rb_root rb_root =RB_ROOT ; +static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX ]; + +static int lowpan_nhc_insert (struct lowpan_nhc *nhc) +{ +struct rb_node **new = &rb_root.rb_node, *parent =NULL ; + +/* Figure out where to put new node */ +while (*new) { + struct lowpan_nhc *this = container_of(*new, struct lowpan_nhc, + node); +int result, len_dif, len; + + len_dif = nhc->idlen - this->idlen; + +if (nhc->idlen < this->idlen) + len = nhc->idlen; +else + len = this->idlen; + + result =memcmp (nhc->id, this->id, len); +if (!result) + result = len_dif; + + parent = *new; +if (result <0 ) + new = &((*new)->rb_left); +else if (result >0 ) + new = &((*new)->rb_right); +else +return -EEXIST ; + } + +/* Add new node and rebalance tree. */ +rb_link_node (&nhc->node, parent, new); +rb_insert_color (&nhc->node, &rb_root); + +return 0 ; +} + +static void lowpan_nhc_remove (struct lowpan_nhc *nhc) +{ +rb_erase (&nhc->node, &rb_root); +} + +struct lowpan_nhc *lowpan_nhc_by_nhcid (const struct sk_buff *skb) +{ +struct rb_node *node = rb_root.rb_node; +const u8 *nhcid_skb_ptr = skb->data; + +while (node) { + struct lowpan_nhc *nhc = container_of(node, struct lowpan_nhc, + node); +u8 nhcid_skb_ptr_masked[LOWPAN_NHC_MAX_ID_LEN ]; +int result, i; + +if (nhcid_skb_ptr + nhc->idlen > skb->data + skb->len) +return NULL ; + +/* copy and mask afterwards the nhid value from skb */ +memcpy (nhcid_skb_ptr_masked, nhcid_skb_ptr, nhc->idlen); +for (i =0 ; i < nhc->idlen; i++) + nhcid_skb_ptr_masked[i] &= nhc->idmask[i]; + + result =memcmp (nhcid_skb_ptr_masked, nhc->id, nhc->idlen); +if (result <0 ) + node = node->rb_left; +else if (result >0 ) + node = node->rb_right; +else +return nhc; + } + +return NULL ; +} + +struct lowpan_nhc *lowpan_nhc_by_nexthdr (u8 nexthdr) +{ +return lowpan_nexthdr_nhcs[nexthdr]; +} + +int lowpan_nhc_do_compression (struct lowpan_nhc *nhc,struct sk_buff *skb, +u8 **hc_ptr,u8 *iphc0) +{ +int ret; + +if (!nhc) +return 0 ; + + ret = nhc->compress (skb, hc_ptr); +if (ret ==0 ) + *iphc0 |=LOWPAN_IPHC_NH_C ;
net/6lowpan/nhc.c line 121
Quoted 10 lines
net/6lowpan/nhc.c new file +10
-0+ +return ret; +} + +int lowpan_nhc_do_uncompression (struct sk_buff *skb,struct ipv6hdr *hdr) +{ +struct lowpan_nhc *nhc; +/* default dropping if nothing found */ +int ret =0 ; +
this should be ret = -ENOENT;
To avoid sending garbage to next higher layer. I changed this is here from -EINVAL to 0. Sorry some mistake is happend here, now it's real dropped afterwards.
Quoted 10 lines
net/6lowpan/nhc.c new file +10
-0+ nhc =lowpan_nhc_by_nhcid (skb); +if (nhc) { + ret = nhc->uncompress (skb,sizeof (*hdr) + nhc->nexthdrlen); +if (ret ==0 ) { + hdr->nexthdr = nhc->nexthdr; +skb_reset_transport_header (skb); +raw_dump_table (__func__,"raw transport header dump" , +skb_transport_header (skb), + nhc->nexthdrlen); + }else if (ret == -ENOTSUPP ) {
net/6lowpan/nhc.c line 141
Quoted 10 lines
net/6lowpan/nhc.c new file +10
-0+netdev_warn (skb->dev,"received %s which is not supported for uncompression.\n" , + nhc->name); + } + }else { +netdev_warn (skb->dev,"received nhc which is not supported. Dropping.\n" ); + } + +return ret; +} +
- Alex
Alexander Aring
maintainerPATCH v2 2/2 6lowpan: add udp compression via nhc layer
In reply to Alexander AringThis patch move UDP header compression and uncompression into the generic 6LoWPAN nhc header compression layer. Moreover this patch activates the nhc layer compression in iphc compression and uncompression functions.
--- net/6lowpan/Kconfig | 7 ++ net/6lowpan/Makefile | 4 +- net/6lowpan/iphc.c | 176 ++++---------------------------------------------- net/6lowpan/nhc_udp.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 191 insertions(+), 165 deletions(-) create mode 100644 net/6lowpan/nhc_udp.c
net/6lowpan/Kconfig +7 -0
@@ -4,3 +4,10 @@ config 6LOWPAN ---help--- This enables IPv6 over Low power Wireless Personal Area Network - "6LoWPAN" which is supported by IEEE 802.15.4 or Bluetooth stacks. + +config 6LOWPAN_UDP + tristate "6LoWPAN UDP compression" + depends on 6LOWPAN + default y + ---help--- + This enables support for 6LoWPAN UDP compression according RFC6282.
net/6lowpan/Makefile +3 -1
@@ -1,3 +1,5 @@ -obj-$(CONFIG_6LOWPAN) := 6lowpan.o +obj-$(CONFIG_6LOWPAN) += 6lowpan.o +obj-$(CONFIG_6LOWPAN_UDP) += 6lowpan_udp.o 6lowpan-y := iphc.o nhc.o +6lowpan_udp-y := nhc_udp.o
net/6lowpan/iphc.c +12 -164
221 lines not on this page · raw message
net/6lowpan/nhc_udp.c new file +169 -0
169 lines not on this page · raw message
Signature · 1 line
2.1.3
Hi Alex,
Quoted 17 lines · Alexander Aring
This patch series introduce the next header compression framework. Currently we support udp compression/uncompression only. This framework allow to add new next header compression formats easily.
If somebody wants to add a new header compression format and some information are missing while calling compression and uncompression callbacks. Please feel free to make framework changes according these callbacks.
Note:
If building 6lowpan_udp as module please make sure it's loaded before running rfc6282 udp connection. If it's not loaded we send 6lowpan with raw udp header and next header compression bit isn't set. Nevertheless if you use rfc6282 connection and 6lowpan_udp isn't loaded following will be printed:
"ieee802154 wpan-phy0 wpan0: received nhc which is not supported. Dropping."
Quoted 8 lines
changes since v2:
- make udp nhc as module as suggested by Marcel Holtmann
- fix comment header innhc_udp.cI didn't make the
lowpan_nhcdeclaration "const" because this will occur issues withrb_node, id and idmask array. Which will manipulated during runtime.
Tested it between two BT 6lowpan connections. If both ends load the 6lowpan_udp module, then no issues. If only the other end has loaded the module, the other end (receiving end) crashed.
[ 132.417733] (NULL net_device): received nhc which is not supported. Dropping. [ 132.722432] skbuff: skb_under_panic: text:d19cb60c len:55 put:40 head:cd923000 data:cd922fec tail:0xcd923023 end:0xcd923740 dev:<NULL> [ 133.536256] ------------[ cut here ]------------ [ 133.537233] kernel BUG at 3.16+gitAUTOINC +f6af675ef5-r215/linux/net/core/skbuff.c:100! [ 133.537233] invalid opcode: 0000 [#1] PREEMPT SMP [ 133.537233] Modules linked in: bluetooth_6lowpan 6lowpan nfc ecb btusb bluetooth rfkill snd_intel8x0 ohci_pci snd_ac97_codec ac97_bus parport_pc parport uvesafb [ 133.537233] CPU: 0 PID: 327 Comm: kworker/u3:0 Not tainted 3.17.0-bt6lowpan #1 [ 133.537233] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 133.537233] Workqueue: hci0 hci_rx_work [bluetooth] [ 133.537233] task: c0170000 ti: cc7d0000 task.ti: cc7d0000 [ 133.537233] EIP: 0060:[<c1779838>] EFLAGS: 00010292 CPU: 0 [ 133.537233] EIP is at skb_panic+0x68/0x70 [ 133.537233] EAX: 0000007a EBX: cd923000 ECX: 00000000 EDX: 00000001 [ 133.537233] ESI: c1b2a11b EDI: 00000004 EBP: cc7d1c18 ESP: cc7d1be8 [ 133.537233] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 [ 133.537233] CR0: 8005003b CR2: b76d9000 CR3: 0e1e5000 CR4: 000006d0 [ 133.537233] Stack: [ 133.537233] c1ba8748 c1982e68 d19cb60c 00000037 00000028 cd923000 cd922fec cd923023 [ 133.537233] cd923740 c1b2a11b cd914300 00000003 cc7d1c24 c1779881 c1982e68 cc7d1c94 [ 133.537233] d19cb60c c0304c48 00000003 00000008 cc7d1c40 00000003 017d1c64 00000003 [ 133.537233] Call Trace: [ 133.537233] [<d19cb60c>] ? lowpan_header_decompress+0x26c/0x980 [6lowpan] [ 133.537233] [<c1779881>] skb_push+0x41/0x50 [ 133.537233] [<d19cb60c>] lowpan_header_decompress+0x26c/0x980 [6lowpan] [ 133.537233] [<d19daeb4>] chan_recv_cb+0x244/0x3f0 [bluetooth_6lowpan] [ 133.537233] [<d1738711>] l2cap_data_channel+0x8e1/0x980 [bluetooth] [ 133.537233] [<c10772d9>] ? sched_clock_local+0x49/0x180 [ 133.537233] [<d173aa8f>] l2cap_recv_frame+0xbf/0x2ee0 [bluetooth] [ 133.537233] [<c100a7a8>] ? sched_clock+0x8/0x10 [ 133.537233] [<c10772d9>] ? sched_clock_local+0x49/0x180 [ 133.537233] [<c100a7a8>] ? sched_clock+0x8/0x10 [ 133.537233] [<c10772d9>] ? sched_clock_local+0x49/0x180 [ 133.537233] [<c107770f>] ? sched_clock_cpu+0x10f/0x160 [ 133.537233] [<c10729cb>] ? get_parent_ip+0xb/0x40 [ 133.537233] [<c1072a4b>] ? preempt_count_add+0x4b/0xa0 [ 133.537233] [<c13e0112>] ? debug_smp_processor_id+0x12/0x20 [ 133.537233] [<c108e584>] ? get_lock_stats+0x24/0x40 [ 133.537233] [<c1090a34>] ? mark_held_locks+0x64/0x90 [ 133.537233] [<c189dbfd>] ? __mutex_unlock_slowpath+0xcd/0x1b0 [ 133.537233] [<c13e012f>] ? __this_cpu_preempt_check+0xf/0x20 [ 133.537233] [<c1090b54>] ? trace_hardirqs_on_caller+0xf4/0x240 [ 133.537233] [<c108e326>] ? trace_hardirqs_off_caller+0xb6/0x160 [ 133.537233] [<d173ee19>] l2cap_recv_acldata+0x2f9/0x340 [bluetooth] [ 133.537233] [<d1709a93>] ? hci_rx_work+0x113/0x4a0 [bluetooth] [ 133.537233] [<d1709ce9>] hci_rx_work+0x369/0x4a0 [bluetooth] [ 133.537233] [<d1709a93>] ? hci_rx_work+0x113/0x4a0 [bluetooth] [ 133.537233] [<c1063203>] process_one_work+0x1b3/0x4e0 [ 133.537233] [<c1063163>] ? process_one_work+0x113/0x4e0 [ 133.537233] [<c10638c9>] worker_thread+0x39/0x440 [ 133.537233] [<c1063890>] ? init_pwq+0xc0/0xc0 [ 133.537233] [<c1067ce8>] kthread+0xa8/0xc0 [ 133.537233] [<c1090cab>] ? trace_hardirqs_on+0xb/0x10 [ 133.537233] [<c18a1741>] ret_from_kernel_thread+0x21/0x30 [ 133.537233] [<c1067c40>] ? kthread_create_on_node+0x160/0x160 [ 133.537233] Code: 98 a8 00 00 00 89 54 24 10 89 5c 24 14 8b 40 5c 89 4c 24 08 c7 04 24 48 87 ba c1 89 44 24 0c 8b 45 08 89 44 24 04 e8 b0 db 11 00 <0f> 0b 8d b6 00 00 00 00 55 89 e5 83 ec 04 3e 8d 74 26 00 89 c1 [ 133.537233] EIP: [<c1779838>] skb_panic+0x68/0x70 SS:ESP
0068:cc7d1be8
Just wondering about how it works now. If the device does not have 6lowpan_nhc module loaded, then UDP compressed packets are dropped. This feels wrong and is a kind of regression to the previous way of working, at least we need to auto-load the compression module.
How the system works if there would be another way to compress UDP packets. User would need to know somehow what kind of packets it is suppose to send/receive and load corresponding module. I wonder if this kind of knowledge is really possible in practice. Should we always support the NHC defined in https://tools.ietf.org/html/rfc6282 and then have a way to load correct compression "plugin" if we get a packet with different compression scheme.
If the system does not support https://tools.ietf.org/html/rfc6775 (like at the moment) there is no way to figure out what compression system the other end is using/supporting. In this respect, it would be nice if the current way of working would be automatically supported and user would not need to remember to select 6lowpan_nhc option when building the kernel.
I like the way to support different compression algorithms, it just needs some fine tuning.
Cheers,
Jukka
Alexander Aring
maintainerHi Jukka,
Quoted 106 lines · Jukka Rissanen
Hi Alex,
Quoted 17 lines · Alexander Aring
This patch series introduce the next header compression framework. Currently we support udp compression/uncompression only. This framework allow to add new next header compression formats easily.
If somebody wants to add a new header compression format and some information are missing while calling compression and uncompression callbacks. Please feel free to make framework changes according these callbacks.
Note:
If building 6lowpan_udp as module please make sure it's loaded before running rfc6282 udp connection. If it's not loaded we send 6lowpan with raw udp header and next header compression bit isn't set. Nevertheless if you use rfc6282 connection and 6lowpan_udp isn't loaded following will be printed:
"ieee802154 wpan-phy0 wpan0: received nhc which is not supported. Dropping."
Quoted 8 lines
changes since v2:
- make udp nhc as module as suggested by Marcel Holtmann
- fix comment header innhc_udp.cI didn't make the
lowpan_nhcdeclaration "const" because this will occur issues withrb_node, id and idmask array. Which will manipulated during runtime.Tested it between two BT 6lowpan connections. If both ends load the 6lowpan_udp module, then no issues. If only the other end has loaded the module, the other end (receiving end) crashed.
[ 132.417733] (NULL net_device): received nhc which is not supported. Dropping. [ 132.722432] skbuff: skb_under_panic: text:d19cb60c len:55 put:40 head:cd923000 data:cd922fec tail:0xcd923023 end:0xcd923740 dev:<NULL> [ 133.536256] ------------[ cut here ]------------ [ 133.537233] kernel BUG at 3.16+gitAUTOINC +f6af675ef5-r215/linux/net/core/skbuff.c:100! [ 133.537233] invalid opcode: 0000 [#1] PREEMPT SMP [ 133.537233] Modules linked in: bluetooth_6lowpan 6lowpan nfc ecb btusb bluetooth rfkill snd_intel8x0 ohci_pci snd_ac97_codec ac97_bus parport_pc parport uvesafb [ 133.537233] CPU: 0 PID: 327 Comm: kworker/u3:0 Not tainted 3.17.0-bt6lowpan #1 [ 133.537233] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 133.537233] Workqueue: hci0 hci_rx_work [bluetooth] [ 133.537233] task: c0170000 ti: cc7d0000 task.ti: cc7d0000 [ 133.537233] EIP: 0060:[<c1779838>] EFLAGS: 00010292 CPU: 0 [ 133.537233] EIP is at skb_panic+0x68/0x70 [ 133.537233] EAX: 0000007a EBX: cd923000 ECX: 00000000 EDX: 00000001 [ 133.537233] ESI: c1b2a11b EDI: 00000004 EBP: cc7d1c18 ESP: cc7d1be8 [ 133.537233] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 [ 133.537233] CR0: 8005003b CR2: b76d9000 CR3: 0e1e5000 CR4: 000006d0 [ 133.537233] Stack: [ 133.537233] c1ba8748 c1982e68 d19cb60c 00000037 00000028 cd923000 cd922fec cd923023 [ 133.537233] cd923740 c1b2a11b cd914300 00000003 cc7d1c24 c1779881 c1982e68 cc7d1c94 [ 133.537233] d19cb60c c0304c48 00000003 00000008 cc7d1c40 00000003 017d1c64 00000003 [ 133.537233] Call Trace: [ 133.537233] [<d19cb60c>] ? lowpan_header_decompress+0x26c/0x980 [6lowpan] [ 133.537233] [<c1779881>] skb_push+0x41/0x50 [ 133.537233] [<d19cb60c>] lowpan_header_decompress+0x26c/0x980 [6lowpan] [ 133.537233] [<d19daeb4>] chan_recv_cb+0x244/0x3f0 [bluetooth_6lowpan] [ 133.537233] [<d1738711>] l2cap_data_channel+0x8e1/0x980 [bluetooth] [ 133.537233] [<c10772d9>] ? sched_clock_local+0x49/0x180 [ 133.537233] [<d173aa8f>] l2cap_recv_frame+0xbf/0x2ee0 [bluetooth] [ 133.537233] [<c100a7a8>] ? sched_clock+0x8/0x10 [ 133.537233] [<c10772d9>] ? sched_clock_local+0x49/0x180 [ 133.537233] [<c100a7a8>] ? sched_clock+0x8/0x10 [ 133.537233] [<c10772d9>] ? sched_clock_local+0x49/0x180 [ 133.537233] [<c107770f>] ? sched_clock_cpu+0x10f/0x160 [ 133.537233] [<c10729cb>] ? get_parent_ip+0xb/0x40 [ 133.537233] [<c1072a4b>] ? preempt_count_add+0x4b/0xa0 [ 133.537233] [<c13e0112>] ? debug_smp_processor_id+0x12/0x20 [ 133.537233] [<c108e584>] ? get_lock_stats+0x24/0x40 [ 133.537233] [<c1090a34>] ? mark_held_locks+0x64/0x90 [ 133.537233] [<c189dbfd>] ? __mutex_unlock_slowpath+0xcd/0x1b0 [ 133.537233] [<c13e012f>] ? __this_cpu_preempt_check+0xf/0x20 [ 133.537233] [<c1090b54>] ? trace_hardirqs_on_caller+0xf4/0x240 [ 133.537233] [<c108e326>] ? trace_hardirqs_off_caller+0xb6/0x160 [ 133.537233] [<d173ee19>] l2cap_recv_acldata+0x2f9/0x340 [bluetooth] [ 133.537233] [<d1709a93>] ? hci_rx_work+0x113/0x4a0 [bluetooth] [ 133.537233] [<d1709ce9>] hci_rx_work+0x369/0x4a0 [bluetooth] [ 133.537233] [<d1709a93>] ? hci_rx_work+0x113/0x4a0 [bluetooth] [ 133.537233] [<c1063203>] process_one_work+0x1b3/0x4e0 [ 133.537233] [<c1063163>] ? process_one_work+0x113/0x4e0 [ 133.537233] [<c10638c9>] worker_thread+0x39/0x440 [ 133.537233] [<c1063890>] ? init_pwq+0xc0/0xc0 [ 133.537233] [<c1067ce8>] kthread+0xa8/0xc0 [ 133.537233] [<c1090cab>] ? trace_hardirqs_on+0xb/0x10 [ 133.537233] [<c18a1741>] ret_from_kernel_thread+0x21/0x30 [ 133.537233] [<c1067c40>] ? kthread_create_on_node+0x160/0x160 [ 133.537233] Code: 98 a8 00 00 00 89 54 24 10 89 5c 24 14 8b 40 5c 89 4c 24 08 c7 04 24 48 87 ba c1 89 44 24 0c 8b 45 08 89 44 24 04 e8 b0 db 11 00 <0f> 0b 8d b6 00 00 00 00 55 89 e5 83 ec 04 3e 8d 74 26 00 89 c1 [ 133.537233] EIP: [<c1779838>] skb_panic+0x68/0x70 SS:ESP
Quoted 2 lines
0068:cc7d1be8
Ok I send now a correction for patch PATCH 1/2 for use "-ENOENT" as ret initialization. Can you test that, please? :-)
Quoted 5 lines
Just wondering about how it works now. If the device does not have 6lowpan_nhc module loaded, then UDP compressed packets are dropped. This feels wrong and is a kind of regression to the previous way of working, at least we need to auto-load the compression module.
It works now in this way (example UDP, RAW UDP is a normal 8 byte UDP header):
If no 6lowpan_nhc_udp is loaded:
sending side:
We don't set the NHC bit in 6LoWPAN header, we putting the RAW UDP header.
receiving side:
If we get a 6LoWPAN header which set the NHC bit:
We print a warning and drop the packet, because we don't know the NHC ID. "ieee802154 wpan-phy0 wpan0: received nhc which is not supported. Dropping." Maybe this can look a little bit better. :-)
If we get a 6LoWPAN header which does not set the NHC bit and contains the raw UDP header then this will go into IPv6 layer.
If 6lowpan_nhc_udp is loaded:
sending side:
If we get nexthdr == UDP then automatically we do a udp compression algorithm for RFC6282.
receiving side:
We can now accept boths methods, NHC bit is set and UDP compression (rfc6282) then magic 6lowpan_nhc_udp module function do an uncompression.
If NHC bit isn't set we accept also a RAW udp without compression.
Quoted 9 lines
How the system works if there would be another way to compress UDP packets. User would need to know somehow what kind of packets it is suppose to send/receive and load corresponding module. I wonder if this kind of knowledge is really possible in practice. Should we always support the NHC defined in https://tools.ietf.org/html/rfc6282 and then have a way to load correct compression "plugin" if we get a packet with different compression scheme.
Quoted 7 lines
If the system does not support https://tools.ietf.org/html/rfc6775 (like at the moment) there is no way to figure out what compression system the other end is using/supporting. In this respect, it would be nice if the current way of working would be automatically supported and user would not need to remember to select 6lowpan_nhc option when building the kernel.
Yes, we should support automatically and not by user if he loads the corresponding module.
For configuration the compression methods I would expect some kind of netlink interface. On the userspace side we need some kind of tool to make it configurable. What do you think here?
Supporting a new userspace tool will make a high working load and we need some kind of new 6lowpan repo for releasing such tool. I _could_ try to implement such netlink interface for nhc into net/6lowpan and greating a userspace tool. Don't know if we do this effort and making a 6lowpan_udp userspace tool for configuration, but please make first such framework mainline and the netlink interface can we add later. :-)
btw: which part of rfc6775 describes how to detect the compression methods on the other end (using/supporting)?
Quoted 3 lines
I like the way to support different compression algorithms, it just needs some fine tuning.
Yea, this should mainly _first_ bring any framework for next header compression mainline. I didn't program such framework in my life and don't know what 100% we need. For adding new compression methods I think this framework will grow automatically by history of hacking new compression methods and I am sure lot of things can be do better than right now. At the moment it's better than the current behaviour that we don't have such framework for adding new compression methods.
- Alex
Hi Alex,
Quoted 112 lines · Alexander Aring
Hi Jukka,
Quoted 106 lines · Jukka Rissanen
Hi Alex,
Quoted 17 lines · Alexander Aring
This patch series introduce the next header compression framework. Currently we support udp compression/uncompression only. This framework allow to add new next header compression formats easily.
If somebody wants to add a new header compression format and some information are missing while calling compression and uncompression callbacks. Please feel free to make framework changes according these callbacks.
Note:
If building 6lowpan_udp as module please make sure it's loaded before running rfc6282 udp connection. If it's not loaded we send 6lowpan with raw udp header and next header compression bit isn't set. Nevertheless if you use rfc6282 connection and 6lowpan_udp isn't loaded following will be printed:
"ieee802154 wpan-phy0 wpan0: received nhc which is not supported. Dropping."
Quoted 8 lines
changes since v2:
- make udp nhc as module as suggested by Marcel Holtmann
- fix comment header innhc_udp.cI didn't make the
lowpan_nhcdeclaration "const" because this will occur issues withrb_node, id and idmask array. Which will manipulated during runtime.Tested it between two BT 6lowpan connections. If both ends load the 6lowpan_udp module, then no issues. If only the other end has loaded the module, the other end (receiving end) crashed.
[ 132.417733] (NULL net_device): received nhc which is not supported. Dropping. [ 132.722432] skbuff: skb_under_panic: text:d19cb60c len:55 put:40 head:cd923000 data:cd922fec tail:0xcd923023 end:0xcd923740 dev:<NULL> [ 133.536256] ------------[ cut here ]------------ [ 133.537233] kernel BUG at 3.16+gitAUTOINC +f6af675ef5-r215/linux/net/core/skbuff.c:100! [ 133.537233] invalid opcode: 0000 [#1] PREEMPT SMP [ 133.537233] Modules linked in: bluetooth_6lowpan 6lowpan nfc ecb btusb bluetooth rfkill snd_intel8x0 ohci_pci snd_ac97_codec ac97_bus parport_pc parport uvesafb [ 133.537233] CPU: 0 PID: 327 Comm: kworker/u3:0 Not tainted 3.17.0-bt6lowpan #1 [ 133.537233] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 133.537233] Workqueue: hci0 hci_rx_work [bluetooth] [ 133.537233] task: c0170000 ti: cc7d0000 task.ti: cc7d0000 [ 133.537233] EIP: 0060:[<c1779838>] EFLAGS: 00010292 CPU: 0 [ 133.537233] EIP is at skb_panic+0x68/0x70 [ 133.537233] EAX: 0000007a EBX: cd923000 ECX: 00000000 EDX: 00000001 [ 133.537233] ESI: c1b2a11b EDI: 00000004 EBP: cc7d1c18 ESP: cc7d1be8 [ 133.537233] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 [ 133.537233] CR0: 8005003b CR2: b76d9000 CR3: 0e1e5000 CR4: 000006d0 [ 133.537233] Stack: [ 133.537233] c1ba8748 c1982e68 d19cb60c 00000037 00000028 cd923000 cd922fec cd923023 [ 133.537233] cd923740 c1b2a11b cd914300 00000003 cc7d1c24 c1779881 c1982e68 cc7d1c94 [ 133.537233] d19cb60c c0304c48 00000003 00000008 cc7d1c40 00000003 017d1c64 00000003 [ 133.537233] Call Trace: [ 133.537233] [<d19cb60c>] ? lowpan_header_decompress+0x26c/0x980 [6lowpan] [ 133.537233] [<c1779881>] skb_push+0x41/0x50 [ 133.537233] [<d19cb60c>] lowpan_header_decompress+0x26c/0x980 [6lowpan] [ 133.537233] [<d19daeb4>] chan_recv_cb+0x244/0x3f0 [bluetooth_6lowpan] [ 133.537233] [<d1738711>] l2cap_data_channel+0x8e1/0x980 [bluetooth] [ 133.537233] [<c10772d9>] ? sched_clock_local+0x49/0x180 [ 133.537233] [<d173aa8f>] l2cap_recv_frame+0xbf/0x2ee0 [bluetooth] [ 133.537233] [<c100a7a8>] ? sched_clock+0x8/0x10 [ 133.537233] [<c10772d9>] ? sched_clock_local+0x49/0x180 [ 133.537233] [<c100a7a8>] ? sched_clock+0x8/0x10 [ 133.537233] [<c10772d9>] ? sched_clock_local+0x49/0x180 [ 133.537233] [<c107770f>] ? sched_clock_cpu+0x10f/0x160 [ 133.537233] [<c10729cb>] ? get_parent_ip+0xb/0x40 [ 133.537233] [<c1072a4b>] ? preempt_count_add+0x4b/0xa0 [ 133.537233] [<c13e0112>] ? debug_smp_processor_id+0x12/0x20 [ 133.537233] [<c108e584>] ? get_lock_stats+0x24/0x40 [ 133.537233] [<c1090a34>] ? mark_held_locks+0x64/0x90 [ 133.537233] [<c189dbfd>] ? __mutex_unlock_slowpath+0xcd/0x1b0 [ 133.537233] [<c13e012f>] ? __this_cpu_preempt_check+0xf/0x20 [ 133.537233] [<c1090b54>] ? trace_hardirqs_on_caller+0xf4/0x240 [ 133.537233] [<c108e326>] ? trace_hardirqs_off_caller+0xb6/0x160 [ 133.537233] [<d173ee19>] l2cap_recv_acldata+0x2f9/0x340 [bluetooth] [ 133.537233] [<d1709a93>] ? hci_rx_work+0x113/0x4a0 [bluetooth] [ 133.537233] [<d1709ce9>] hci_rx_work+0x369/0x4a0 [bluetooth] [ 133.537233] [<d1709a93>] ? hci_rx_work+0x113/0x4a0 [bluetooth] [ 133.537233] [<c1063203>] process_one_work+0x1b3/0x4e0 [ 133.537233] [<c1063163>] ? process_one_work+0x113/0x4e0 [ 133.537233] [<c10638c9>] worker_thread+0x39/0x440 [ 133.537233] [<c1063890>] ? init_pwq+0xc0/0xc0 [ 133.537233] [<c1067ce8>] kthread+0xa8/0xc0 [ 133.537233] [<c1090cab>] ? trace_hardirqs_on+0xb/0x10 [ 133.537233] [<c18a1741>] ret_from_kernel_thread+0x21/0x30 [ 133.537233] [<c1067c40>] ? kthread_create_on_node+0x160/0x160 [ 133.537233] Code: 98 a8 00 00 00 89 54 24 10 89 5c 24 14 8b 40 5c 89 4c 24 08 c7 04 24 48 87 ba c1 89 44 24 0c 8b 45 08 89 44 24 04 e8 b0 db 11 00 <0f> 0b 8d b6 00 00 00 00 55 89 e5 83 ec 04 3e 8d 74 26 00 89 c1 [ 133.537233] EIP: [<c1779838>] skb_panic+0x68/0x70 SS:ESPQuoted 2 lines
0068:cc7d1be8
Quoted 2 lines
Ok I send now a correction for patch PATCH 1/2 for use "
-ENOENT" as ret initialization. Can you test that, please? :-)
Sure, I will do that, will send status about that later.
Quoted 59 lines
Quoted 6 lines
Just wondering about how it works now. If the device does not have 6lowpan_nhc module loaded, then UDP compressed packets are dropped. This feels wrong and is a kind of regression to the previous way of working, at least we need to auto-load the compression module.
It works now in this way (example UDP, RAW UDP is a normal 8 byte UDP header):
If no 6lowpan_nhc_udp is loaded:
sending side:
We don't set the NHC bit in 6LoWPAN header, we putting the RAW UDP header.
receiving side:
If we get a 6LoWPAN header which set the NHC bit:
We print a warning and drop the packet, because we don't know the NHC ID. "ieee802154 wpan-phy0 wpan0: received nhc which is not supported. Dropping." Maybe this can look a little bit better. :-)If we get a 6LoWPAN header which does not set the NHC bit and contains the raw UDP header then this will go into IPv6 layer.
If 6lowpan_nhc_udp is loaded:
sending side:
If we get nexthdr == UDP then automatically we do a udp compression algorithm for RFC6282.receiving side:
We can now accept boths methods, NHC bit is set and UDP compression (rfc6282) then magic 6lowpan_nhc_udp module function do an uncompression.
If NHC bit isn't set we accept also a RAW udp without compression.
Quoted 9 lines
How the system works if there would be another way to compress UDP packets. User would need to know somehow what kind of packets it is suppose to send/receive and load corresponding module. I wonder if this kind of knowledge is really possible in practice. Should we always support the NHC defined in https://tools.ietf.org/html/rfc6282 and then have a way to load correct compression "plugin" if we get a packet with different compression scheme.
Quoted 7 lines
If the system does not support https://tools.ietf.org/html/rfc6775 (like at the moment) there is no way to figure out what compression system the other end is using/supporting. In this respect, it would be nice if the current way of working would be automatically supported and user would not need to remember to select 6lowpan_nhc option when building the kernel.
Quoted 6 lines
Yes, we should support automatically and not by user if he loads the corresponding module.
For configuration the compression methods I would expect some kind of netlink interface. On the userspace side we need some kind of tool to make it configurable. What do you think here?
Yes, that sounds good.
Quoted 11 lines
Supporting a new userspace tool will make a high working load and we need some kind of new 6lowpan repo for releasing such tool. I _could_ try to implement such netlink interface for nhc into net/6lowpan and greating a userspace tool. Don't know if we do this effort and making a 6lowpan_udp userspace tool for configuration, but please make first such framework mainline and the netlink interface can we add later. :-)
btw: which part of rfc6775 describes how to detect the compression methods on the other end (using/supporting)?
My bad, I remembered incorrectly, there was nothing like that mentioned in rfc6775.
Quoted 13 lines
Quoted 4 lines
I like the way to support different compression algorithms, it just needs some fine tuning.
Yea, this should mainly _first_ bring any framework for next header compression mainline. I didn't program such framework in my life and don't know what 100% we need. For adding new compression methods I think this framework will grow automatically by history of hacking new compression methods and I am sure lot of things can be do better than right now. At the moment it's better than the current behaviour that we don't have such framework for adding new compression methods.
Quoted 1 line
- Alex
I forgot to mention earlier that I think we need to support the case where some clients are using different compression method than the other (at the same time). What do you think?
Cheers,
Jukka
Alexander Aring
maintainerOn Tue, Dec 02, 2014 at 11:23:36AM +0200, Jukka Rissanen wrote:
...
Quoted 6 lines
I forgot to mention earlier that I think we need to support the case where some clients are using different compression method than the other (at the same time). What do you think?
_Currently_ I would to do the following:
Sending side:
We have a mapping from nexthdr IPv6 field to the configurated (at the moment the defaults compression methods) next header compression.
lowpan_compress -> nexthdr to nhc struct -> do nhc compression
This is a 1:1 mapping for nexthdr as UDP we have RFC6282 UDP.
_Maybe_ we can do some socket options settings in the future to have not always a 1:1 mapping. Sending sockopts to 6LoWPAN layer seems to be difficult, I don't know how much possible that is and the IPv6 agree with that. Otherwise we need some great idea to make allow different compression methods per socket. Currently a 1:1 seems to be okay.
Receiving side:
There we need to support everything what we can support. The next header compression id is a variable length of bitstring (that's why there is a complicated rbtree datastructure inside the nhc framework).
This number is unique to each compression methods. It's some kind of n:1 mapping e.g. (UDP RFC6282) to UDP and (UDP FOOBAR) to UDP.
So sending side _can_ be optionally and receiving _should_ be implemented.
I have a new series which makes both optionally. The reason is that we can register the NHC ID and print a warning which NHC ID isn't supported. So this beahviour is more "We know this NHC but we don't support compression and uncompression". This will print a warning and users have two options:
1. Implement the nhc.
2. Change network configuration to not do this nhc on other nodes.
- Alex