diff options
author | Sven Eckelmann <sven@narfation.org> | 2012-11-04 11:11:45 -0500 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-11-07 14:00:16 -0500 |
commit | 5b246574430f808e5b98ef40b8058bf5ac1df02d (patch) | |
tree | 7bc67e708ef2aee632de51020d7ba0d8c55a0883 /net/batman-adv | |
parent | 6f0a0986e328dd61610d898a09c9f4aa960ae64a (diff) |
batman-adv: Reserve extra bytes in skb for better alignment
The ethernet header is 14 bytes long. Therefore, the data after it is not 4
byte aligned and may cause problems on systems without unaligned data access.
Reserving NET_IP_ALIGN more byes can fix the misalignment of the ethernet
header.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 8 | ||||
-rw-r--r-- | net/batman-adv/icmp_socket.c | 4 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 20 | ||||
-rw-r--r-- | net/batman-adv/vis.c | 9 |
4 files changed, 22 insertions, 19 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 75403a491892..9f3925a85aab 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -411,9 +411,11 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, | |||
411 | 411 | ||
412 | if ((atomic_read(&bat_priv->aggregated_ogms)) && | 412 | if ((atomic_read(&bat_priv->aggregated_ogms)) && |
413 | (packet_len < BATADV_MAX_AGGREGATION_BYTES)) | 413 | (packet_len < BATADV_MAX_AGGREGATION_BYTES)) |
414 | skb_size = BATADV_MAX_AGGREGATION_BYTES + ETH_HLEN; | 414 | skb_size = BATADV_MAX_AGGREGATION_BYTES; |
415 | else | 415 | else |
416 | skb_size = packet_len + ETH_HLEN; | 416 | skb_size = packet_len; |
417 | |||
418 | skb_size += ETH_HLEN + NET_IP_ALIGN; | ||
417 | 419 | ||
418 | forw_packet_aggr->skb = dev_alloc_skb(skb_size); | 420 | forw_packet_aggr->skb = dev_alloc_skb(skb_size); |
419 | if (!forw_packet_aggr->skb) { | 421 | if (!forw_packet_aggr->skb) { |
@@ -422,7 +424,7 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, | |||
422 | kfree(forw_packet_aggr); | 424 | kfree(forw_packet_aggr); |
423 | goto out; | 425 | goto out; |
424 | } | 426 | } |
425 | skb_reserve(forw_packet_aggr->skb, ETH_HLEN); | 427 | skb_reserve(forw_packet_aggr->skb, ETH_HLEN + NET_IP_ALIGN); |
426 | 428 | ||
427 | INIT_HLIST_NODE(&forw_packet_aggr->list); | 429 | INIT_HLIST_NODE(&forw_packet_aggr->list); |
428 | 430 | ||
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index 5874c0e84846..87ca8095b011 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c | |||
@@ -177,13 +177,13 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff, | |||
177 | if (len >= sizeof(struct batadv_icmp_packet_rr)) | 177 | if (len >= sizeof(struct batadv_icmp_packet_rr)) |
178 | packet_len = sizeof(struct batadv_icmp_packet_rr); | 178 | packet_len = sizeof(struct batadv_icmp_packet_rr); |
179 | 179 | ||
180 | skb = dev_alloc_skb(packet_len + ETH_HLEN); | 180 | skb = dev_alloc_skb(packet_len + ETH_HLEN + NET_IP_ALIGN); |
181 | if (!skb) { | 181 | if (!skb) { |
182 | len = -ENOMEM; | 182 | len = -ENOMEM; |
183 | goto out; | 183 | goto out; |
184 | } | 184 | } |
185 | 185 | ||
186 | skb_reserve(skb, ETH_HLEN); | 186 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); |
187 | icmp_packet = (struct batadv_icmp_packet_rr *)skb_put(skb, packet_len); | 187 | icmp_packet = (struct batadv_icmp_packet_rr *)skb_put(skb, packet_len); |
188 | 188 | ||
189 | if (copy_from_user(icmp_packet, buff, packet_len)) { | 189 | if (copy_from_user(icmp_packet, buff, packet_len)) { |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index a570d957a5a0..f8b9c32c29a5 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -1472,11 +1472,11 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, | |||
1472 | tt_tot = tt_len / sizeof(struct batadv_tt_change); | 1472 | tt_tot = tt_len / sizeof(struct batadv_tt_change); |
1473 | 1473 | ||
1474 | len = tt_query_size + tt_len; | 1474 | len = tt_query_size + tt_len; |
1475 | skb = dev_alloc_skb(len + ETH_HLEN); | 1475 | skb = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN); |
1476 | if (!skb) | 1476 | if (!skb) |
1477 | goto out; | 1477 | goto out; |
1478 | 1478 | ||
1479 | skb_reserve(skb, ETH_HLEN); | 1479 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); |
1480 | tt_response = (struct batadv_tt_query_packet *)skb_put(skb, len); | 1480 | tt_response = (struct batadv_tt_query_packet *)skb_put(skb, len); |
1481 | tt_response->ttvn = ttvn; | 1481 | tt_response->ttvn = ttvn; |
1482 | 1482 | ||
@@ -1538,11 +1538,11 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv, | |||
1538 | if (!tt_req_node) | 1538 | if (!tt_req_node) |
1539 | goto out; | 1539 | goto out; |
1540 | 1540 | ||
1541 | skb = dev_alloc_skb(sizeof(*tt_request) + ETH_HLEN); | 1541 | skb = dev_alloc_skb(sizeof(*tt_request) + ETH_HLEN + NET_IP_ALIGN); |
1542 | if (!skb) | 1542 | if (!skb) |
1543 | goto out; | 1543 | goto out; |
1544 | 1544 | ||
1545 | skb_reserve(skb, ETH_HLEN); | 1545 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); |
1546 | 1546 | ||
1547 | tt_req_len = sizeof(*tt_request); | 1547 | tt_req_len = sizeof(*tt_request); |
1548 | tt_request = (struct batadv_tt_query_packet *)skb_put(skb, tt_req_len); | 1548 | tt_request = (struct batadv_tt_query_packet *)skb_put(skb, tt_req_len); |
@@ -1653,11 +1653,11 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1653 | tt_tot = tt_len / sizeof(struct batadv_tt_change); | 1653 | tt_tot = tt_len / sizeof(struct batadv_tt_change); |
1654 | 1654 | ||
1655 | len = sizeof(*tt_response) + tt_len; | 1655 | len = sizeof(*tt_response) + tt_len; |
1656 | skb = dev_alloc_skb(len + ETH_HLEN); | 1656 | skb = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN); |
1657 | if (!skb) | 1657 | if (!skb) |
1658 | goto unlock; | 1658 | goto unlock; |
1659 | 1659 | ||
1660 | skb_reserve(skb, ETH_HLEN); | 1660 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); |
1661 | packet_pos = skb_put(skb, len); | 1661 | packet_pos = skb_put(skb, len); |
1662 | tt_response = (struct batadv_tt_query_packet *)packet_pos; | 1662 | tt_response = (struct batadv_tt_query_packet *)packet_pos; |
1663 | tt_response->ttvn = req_ttvn; | 1663 | tt_response->ttvn = req_ttvn; |
@@ -1780,11 +1780,11 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1780 | tt_tot = tt_len / sizeof(struct batadv_tt_change); | 1780 | tt_tot = tt_len / sizeof(struct batadv_tt_change); |
1781 | 1781 | ||
1782 | len = sizeof(*tt_response) + tt_len; | 1782 | len = sizeof(*tt_response) + tt_len; |
1783 | skb = dev_alloc_skb(len + ETH_HLEN); | 1783 | skb = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN); |
1784 | if (!skb) | 1784 | if (!skb) |
1785 | goto unlock; | 1785 | goto unlock; |
1786 | 1786 | ||
1787 | skb_reserve(skb, ETH_HLEN); | 1787 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); |
1788 | packet_pos = skb_put(skb, len); | 1788 | packet_pos = skb_put(skb, len); |
1789 | tt_response = (struct batadv_tt_query_packet *)packet_pos; | 1789 | tt_response = (struct batadv_tt_query_packet *)packet_pos; |
1790 | tt_response->ttvn = req_ttvn; | 1790 | tt_response->ttvn = req_ttvn; |
@@ -2118,11 +2118,11 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client, | |||
2118 | if (!batadv_tt_check_roam_count(bat_priv, client)) | 2118 | if (!batadv_tt_check_roam_count(bat_priv, client)) |
2119 | goto out; | 2119 | goto out; |
2120 | 2120 | ||
2121 | skb = dev_alloc_skb(sizeof(*roam_adv_packet) + ETH_HLEN); | 2121 | skb = dev_alloc_skb(sizeof(*roam_adv_packet) + ETH_HLEN + NET_IP_ALIGN); |
2122 | if (!skb) | 2122 | if (!skb) |
2123 | goto out; | 2123 | goto out; |
2124 | 2124 | ||
2125 | skb_reserve(skb, ETH_HLEN); | 2125 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); |
2126 | 2126 | ||
2127 | roam_adv_packet = (struct batadv_roam_adv_packet *)skb_put(skb, len); | 2127 | roam_adv_packet = (struct batadv_roam_adv_packet *)skb_put(skb, len); |
2128 | 2128 | ||
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index 5abd1454fb07..ad14a6c91d6a 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -396,12 +396,12 @@ batadv_add_packet(struct batadv_priv *bat_priv, | |||
396 | return NULL; | 396 | return NULL; |
397 | 397 | ||
398 | len = sizeof(*packet) + vis_info_len; | 398 | len = sizeof(*packet) + vis_info_len; |
399 | info->skb_packet = dev_alloc_skb(len + ETH_HLEN); | 399 | info->skb_packet = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN); |
400 | if (!info->skb_packet) { | 400 | if (!info->skb_packet) { |
401 | kfree(info); | 401 | kfree(info); |
402 | return NULL; | 402 | return NULL; |
403 | } | 403 | } |
404 | skb_reserve(info->skb_packet, ETH_HLEN); | 404 | skb_reserve(info->skb_packet, ETH_HLEN + NET_IP_ALIGN); |
405 | packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len); | 405 | packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len); |
406 | 406 | ||
407 | kref_init(&info->refcount); | 407 | kref_init(&info->refcount); |
@@ -873,12 +873,13 @@ int batadv_vis_init(struct batadv_priv *bat_priv) | |||
873 | if (!bat_priv->vis.my_info) | 873 | if (!bat_priv->vis.my_info) |
874 | goto err; | 874 | goto err; |
875 | 875 | ||
876 | len = sizeof(*packet) + BATADV_MAX_VIS_PACKET_SIZE + ETH_HLEN; | 876 | len = sizeof(*packet) + BATADV_MAX_VIS_PACKET_SIZE; |
877 | len += ETH_HLEN + NET_IP_ALIGN; | ||
877 | bat_priv->vis.my_info->skb_packet = dev_alloc_skb(len); | 878 | bat_priv->vis.my_info->skb_packet = dev_alloc_skb(len); |
878 | if (!bat_priv->vis.my_info->skb_packet) | 879 | if (!bat_priv->vis.my_info->skb_packet) |
879 | goto free_info; | 880 | goto free_info; |
880 | 881 | ||
881 | skb_reserve(bat_priv->vis.my_info->skb_packet, ETH_HLEN); | 882 | skb_reserve(bat_priv->vis.my_info->skb_packet, ETH_HLEN + NET_IP_ALIGN); |
882 | tmp_skb = bat_priv->vis.my_info->skb_packet; | 883 | tmp_skb = bat_priv->vis.my_info->skb_packet; |
883 | packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet)); | 884 | packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet)); |
884 | 885 | ||