* [PATCH net-next 0/4] 6lowpan: cleanup header creation
@ 2013-10-30 8:18 Alexander Aring
[not found] ` <1383121104-2515-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Alexander Aring @ 2013-10-30 8:18 UTC (permalink / raw)
To: alex.bluesman.smirnov
Cc: linux-zigbee-devel, werner, dbaryshkov, netdev, Alexander Aring
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(-)
--
1.8.4.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/4] 6lowpan: remove unnecessary set of headers
[not found] ` <1383121104-2515-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-10-30 8:18 ` Alexander Aring
2013-10-30 8:18 ` [PATCH net-next 2/4] 6lowpan: set and use mac_len for mac header length Alexander Aring
1 sibling, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2013-10-30 8:18 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
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.
Signed-off-by: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reviewed-by: Werner Almesberger <werner-SEdMjqphH88wryQfseakQg@public.gmane.org>
---
net/ieee802154/6lowpan.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index fde90e6..6d67784 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -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);
--
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/4] 6lowpan: set and use mac_len for mac header length
[not found] ` <1383121104-2515-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-30 8:18 ` [PATCH net-next 1/4] 6lowpan: remove unnecessary set of headers Alexander Aring
@ 2013-10-30 8:18 ` Alexander Aring
1 sibling, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2013-10-30 8:18 UTC (permalink / raw)
To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
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 <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reviewed-by: Werner Almesberger <werner-SEdMjqphH88wryQfseakQg@public.gmane.org>
---
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 6d67784..e6db1f5 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -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++;
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index 2ca2f4d..e24bcf9 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -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;
}
--
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 3/4] 6lowpan: set 6lowpan network and transport header
2013-10-30 8:18 [PATCH net-next 0/4] 6lowpan: cleanup header creation Alexander Aring
[not found] ` <1383121104-2515-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-10-30 8:18 ` Alexander Aring
2013-10-30 8:18 ` [PATCH net-next 4/4] 6lowpan: cleanup skb copy data Alexander Aring
2013-10-30 21:19 ` [PATCH net-next 0/4] 6lowpan: cleanup header creation David Miller
3 siblings, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2013-10-30 8:18 UTC (permalink / raw)
To: alex.bluesman.smirnov
Cc: linux-zigbee-devel, werner, dbaryshkov, netdev, Alexander Aring
This 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.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Acked-by: Werner Almesberger <werner@almesberger.net>
---
net/ieee802154/6lowpan.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index e6db1f5..58c07fd 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -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);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 4/4] 6lowpan: cleanup skb copy data
2013-10-30 8:18 [PATCH net-next 0/4] 6lowpan: cleanup header creation Alexander Aring
[not found] ` <1383121104-2515-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-30 8:18 ` [PATCH net-next 3/4] 6lowpan: set 6lowpan network and transport header Alexander Aring
@ 2013-10-30 8:18 ` Alexander Aring
2013-10-30 21:19 ` [PATCH net-next 0/4] 6lowpan: cleanup header creation David Miller
3 siblings, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2013-10-30 8:18 UTC (permalink / raw)
To: alex.bluesman.smirnov
Cc: linux-zigbee-devel, werner, dbaryshkov, netdev, Alexander Aring
This patch drops the direct 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 <alex.aring@gmail.com>
Reviewed-by: Werner Almesberger <werner@almesberger.net>
---
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 58c07fd..9497c6f 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -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);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/4] 6lowpan: cleanup header creation
2013-10-30 8:18 [PATCH net-next 0/4] 6lowpan: cleanup header creation Alexander Aring
` (2 preceding siblings ...)
2013-10-30 8:18 ` [PATCH net-next 4/4] 6lowpan: cleanup skb copy data Alexander Aring
@ 2013-10-30 21:19 ` David Miller
3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-10-30 21:19 UTC (permalink / raw)
To: alex.aring
Cc: alex.bluesman.smirnov, linux-zigbee-devel, werner, dbaryshkov,
netdev
From: Alexander Aring <alex.aring@gmail.com>
Date: Wed, 30 Oct 2013 09:18:20 +0100
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-10-30 21:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-30 8:18 [PATCH net-next 0/4] 6lowpan: cleanup header creation Alexander Aring
[not found] ` <1383121104-2515-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-30 8:18 ` [PATCH net-next 1/4] 6lowpan: remove unnecessary set of headers Alexander Aring
2013-10-30 8:18 ` [PATCH net-next 2/4] 6lowpan: set and use mac_len for mac header length Alexander Aring
2013-10-30 8:18 ` [PATCH net-next 3/4] 6lowpan: set 6lowpan network and transport header Alexander Aring
2013-10-30 8:18 ` [PATCH net-next 4/4] 6lowpan: cleanup skb copy data Alexander Aring
2013-10-30 21:19 ` [PATCH net-next 0/4] 6lowpan: cleanup header creation David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).