6lowpan: cleanup header creation
Subsystems (3)
Alexander Aring
maintainercover 6lowpan: cleanup header creation
This patch series cleanup the 6LoWPAN header creation and extend the use of skb_*_header functions.
Patch 2/4 fix issues of parsing the mac header. The ieee802.15.4 header has a dynamic size which depends on frame control bits. This patch replaces the static mac header len calculation with a dynamic one.
Alexander Aring (4):
6lowpan: remove unnecessary set of headers 6lowpan: set and use mac_len for mac header length 6lowpan: set 6lowpan network and transport header 6lowpan: cleanup skb copy data
net/ieee802154/6lowpan.c | 32 +++++++++++--------------------- net/mac802154/wpan.c | 2 ++ 2 files changed, 13 insertions(+), 21 deletions(-)
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1383121104-2515-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/4 6lowpan: remove unnecessary set of headers
On receiving side we don't need to set any headers in skb because the 6LoWPAN layer do not access it. Currently these values will set twice after calling netif_rx.
--- net/ieee802154/6lowpan.c | 4 ---- 1 file changed, 4 deletions(-)
net/ieee802154/6lowpan.c +0 -4
@@ -737,7 +737,6 @@ static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr)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 );
@@ -1059,7 +1058,6 @@ lowpan_process_data(struct sk_buff *skb) skb = new;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",
@@ -1323,8 +1321,6 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,/* 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);
Signature · 9 lines
1.8.4.2 ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
PATCH 2/4 6lowpan: set and use mac_len for mac header length
In reply to a message not in the archiveSet 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.
--- net/ieee802154/6lowpan.c | 13 +------------ net/mac802154/wpan.c | 2 ++ 2 files changed, 3 insertions(+), 12 deletions(-)
net/ieee802154/6lowpan.c +1 -12
@@ -1100,17 +1100,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)
@@ -1150,7 +1139,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++;
net/mac802154/wpan.c +2 -0
@@ -208,6 +208,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; }
Signature · 9 lines
1.8.4.2 ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
Alexander Aring
maintainerPATCH 3/4 6lowpan: set 6lowpan network and transport header
In reply to Alexander AringThis is necessary to access network header with the skb_network_header function instead of calculate the position with mac_len, etc. Do the same for the transport header, when we replace the IPv6 header with the 6LoWPAN header.
--- net/ieee802154/6lowpan.c | 2 ++ 1 file changed, 2 insertions(+)
net/ieee802154/6lowpan.c +2 -0
@@ -654,7 +654,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);
Signature · 1 line
1.8.4.2
Alexander Aring
maintainerPATCH 4/4 6lowpan: cleanup skb copy data
In reply to Alexander AringThis patch drops the direct memcpy on skb and uses the right skb memcpy functions. Also remove an unnecessary check if plen is non zero.
--- net/ieee802154/6lowpan.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
net/ieee802154/6lowpan.c +8 -5
@@ -1122,12 +1122,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);
Signature · 1 line
1.8.4.2
David Miller
maintainerFrom: Alexander Aring <[email protected]>
Date: Wed, 30 Oct 2013 09:18:20 +0100
Quoted 6 lines
This patch series cleanup the 6LoWPAN header creation and extend the use of skb_*_header functions.
Patch 2/4 fix issues of parsing the mac header. The ieee802.15.4 header has a dynamic size which depends on frame control bits. This patch replaces the static mac header len calculation with a dynamic one.
Series applied, thanks.