[Linux-zigbee-devel] [PATCH net-next 01/17] 6lowpan: allow to skip bytes in lowpan_fetch_skb
This will add support to skip bytes from skb with the lowpan_fetch_skb function. This is necessary for upcomming patches. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h index 2869c05..1b1b5db 100644 --- a/net/ieee802154/6lowpan.h +++ b/net/ieee802154/6lowpan.h @@ -238,7 +238,9 @@ static inline bool lowpan_fetch_skb(struct sk_buff *skb, if (unlikely(!pskb_may_pull(skb, len))) return true; - skb_copy_from_linear_data(skb, data, len); + if (data) + skb_copy_from_linear_data(skb, data, len); + skb_pull(skb, len); return false; -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 06/17] 6lowpan: remove unnecessary ret variable
Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 1743478..1dd690a 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -1078,7 +1078,7 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, int mlen, int plen, int offset, int type) { struct sk_buff *frag; - int hlen, ret; + int hlen; hlen = (type == LOWPAN_DISPATCH_FRAG1) ? LOWPAN_FRAG1_HEAD_SIZE : LOWPAN_FRAGN_HEAD_SIZE; @@ -1103,9 +1103,7 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, lowpan_raw_dump_table(__func__, " raw fragment dump", frag->data, frag->len); - ret = dev_queue_xmit(frag); - - return ret; + return dev_queue_xmit(frag); } static int -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 00/17] 6lowpan: fragmentation fix
The current fragmentation implementation isn't rfc4944 compatible so a ping with a payload of > 127 with other 6lowpan implementations like contiki isn't possible. This patch fixes the fragmentation implementation to rfc4944 so fragmentation with ping comes possible, Also fix some race conditions which I detect while testing and a lot of smaller changes in the api to make the rfc4944 fragmentation possible. I also have some patches to fix the udp compression/uncompression which is totally broken at the moment. I will send the udp patches after the fragmentation fixes. Alexander Aring (17): 6lowpan: allow to skip bytes in lowpan_fetch_skb 6lowpan: fix indentation 6lowpan: remove several copies of sk_buff 6lowpan: set and use mac_len for mac header length 6lowpan: set 6lowpan network and transport header 6lowpan: remove unnecessary ret variable 6lowpan: use netdev_alloc_skb instead dev_alloc_skb 6lowpan: remove unnecessary check on err >= 0 6lowpan: cleanup skb copy data 6lowpan: remove unecessary set of headers 6lowpan: remove lowpan_skb_deliver func 6lowpan: remove skb->dev assign 6lowpan: fix fragmentation on sending side 6lowpan: fix fragmentation on receiving side 6lowpan: add match for address 6lowpan: fix fragmentation race condition 6lowpan: use try_to_del_timer_sync instead del_timer_sync include/net/ieee802154_netdev.h | 2 + net/ieee802154/6lowpan.c| 448 net/ieee802154/6lowpan.h| 32 ++- net/mac802154/wpan.c| 6 +- 4 files changed, 264 insertions(+), 224 deletions(-) -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 02/17] 6lowpan: fix indentation
This patch indentation fixes are necessary for the upcomming patches. It removes some whitespace issues which checkpatch pointed out. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index c85e71e..0d486b5 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -1065,7 +1065,7 @@ lowpan_process_data(struct sk_buff *skb) skb_copy_to_linear_data(skb, &uh, sizeof(struct udphdr)); lowpan_raw_dump_table(__func__, "raw UDP header dump", - (u8 *)&uh, sizeof(uh)); + (u8 *)&uh, sizeof(uh)); hdr.nexthdr = UIP_PROTO_UDP; } @@ -1080,8 +1080,8 @@ lowpan_process_data(struct sk_buff *skb) "nexthdr = 0x%02x\n\thop_lim = %d\n", hdr.version, ntohs(hdr.payload_len), hdr.nexthdr, hdr.hop_limit); - lowpan_raw_dump_table(__func__, "raw header dump", (u8 *)&hdr, - sizeof(hdr)); + lowpan_raw_dump_table(__func__, "raw header dump", + (u8 *)&hdr, sizeof(hdr)); return lowpan_skb_deliver(skb, &hdr); unlock_and_drop: @@ -1117,7 +1117,7 @@ static int lowpan_get_mac_header_length(struct sk_buff *skb) static int lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, - int mlen, int plen, int offset, int type) + int mlen, int plen, int offset, int type) { struct sk_buff *frag; int hlen, ret; @@ -1142,8 +1142,8 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, skb_copy_from_linear_data_offset(skb, offset + mlen, skb_put(frag, plen), plen); - lowpan_raw_dump_table(__func__, " raw fragment dump", frag->data, - frag->len); + lowpan_raw_dump_table(__func__, " raw fragment dump", + frag->data, frag->len); ret = dev_queue_xmit(frag); -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 16/17] 6lowpan: fix fragmentation race condition
If the timer expire on fragmentation handling we need to hold the flist_lock spinlock while accessing fraglist. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 0da513b..10cf032 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -743,7 +743,9 @@ static void lowpan_fragment_timer_expired(unsigned long entry_addr) pr_debug("timer expired for frame with tag %d\n", entry->tag); + spin_lock_bh(&flist_lock); list_del(&entry->list); + spin_unlock_bh(&flist_lock); dev_kfree_skb(entry->skb); kfree(entry); } -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 05/17] 6lowpan: set 6lowpan network and transport header
This is necessary for upcomming patches to calculate the 6lowpan header. It's a little bit tricky here because a UDP transport header can be compressed in the network header, so the UDP header is merged in the 6lowpan header. In this case the transport header points to the payload of the UDP header. For now it's okay to make it in this way, because we use this to calculate the 6lowpan header size only. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 946b6b4..1743478 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -655,7 +655,9 @@ static int lowpan_header_create(struct sk_buff *skb, head[1] = iphc1; skb_pull(skb, sizeof(struct ipv6hdr)); + skb_reset_transport_header(skb); memcpy(skb_push(skb, hc06_ptr - head), head, hc06_ptr - head); + skb_reset_network_header(skb); lowpan_raw_dump_table(__func__, "raw skb data dump", skb->data, skb->len); -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 08/17] 6lowpan: remove unnecessary check on err >= 0
Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index c458ac2..6547efc 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -1137,7 +1137,7 @@ lowpan_skb_fragmentation(struct sk_buff *skb, struct net_device *dev) head[0] &= ~LOWPAN_DISPATCH_FRAG1; head[0] |= LOWPAN_DISPATCH_FRAGN; - while ((payload_length - offset > 0) && (err >= 0)) { + while (payload_length - offset > 0) { int len = LOWPAN_FRAG_SIZE; head[4] = offset / 8; -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 09/17] 6lowpan: cleanup skb copy data
This patch drops the directly memcpy on skb and uses the right skb memcpy functions. Also remove an unnecessary check if plen is non zero. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 6547efc..605fe2b 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -1093,12 +1093,15 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, frag->priority = skb->priority; /* copy header, MFR and payload */ - memcpy(skb_put(frag, mlen), skb->data, mlen); - memcpy(skb_put(frag, hlen), head, hlen); + skb_put(frag, mlen); + skb_copy_to_linear_data(frag, skb_mac_header(skb), mlen); - if (plen) - skb_copy_from_linear_data_offset(skb, offset + mlen, - skb_put(frag, plen), plen); + skb_put(frag, hlen); + skb_copy_to_linear_data_offset(frag, mlen, head, hlen); + + skb_put(frag, plen); + skb_copy_to_linear_data_offset(frag, mlen + hlen, + skb_network_header(skb) + offset, plen); lowpan_raw_dump_table(__func__, " raw fragment dump", frag->data, frag->len); -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 11/17] 6lowpan: remove lowpan_skb_deliver func
Since we drop the skb copies, we don't need this function. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 22 -- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 42deee6..711f905 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -709,6 +709,9 @@ static int lowpan_give_skb_to_devices(struct sk_buff *skb) struct lowpan_dev_record *entry; int stat = NET_RX_SUCCESS; + skb->protocol = htons(ETH_P_IPV6); + skb->pkt_type = PACKET_HOST; + rcu_read_lock(); list_for_each_entry_rcu(entry, &lowpan_devices, list) if (lowpan_dev_info(entry->ldev)->real_dev == skb->dev) { @@ -720,19 +723,6 @@ static int lowpan_give_skb_to_devices(struct sk_buff *skb) return stat; } -static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr) -{ - int stat = NET_RX_SUCCESS; - - skb_push(skb, sizeof(struct ipv6hdr)); - skb_copy_to_linear_data(skb, hdr, sizeof(struct ipv6hdr)); - - skb->protocol = htons(ETH_P_IPV6); - skb->pkt_type = PACKET_HOST; - - return lowpan_give_skb_to_devices(skb); -} - static void lowpan_fragment_timer_expired(unsigned long entry_addr) { struct lowpan_fragment *entry = (struct lowpan_fragment *)entry_addr; @@ -1049,7 +1039,11 @@ lowpan_process_data(struct sk_buff *skb) lowpan_raw_dump_table(__func__, "raw header dump", (u8 *)&hdr, sizeof(hdr)); - return lowpan_skb_deliver(skb, &hdr); + + skb_push(skb, sizeof(struct ipv6hdr)); + skb_copy_to_linear_data(skb, &hdr, sizeof(struct ipv6hdr)); + + return lowpan_give_skb_to_devices(skb); unlock_and_drop: spin_unlock_bh(&flist_lock); -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 12/17] 6lowpan: remove skb->dev assign
This patch removes the assign of skb->dev. We don't need it here because we use a netdev_alloc_skb... function. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 711f905..448cc75 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -757,7 +757,6 @@ lowpan_alloc_new_frame(struct sk_buff *skb, u16 len, u16 tag) goto skb_err; frame->skb->priority = skb->priority; - frame->skb->dev = skb->dev; /* reserve headroom for uncompressed ipv6 header */ skb_reserve(frame->skb, sizeof(struct ipv6hdr)); -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 03/17] 6lowpan: remove several copies of sk_buff
The current implementation does many copies of the sk_buff for increasing headroom which are not necessary. This patch increases the headroom in the maclayer for a worst case scenario of (sizeof(struct ipv6hdr) + sizeof(struct udphdr)). Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 80 net/mac802154/wpan.c | 4 ++- 2 files changed, 16 insertions(+), 68 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 0d486b5..0dc27ec 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -705,20 +705,13 @@ static int lowpan_header_create(struct sk_buff *skb, static int lowpan_give_skb_to_devices(struct sk_buff *skb) { struct lowpan_dev_record *entry; - struct sk_buff *skb_cp; int stat = NET_RX_SUCCESS; rcu_read_lock(); list_for_each_entry_rcu(entry, &lowpan_devices, list) if (lowpan_dev_info(entry->ldev)->real_dev == skb->dev) { - skb_cp = skb_copy(skb, GFP_ATOMIC); - if (!skb_cp) { - stat = -ENOMEM; - break; - } - - skb_cp->dev = entry->ldev; - stat = netif_rx(skb_cp); + skb->dev = entry->ldev; + stat = netif_rx(skb); } rcu_read_unlock(); @@ -727,28 +720,16 @@ static int lowpan_give_skb_to_devices(struct sk_buff *skb) static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr) { - struct sk_buff *new; int stat = NET_RX_SUCCESS; - new = skb_copy_expand(skb, sizeof(struct ipv6hdr), skb_tailroom(skb), - GFP_ATOMIC); - kfree_skb(skb); - - if (!new) - return -ENOMEM; - - skb_push(new, sizeof(struct ipv6hdr)); - skb_reset_network_header(new); - skb_copy_to_linear_data(new, hdr, sizeof(struct ipv6hdr)); - - new->protocol = htons(ETH_P_IPV6); - new->pkt_type = PACKET_HOST; - - stat = lowpan_give_skb_to_devices(new); + skb_push(skb, sizeof(struct ipv6hdr)); + skb_reset_network_header(skb); + skb_copy_to_linear_data(skb, hdr, sizeof(struct ipv6hdr)); - kfree_skb(new); + skb->protocol = htons(ETH_P_IPV6); + skb->pkt_type = PACKET_HOST; - return stat; + return lowpan_give_skb_to_devices(skb); } static void lowpan_fragment_timer_expired(unsigned long entry_addr) @@ -1043,23 +1024,9 @@ lowpan_process_data(struct sk_buff *skb) /* UDP data uncompression */ if (iphc0 & LOWPAN_IPHC_NH_C) { struct udphdr uh; - struct sk_buff *new; if (lowpan_uncompress_udp_header(skb, &uh)) goto drop; - /* -* replace the compressed UDP head by the uncompressed UDP -* header -*/ - new = skb_copy_expand(skb, sizeof(struct udphdr), - skb_tailroom(skb), GFP_ATOMIC); - kfree_skb(skb); - - if (!new) - return -ENOMEM; - - skb = new; - skb_push(skb, sizeof(struct udphdr)); skb_reset_transport_header(skb); skb_copy_to_linear_data(skb, &uh, sizeof(struct udphdr)); @@ -1304,8 +1271,6 @@ static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[]) static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { - struct sk_buff *local_skb; - if (!netif_running(dev)) goto drop; @@ -1314,37 +1279,18 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, /* check that it's our buffer */ if (skb->data[0] == LOWPAN_DISPATCH_IPV6) { - /* Copy the packet so that the IPv6 header is -* properly aligned. -*/ - local_skb = skb_copy_expand(skb, NET_SKB_PAD - 1, - skb_tailroom(skb), GFP_ATOMIC); - if (!local_skb) - goto drop; - - local_skb->protocol = htons(ETH_P_IPV6); - local_skb->pkt_type = PACKET_HOST; - /* Pull off the 1-byte of 6lowpan header. */ - skb_pull(local_skb, 1); - skb_reset_network_header(local_skb); - skb_set_transport_header(local_skb, sizeof(struct ipv6hdr)); - - lowpan_give_skb_to_devices(local_skb); + skb_pull(skb, 1); + skb_reset_network_header(skb); + skb_set_transport_header(skb, sizeof(struct ipv6hdr)); - kfree_skb(local_skb); - kfree_skb(skb); + lowpan_give_skb
[Linux-zigbee-devel] [PATCH net-next 17/17] 6lowpan: use try_to_del_timer_sync instead del_timer_sync
This is a race condition fix if the timer expire occurs when the last frame is arrived otherwise we cleanup the list entry twice. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 10cf032..37c952e 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -1255,8 +1255,11 @@ static int lowpan_check_frag_complete(struct lowpan_fragment *frame) if (frame->bytes_rcv != frame->length) return ret; + ret = try_to_del_timer_sync(&frame->timer); + if (ret == -1) + return ret; + list_del(&frame->list); - del_timer_sync(&frame->timer); ret = lowpan_give_skb_to_devices(frame->skb); kfree(frame); -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 14/17] 6lowpan: fix fragmentation on receiving side
This patch fixes the fragmentation of receiving 6lowpan packets. The current fragmentation isn't rfc4944 compatible. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 268 +++ 1 file changed, 154 insertions(+), 114 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 4c2072d..6df928f 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -402,7 +402,8 @@ static inline int lowpan_fetch_skb_u16(struct sk_buff *skb, u16 *val) } static int -lowpan_uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh) +lowpan_uncompress_udp_header(struct sk_buff *skb, + struct udphdr *uh, size_t udplen) { u8 tmp; @@ -456,7 +457,11 @@ lowpan_uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh) * here, we obtain the hint from the remaining size of the * frame */ - uh->len = htons(skb->len + sizeof(struct udphdr)); + if (udplen) + uh->len = htons(udplen); + else + uh->len = htons(skb->len + sizeof(struct udphdr)); + pr_debug("uncompressed UDP length: src = %d", uh->len); } else { pr_debug("ERROR: unsupported NH format\n"); @@ -757,16 +762,11 @@ lowpan_alloc_new_frame(struct sk_buff *skb, u16 len, u16 tag) frame->tag = tag; /* allocate buffer for frame assembling */ - frame->skb = netdev_alloc_skb_ip_align(skb->dev, frame->length + - sizeof(struct ipv6hdr)); - + frame->skb = netdev_alloc_skb(skb->dev, frame->length); if (!frame->skb) goto skb_err; frame->skb->priority = skb->priority; - - /* reserve headroom for uncompressed ipv6 header */ - skb_reserve(frame->skb, sizeof(struct ipv6hdr)); skb_put(frame->skb, frame->length); /* copy the first control block to keep a @@ -786,7 +786,6 @@ lowpan_alloc_new_frame(struct sk_buff *skb, u16 len, u16 tag) list_add_tail(&frame->list, &lowpan_fragments); return frame; - skb_err: kfree(frame); frame_err: @@ -794,7 +793,7 @@ frame_err: } static int -lowpan_process_data(struct sk_buff *skb) +lowpan_process_data(struct sk_buff *skb, size_t d_size) { struct ipv6hdr hdr = {}; u8 tmp, iphc0, iphc1, num_context = 0; @@ -810,94 +809,6 @@ lowpan_process_data(struct sk_buff *skb) if (lowpan_fetch_skb_u8(skb, &iphc0)) goto drop; - /* fragments assembling */ - switch (iphc0 & LOWPAN_DISPATCH_MASK) { - case LOWPAN_DISPATCH_FRAG1: - case LOWPAN_DISPATCH_FRAGN: - { - struct lowpan_fragment *frame; - /* slen stores the rightmost 8 bits of the 11 bits length */ - u8 slen, offset = 0; - u16 len, tag; - bool found = false; - - if (lowpan_fetch_skb_u8(skb, &slen) || /* frame length */ - lowpan_fetch_skb_u16(skb, &tag)) /* fragment tag */ - goto drop; - - /* adds the 3 MSB to the 8 LSB to retrieve the 11 bits length */ - len = ((iphc0 & 7) << 8) | slen; - - if ((iphc0 & LOWPAN_DISPATCH_MASK) == LOWPAN_DISPATCH_FRAG1) { - pr_debug("%s received a FRAG1 packet (tag: %d, " -"size of the entire IP packet: %d)", -__func__, tag, len); - } else { /* FRAGN */ - if (lowpan_fetch_skb_u8(skb, &offset)) - goto unlock_and_drop; - pr_debug("%s received a FRAGN packet (tag: %d, " -"size of the entire IP packet: %d, " -"offset: %d)", __func__, tag, len, offset * 8); - } - - /* -* check if frame assembling with the same tag is -* already in progress -*/ - spin_lock_bh(&flist_lock); - - list_for_each_entry(frame, &lowpan_fragments, list) - if (frame->tag == tag) { - found = true; - break; - } - - /* alloc new frame structure */ - if (!found) { - pr_debug("%s first fragment received for tag %d, " -"begin packet reassembly", __func__, tag); - frame = lowpan_alloc_new_frame(skb, len, tag); - if (!frame) - goto unlock_and_drop; - } - - /* if payload fits buffer, copy it */ - if (likely((offset * 8 + skb->len) <= frame->length)) - skb_copy_to_linear_dat
[Linux-zigbee-devel] [PATCH net-next 15/17] 6lowpan: add match for address
Currently we match fragmentation frames only on his tagid. This patch adds support to match also on source and destination address. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 13 - net/ieee802154/6lowpan.h | 28 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 6df928f..0da513b 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -84,6 +84,8 @@ struct lowpan_fragment { u16 length; /* length to be assemled */ u32 bytes_rcv; /* bytes received */ u16 tag;/* current fragment tag */ + struct ieee802154_addr sa; /* source address */ + struct ieee802154_addr da; /* destination address */ struct timer_list timer; /* assembling timer */ struct list_headlist; /* fragments list */ }; @@ -760,6 +762,11 @@ lowpan_alloc_new_frame(struct sk_buff *skb, u16 len, u16 tag) frame->length = len; frame->tag = tag; + memcpy(&frame->sa, &mac_cb(skb)->sa, + sizeof(struct ieee802154_addr)); + memcpy(&frame->da, &mac_cb(skb)->da, + sizeof(struct ieee802154_addr)); + /* allocate buffer for frame assembling */ frame->skb = netdev_alloc_skb(skb->dev, frame->length); @@ -1228,7 +1235,11 @@ static struct lowpan_fragment *lowpan_get_frame( struct lowpan_fragment *frame; list_for_each_entry(frame, &lowpan_fragments, list) { - if (frame->tag == d_tag) + if (frame->tag == d_tag && + lowpan_equal_ieee802154_addr(&frame->sa, + &mac_cb(skb)->sa) && + lowpan_equal_ieee802154_addr(&frame->da, + &mac_cb(skb)->da)) return frame; } diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h index 1b1b5db..05a2a37 100644 --- a/net/ieee802154/6lowpan.h +++ b/net/ieee802154/6lowpan.h @@ -246,4 +246,32 @@ static inline bool lowpan_fetch_skb(struct sk_buff *skb, return false; } +/* Checks if ieee802154_addr are equals, + * if yes return 1 otherwise 0 + */ +static inline int lowpan_equal_ieee802154_addr(struct ieee802154_addr *a, + struct ieee802154_addr *b) +{ + if (a->pan_id != b->pan_id) + return 0; + + if (a->addr_type != b->addr_type) + return 0; + + switch (a->addr_type) { + case IEEE802154_ADDR_LONG: + if (memcmp(a->hwaddr, b->hwaddr, IEEE802154_ADDR_LEN)) + return 0; + break; + case IEEE802154_ADDR_SHORT: + if (a->short_addr != b->short_addr) + return 0; + break; + default: + return 0; + } + + return 1; +} + #endif /* __6LOWPAN_H__ */ -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 10/17] 6lowpan: remove unecessary set of headers
On receiving side we don't need to set any headers in skb. The deliver function delivers the skb to ipv6 handler and the ipv6 handler will set these headers. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 4 1 file changed, 4 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 605fe2b..42deee6 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -725,7 +725,6 @@ static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr) int stat = NET_RX_SUCCESS; skb_push(skb, sizeof(struct ipv6hdr)); - skb_reset_network_header(skb); skb_copy_to_linear_data(skb, hdr, sizeof(struct ipv6hdr)); skb->protocol = htons(ETH_P_IPV6); @@ -1030,7 +1029,6 @@ lowpan_process_data(struct sk_buff *skb) goto drop; skb_push(skb, sizeof(struct udphdr)); - skb_reset_transport_header(skb); skb_copy_to_linear_data(skb, &uh, sizeof(struct udphdr)); lowpan_raw_dump_table(__func__, "raw UDP header dump", @@ -1273,8 +1271,6 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, if (skb->data[0] == LOWPAN_DISPATCH_IPV6) { /* Pull off the 1-byte of 6lowpan header. */ skb_pull(skb, 1); - skb_reset_network_header(skb); - skb_set_transport_header(skb, sizeof(struct ipv6hdr)); lowpan_give_skb_to_devices(skb); } else { -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 13/17] 6lowpan: fix fragmentation on sending side
This patch fix the fragmentation on sending side according to rfc4944. Also add improvement to use the full payload of a PDU which calculate the nearest divided to 8 payload length for the fragmentation datagram offset attribute. Signed-off-by: Alexander Aring --- include/net/ieee802154_netdev.h | 2 ++ net/ieee802154/6lowpan.c| 41 +++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h index 8196d5d..f93296d 100644 --- a/include/net/ieee802154_netdev.h +++ b/include/net/ieee802154_netdev.h @@ -39,6 +39,8 @@ struct ieee802154_mac_cb { struct ieee802154_addr da; u8 flags; u8 seq; + u16 dgram_size; + u16 dgram_offset; }; static inline struct ieee802154_mac_cb *mac_cb(struct sk_buff *skb) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 448cc75..4c2072d 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -374,6 +374,7 @@ lowpan_compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb) memcpy(*hc06_ptr, &uh->check, 2); *hc06_ptr += 2; + mac_cb(skb)->dgram_offset += sizeof(struct udphdr); /* skip the UDP header */ skb_pull(skb, sizeof(struct udphdr)); } @@ -485,6 +486,7 @@ static int lowpan_header_create(struct sk_buff *skb, if (type != ETH_P_IPV6) return 0; + mac_cb(skb)->dgram_offset = 0; hdr = ipv6_hdr(skb); hc06_ptr = head + 2; @@ -654,6 +656,11 @@ static int lowpan_header_create(struct sk_buff *skb, head[0] = iphc0; head[1] = iphc1; + /* Before replace ipv6hdr to 6lowpan header we save the dgram_size */ + mac_cb(skb)->dgram_size = ntohs(hdr->payload_len) + + sizeof(struct ipv6hdr); + mac_cb(skb)->dgram_offset += sizeof(struct ipv6hdr); + skb_pull(skb, sizeof(struct ipv6hdr)); skb_reset_transport_header(skb); memcpy(skb_push(skb, hc06_ptr - head), head, hc06_ptr - head); @@ -1103,44 +1110,57 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, static int lowpan_skb_fragmentation(struct sk_buff *skb, struct net_device *dev) { - int err, header_length, payload_length, tag, offset = 0; + int err, header_length, payload_length, tag, dgram_size, + dgram_offset, lowpan_size, frag_plen, offset = 0; u8 head[5]; header_length = skb->mac_len; payload_length = skb->len - header_length; tag = lowpan_dev_info(dev)->fragment_tag++; + lowpan_size = skb->transport_header - skb->network_header; + dgram_size = mac_cb(skb)->dgram_size; /* first fragment header */ - head[0] = LOWPAN_DISPATCH_FRAG1 | ((payload_length >> 8) & 0x7); - head[1] = payload_length & 0xff; + head[0] = LOWPAN_DISPATCH_FRAG1 | ((dgram_size >> 8) & 0x7); + head[1] = dgram_size & 0xff; head[2] = tag >> 8; head[3] = tag & 0xff; - err = lowpan_fragment_xmit(skb, head, header_length, LOWPAN_FRAG_SIZE, - 0, LOWPAN_DISPATCH_FRAG1); + /* calc the nearest payload length(divided to 8) for first fragment +* which fits into a IEEE802154_MTU +*/ + frag_plen = round_down(IEEE802154_MTU - header_length - + LOWPAN_FRAG1_HEAD_SIZE - lowpan_size - + IEEE802154_MFR_SIZE, 8); + err = lowpan_fragment_xmit(skb, head, header_length, + frag_plen + lowpan_size, 0, LOWPAN_DISPATCH_FRAG1); if (err) { pr_debug("%s unable to send FRAG1 packet (tag: %d)", __func__, tag); goto exit; } - offset = LOWPAN_FRAG_SIZE; + offset = lowpan_size + frag_plen; + dgram_offset = mac_cb(skb)->dgram_offset + frag_plen; /* next fragment header */ head[0] &= ~LOWPAN_DISPATCH_FRAG1; head[0] |= LOWPAN_DISPATCH_FRAGN; + frag_plen = round_down(IEEE802154_MTU - header_length - + LOWPAN_FRAGN_HEAD_SIZE - IEEE802154_MFR_SIZE, 8); + while (payload_length - offset > 0) { - int len = LOWPAN_FRAG_SIZE; + int len = frag_plen; - head[4] = offset / 8; + head[4] = dgram_offset / 8; if (payload_length - offset < len) len = payload_length - offset; - err = lowpan_fragment_xmit(skb, head, header_length, - len, offset, LOWPAN_DISPATCH_FRAGN); + err = lowpan_fragment_xmit(skb, head, header_length, len, + offset, LOWPAN_DISPATCH_FRAGN); if (err) { pr_debug("%s unable to send a subsequent FRAGN packet " "(tag: %d, offset: %d", __func__, tag, offset); @@ -1148,6 +1168,7
[Linux-zigbee-devel] [PATCH net-next 04/17] 6lowpan: set and use mac_len for mac header length
Set the mac header length while creating the 802.15.4 mac header. Drop the function for recalculate mac header length in upper layers which was static and works for intra pan communication only. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 13 + net/mac802154/wpan.c | 2 ++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 0dc27ec..946b6b4 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -1071,17 +1071,6 @@ static int lowpan_set_address(struct net_device *dev, void *p) return 0; } -static int lowpan_get_mac_header_length(struct sk_buff *skb) -{ - /* -* Currently long addressing mode is supported only, so the overall -* header size is 21: -* FC SeqNum DPAN DA SA Sec -* 2 + 1 + 2 + 8 + 8 + 0 = 21 -*/ - return 21; -} - static int lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, int mlen, int plen, int offset, int type) @@ -1123,7 +1112,7 @@ lowpan_skb_fragmentation(struct sk_buff *skb, struct net_device *dev) int err, header_length, payload_length, tag, offset = 0; u8 head[5]; - header_length = lowpan_get_mac_header_length(skb); + header_length = skb->mac_len; payload_length = skb->len - header_length; tag = lowpan_dev_info(dev)->fragment_tag++; diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c index 78b0a33..b787887 100644 --- a/net/mac802154/wpan.c +++ b/net/mac802154/wpan.c @@ -209,6 +209,8 @@ static int mac802154_header_create(struct sk_buff *skb, head[1] = fc >> 8; memcpy(skb_push(skb, pos), head, pos); + skb_reset_mac_header(skb); + skb->mac_len = pos; return pos; } -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
[Linux-zigbee-devel] [PATCH net-next 07/17] 6lowpan: use netdev_alloc_skb instead dev_alloc_skb
This patch uses the netdev_alloc_skb instead dev_alloc_skb function. Also dropping the assign to skb->dev to netdev. Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 1dd690a..c458ac2 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -1085,12 +1085,12 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, lowpan_raw_dump_inline(__func__, "6lowpan fragment header", head, hlen); - frag = dev_alloc_skb(hlen + mlen + plen + IEEE802154_MFR_SIZE); + frag = netdev_alloc_skb(skb->dev, hlen + mlen + + plen + IEEE802154_MFR_SIZE); if (!frag) return -ENOMEM; frag->priority = skb->priority; - frag->dev = skb->dev; /* copy header, MFR and payload */ memcpy(skb_put(frag, mlen), skb->data, mlen); -- 1.8.4 -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel
Re: [Linux-zigbee-devel] [PATCH net-next 14/17] 6lowpan: fix fragmentation on receiving side
On Sun, Oct 13, 2013 at 03:46:47PM +0200, Alexander Aring wrote: > This patch fixes the fragmentation of receiving 6lowpan packets. > The current fragmentation isn't rfc4944 compatible. > > Signed-off-by: Alexander Aring > --- > net/ieee802154/6lowpan.c | 268 > +++ > 1 file changed, 154 insertions(+), 114 deletions(-) > > diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c > index 4c2072d..6df928f 100644 > --- a/net/ieee802154/6lowpan.c > +++ b/net/ieee802154/6lowpan.c > @@ -402,7 +402,8 @@ static inline int lowpan_fetch_skb_u16(struct sk_buff > *skb, u16 *val) > } > > static int > -lowpan_uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh) > +lowpan_uncompress_udp_header(struct sk_buff *skb, > + struct udphdr *uh, size_t udplen) > { > u8 tmp; > > @@ -456,7 +457,11 @@ lowpan_uncompress_udp_header(struct sk_buff *skb, struct > udphdr *uh) >* here, we obtain the hint from the remaining size of the >* frame ... > +} > + > +static int lowpan_check_frag_complete(struct lowpan_fragment *frame) > +{ > + int ret = 0; > + > + if (frame->bytes_rcv != frame->length) > + return ret; > + > + list_del(&frame->list); > + del_timer_sync(&frame->timer); > + > + ret = lowpan_give_skb_to_devices(frame->skb); if (ret != NET_RX_SUCCESS) dev_kfree_skb(frame->skb); jsut added here, because we didn't clean up the frame->skb on error. > + kfree(frame); > + return ret; > +} > + > static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, > - struct packet_type *pt, struct net_device *orig_dev) > + struct packet_type *pt, struct net_device *orig_dev) > { > + int ret; > + struct lowpan_fragment *frame; > + u16 d_tag, d_size; -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk ___ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel