diff options
| author | David S. Miller <davem@davemloft.net> | 2013-10-30 17:18:57 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-10-30 17:18:57 -0400 |
| commit | 8715fb364f87329ae52a03935942b6f0ee5482fe (patch) | |
| tree | 6483821dfea97939caae9b0136884a12d2bd39f7 | |
| parent | ba4865027c11d7ac8e5a33e0624dd415caab2027 (diff) | |
| parent | 3582b900ad2c1e218e4963060ba6dcf757cb702e (diff) | |
Merge branch '6lowpan'
Alexander Aring says:
====================
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.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/ieee802154/6lowpan.c | 32 | ||||
| -rw-r--r-- | net/mac802154/wpan.c | 2 |
2 files changed, 13 insertions, 21 deletions
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index fde90e63027d..9497c6f3276b 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c | |||
| @@ -654,7 +654,9 @@ static int lowpan_header_create(struct sk_buff *skb, | |||
| 654 | head[1] = iphc1; | 654 | head[1] = iphc1; |
| 655 | 655 | ||
| 656 | skb_pull(skb, sizeof(struct ipv6hdr)); | 656 | skb_pull(skb, sizeof(struct ipv6hdr)); |
| 657 | skb_reset_transport_header(skb); | ||
| 657 | memcpy(skb_push(skb, hc06_ptr - head), head, hc06_ptr - head); | 658 | memcpy(skb_push(skb, hc06_ptr - head), head, hc06_ptr - head); |
| 659 | skb_reset_network_header(skb); | ||
| 658 | 660 | ||
| 659 | lowpan_raw_dump_table(__func__, "raw skb data dump", skb->data, | 661 | lowpan_raw_dump_table(__func__, "raw skb data dump", skb->data, |
| 660 | skb->len); | 662 | skb->len); |
| @@ -737,7 +739,6 @@ static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr) | |||
| 737 | return -ENOMEM; | 739 | return -ENOMEM; |
| 738 | 740 | ||
| 739 | skb_push(new, sizeof(struct ipv6hdr)); | 741 | skb_push(new, sizeof(struct ipv6hdr)); |
| 740 | skb_reset_network_header(new); | ||
| 741 | skb_copy_to_linear_data(new, hdr, sizeof(struct ipv6hdr)); | 742 | skb_copy_to_linear_data(new, hdr, sizeof(struct ipv6hdr)); |
| 742 | 743 | ||
| 743 | new->protocol = htons(ETH_P_IPV6); | 744 | new->protocol = htons(ETH_P_IPV6); |
| @@ -1059,7 +1060,6 @@ lowpan_process_data(struct sk_buff *skb) | |||
| 1059 | skb = new; | 1060 | skb = new; |
| 1060 | 1061 | ||
| 1061 | skb_push(skb, sizeof(struct udphdr)); | 1062 | skb_push(skb, sizeof(struct udphdr)); |
| 1062 | skb_reset_transport_header(skb); | ||
| 1063 | skb_copy_to_linear_data(skb, &uh, sizeof(struct udphdr)); | 1063 | skb_copy_to_linear_data(skb, &uh, sizeof(struct udphdr)); |
| 1064 | 1064 | ||
| 1065 | lowpan_raw_dump_table(__func__, "raw UDP header dump", | 1065 | lowpan_raw_dump_table(__func__, "raw UDP header dump", |
| @@ -1102,17 +1102,6 @@ static int lowpan_set_address(struct net_device *dev, void *p) | |||
| 1102 | return 0; | 1102 | return 0; |
| 1103 | } | 1103 | } |
| 1104 | 1104 | ||
| 1105 | static int lowpan_get_mac_header_length(struct sk_buff *skb) | ||
| 1106 | { | ||
| 1107 | /* | ||
| 1108 | * Currently long addressing mode is supported only, so the overall | ||
| 1109 | * header size is 21: | ||
| 1110 | * FC SeqNum DPAN DA SA Sec | ||
| 1111 | * 2 + 1 + 2 + 8 + 8 + 0 = 21 | ||
| 1112 | */ | ||
| 1113 | return 21; | ||
| 1114 | } | ||
| 1115 | |||
| 1116 | static int | 1105 | static int |
| 1117 | lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, | 1106 | lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, |
| 1118 | int mlen, int plen, int offset, int type) | 1107 | int mlen, int plen, int offset, int type) |
| @@ -1133,12 +1122,15 @@ lowpan_fragment_xmit(struct sk_buff *skb, u8 *head, | |||
| 1133 | frag->priority = skb->priority; | 1122 | frag->priority = skb->priority; |
| 1134 | 1123 | ||
| 1135 | /* copy header, MFR and payload */ | 1124 | /* copy header, MFR and payload */ |
| 1136 | memcpy(skb_put(frag, mlen), skb->data, mlen); | 1125 | skb_put(frag, mlen); |
| 1137 | memcpy(skb_put(frag, hlen), head, hlen); | 1126 | skb_copy_to_linear_data(frag, skb_mac_header(skb), mlen); |
| 1127 | |||
| 1128 | skb_put(frag, hlen); | ||
| 1129 | skb_copy_to_linear_data_offset(frag, mlen, head, hlen); | ||
| 1138 | 1130 | ||
| 1139 | if (plen) | 1131 | skb_put(frag, plen); |
| 1140 | skb_copy_from_linear_data_offset(skb, offset + mlen, | 1132 | skb_copy_to_linear_data_offset(frag, mlen + hlen, |
| 1141 | skb_put(frag, plen), plen); | 1133 | skb_network_header(skb) + offset, plen); |
| 1142 | 1134 | ||
| 1143 | lowpan_raw_dump_table(__func__, " raw fragment dump", frag->data, | 1135 | lowpan_raw_dump_table(__func__, " raw fragment dump", frag->data, |
| 1144 | frag->len); | 1136 | frag->len); |
| @@ -1152,7 +1144,7 @@ lowpan_skb_fragmentation(struct sk_buff *skb, struct net_device *dev) | |||
| 1152 | int err, header_length, payload_length, tag, offset = 0; | 1144 | int err, header_length, payload_length, tag, offset = 0; |
| 1153 | u8 head[5]; | 1145 | u8 head[5]; |
| 1154 | 1146 | ||
| 1155 | header_length = lowpan_get_mac_header_length(skb); | 1147 | header_length = skb->mac_len; |
| 1156 | payload_length = skb->len - header_length; | 1148 | payload_length = skb->len - header_length; |
| 1157 | tag = lowpan_dev_info(dev)->fragment_tag++; | 1149 | tag = lowpan_dev_info(dev)->fragment_tag++; |
| 1158 | 1150 | ||
| @@ -1323,8 +1315,6 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 1323 | 1315 | ||
| 1324 | /* Pull off the 1-byte of 6lowpan header. */ | 1316 | /* Pull off the 1-byte of 6lowpan header. */ |
| 1325 | skb_pull(local_skb, 1); | 1317 | skb_pull(local_skb, 1); |
| 1326 | skb_reset_network_header(local_skb); | ||
| 1327 | skb_set_transport_header(local_skb, sizeof(struct ipv6hdr)); | ||
| 1328 | 1318 | ||
| 1329 | lowpan_give_skb_to_devices(local_skb); | 1319 | lowpan_give_skb_to_devices(local_skb); |
| 1330 | 1320 | ||
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c index 2ca2f4dceab7..e24bcf977296 100644 --- a/net/mac802154/wpan.c +++ b/net/mac802154/wpan.c | |||
| @@ -208,6 +208,8 @@ static int mac802154_header_create(struct sk_buff *skb, | |||
| 208 | head[1] = fc >> 8; | 208 | head[1] = fc >> 8; |
| 209 | 209 | ||
| 210 | memcpy(skb_push(skb, pos), head, pos); | 210 | memcpy(skb_push(skb, pos), head, pos); |
| 211 | skb_reset_mac_header(skb); | ||
| 212 | skb->mac_len = pos; | ||
| 211 | 213 | ||
| 212 | return pos; | 214 | return pos; |
| 213 | } | 215 | } |
