diff options
author | Antonio Quartulli <ordex@autistici.org> | 2013-04-02 16:28:44 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2013-05-28 20:44:54 -0400 |
commit | 41ab6c4891ed4cdd855ae569924acb1da424a614 (patch) | |
tree | 073d8ba7befde0fb1965f0562f63dfb598d8210d /net/batman-adv | |
parent | 3abe4adbfb293e37d2d6f4fe22366534dc2675d9 (diff) |
batman-adv: don't deal with NET_IP_ALIGN manually
Instead of dealing with NET_IP_ALIGN during allocation and
headroom reservation, it is possible to use
netdev_alloc_skb_ip_align() which transparently allocate
and reserve the correct amount of data
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 6 | ||||
-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 | 12 |
4 files changed, 21 insertions, 21 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 42b7a94d61b3..5b0a043c47c8 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -453,16 +453,16 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, | |||
453 | else | 453 | else |
454 | skb_size = packet_len; | 454 | skb_size = packet_len; |
455 | 455 | ||
456 | skb_size += ETH_HLEN + NET_IP_ALIGN; | 456 | skb_size += ETH_HLEN; |
457 | 457 | ||
458 | forw_packet_aggr->skb = dev_alloc_skb(skb_size); | 458 | forw_packet_aggr->skb = netdev_alloc_skb_ip_align(NULL, skb_size); |
459 | if (!forw_packet_aggr->skb) { | 459 | if (!forw_packet_aggr->skb) { |
460 | if (!own_packet) | 460 | if (!own_packet) |
461 | atomic_inc(&bat_priv->batman_queue_left); | 461 | atomic_inc(&bat_priv->batman_queue_left); |
462 | kfree(forw_packet_aggr); | 462 | kfree(forw_packet_aggr); |
463 | goto out; | 463 | goto out; |
464 | } | 464 | } |
465 | skb_reserve(forw_packet_aggr->skb, ETH_HLEN + NET_IP_ALIGN); | 465 | skb_reserve(forw_packet_aggr->skb, ETH_HLEN); |
466 | 466 | ||
467 | INIT_HLIST_NODE(&forw_packet_aggr->list); | 467 | INIT_HLIST_NODE(&forw_packet_aggr->list); |
468 | 468 | ||
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index 0ba6c899b2d3..b27508b8085c 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 + NET_IP_ALIGN); | 180 | skb = netdev_alloc_skb_ip_align(NULL, packet_len + ETH_HLEN); |
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 + NET_IP_ALIGN); | 186 | skb_reserve(skb, ETH_HLEN); |
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 d35b73904e04..52808c4ae081 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -1607,11 +1607,11 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, | |||
1607 | tt_tot = tt_len / sizeof(struct batadv_tt_change); | 1607 | tt_tot = tt_len / sizeof(struct batadv_tt_change); |
1608 | 1608 | ||
1609 | len = tt_query_size + tt_len; | 1609 | len = tt_query_size + tt_len; |
1610 | skb = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN); | 1610 | skb = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN); |
1611 | if (!skb) | 1611 | if (!skb) |
1612 | goto out; | 1612 | goto out; |
1613 | 1613 | ||
1614 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); | 1614 | skb_reserve(skb, ETH_HLEN); |
1615 | tt_response = (struct batadv_tt_query_packet *)skb_put(skb, len); | 1615 | tt_response = (struct batadv_tt_query_packet *)skb_put(skb, len); |
1616 | tt_response->ttvn = ttvn; | 1616 | tt_response->ttvn = ttvn; |
1617 | 1617 | ||
@@ -1672,11 +1672,11 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv, | |||
1672 | if (!tt_req_node) | 1672 | if (!tt_req_node) |
1673 | goto out; | 1673 | goto out; |
1674 | 1674 | ||
1675 | skb = dev_alloc_skb(sizeof(*tt_request) + ETH_HLEN + NET_IP_ALIGN); | 1675 | skb = netdev_alloc_skb_ip_align(NULL, sizeof(*tt_request) + ETH_HLEN); |
1676 | if (!skb) | 1676 | if (!skb) |
1677 | goto out; | 1677 | goto out; |
1678 | 1678 | ||
1679 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); | 1679 | skb_reserve(skb, ETH_HLEN); |
1680 | 1680 | ||
1681 | tt_req_len = sizeof(*tt_request); | 1681 | tt_req_len = sizeof(*tt_request); |
1682 | tt_request = (struct batadv_tt_query_packet *)skb_put(skb, tt_req_len); | 1682 | tt_request = (struct batadv_tt_query_packet *)skb_put(skb, tt_req_len); |
@@ -1769,11 +1769,11 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1769 | tt_tot = tt_len / sizeof(struct batadv_tt_change); | 1769 | tt_tot = tt_len / sizeof(struct batadv_tt_change); |
1770 | 1770 | ||
1771 | len = sizeof(*tt_response) + tt_len; | 1771 | len = sizeof(*tt_response) + tt_len; |
1772 | skb = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN); | 1772 | skb = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN); |
1773 | if (!skb) | 1773 | if (!skb) |
1774 | goto unlock; | 1774 | goto unlock; |
1775 | 1775 | ||
1776 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); | 1776 | skb_reserve(skb, ETH_HLEN); |
1777 | packet_pos = skb_put(skb, len); | 1777 | packet_pos = skb_put(skb, len); |
1778 | tt_response = (struct batadv_tt_query_packet *)packet_pos; | 1778 | tt_response = (struct batadv_tt_query_packet *)packet_pos; |
1779 | tt_response->ttvn = req_ttvn; | 1779 | tt_response->ttvn = req_ttvn; |
@@ -1885,11 +1885,11 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1885 | tt_tot = tt_len / sizeof(struct batadv_tt_change); | 1885 | tt_tot = tt_len / sizeof(struct batadv_tt_change); |
1886 | 1886 | ||
1887 | len = sizeof(*tt_response) + tt_len; | 1887 | len = sizeof(*tt_response) + tt_len; |
1888 | skb = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN); | 1888 | skb = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN); |
1889 | if (!skb) | 1889 | if (!skb) |
1890 | goto unlock; | 1890 | goto unlock; |
1891 | 1891 | ||
1892 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); | 1892 | skb_reserve(skb, ETH_HLEN); |
1893 | packet_pos = skb_put(skb, len); | 1893 | packet_pos = skb_put(skb, len); |
1894 | tt_response = (struct batadv_tt_query_packet *)packet_pos; | 1894 | tt_response = (struct batadv_tt_query_packet *)packet_pos; |
1895 | tt_response->ttvn = req_ttvn; | 1895 | tt_response->ttvn = req_ttvn; |
@@ -2219,11 +2219,11 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client, | |||
2219 | if (!batadv_tt_check_roam_count(bat_priv, client)) | 2219 | if (!batadv_tt_check_roam_count(bat_priv, client)) |
2220 | goto out; | 2220 | goto out; |
2221 | 2221 | ||
2222 | skb = dev_alloc_skb(sizeof(*roam_adv_packet) + ETH_HLEN + NET_IP_ALIGN); | 2222 | skb = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN); |
2223 | if (!skb) | 2223 | if (!skb) |
2224 | goto out; | 2224 | goto out; |
2225 | 2225 | ||
2226 | skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN); | 2226 | skb_reserve(skb, ETH_HLEN); |
2227 | 2227 | ||
2228 | roam_adv_packet = (struct batadv_roam_adv_packet *)skb_put(skb, len); | 2228 | roam_adv_packet = (struct batadv_roam_adv_packet *)skb_put(skb, len); |
2229 | 2229 | ||
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index 1625e5793a89..94eaeb521c17 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -392,12 +392,12 @@ batadv_add_packet(struct batadv_priv *bat_priv, | |||
392 | return NULL; | 392 | return NULL; |
393 | 393 | ||
394 | len = sizeof(*packet) + vis_info_len; | 394 | len = sizeof(*packet) + vis_info_len; |
395 | info->skb_packet = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN); | 395 | info->skb_packet = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN); |
396 | if (!info->skb_packet) { | 396 | if (!info->skb_packet) { |
397 | kfree(info); | 397 | kfree(info); |
398 | return NULL; | 398 | return NULL; |
399 | } | 399 | } |
400 | skb_reserve(info->skb_packet, ETH_HLEN + NET_IP_ALIGN); | 400 | skb_reserve(info->skb_packet, ETH_HLEN); |
401 | packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len); | 401 | packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len); |
402 | 402 | ||
403 | kref_init(&info->refcount); | 403 | kref_init(&info->refcount); |
@@ -854,13 +854,13 @@ int batadv_vis_init(struct batadv_priv *bat_priv) | |||
854 | if (!bat_priv->vis.my_info) | 854 | if (!bat_priv->vis.my_info) |
855 | goto err; | 855 | goto err; |
856 | 856 | ||
857 | len = sizeof(*packet) + BATADV_MAX_VIS_PACKET_SIZE; | 857 | len = sizeof(*packet) + BATADV_MAX_VIS_PACKET_SIZE + ETH_HLEN; |
858 | len += ETH_HLEN + NET_IP_ALIGN; | 858 | bat_priv->vis.my_info->skb_packet = netdev_alloc_skb_ip_align(NULL, |
859 | bat_priv->vis.my_info->skb_packet = dev_alloc_skb(len); | 859 | len); |
860 | if (!bat_priv->vis.my_info->skb_packet) | 860 | if (!bat_priv->vis.my_info->skb_packet) |
861 | goto free_info; | 861 | goto free_info; |
862 | 862 | ||
863 | skb_reserve(bat_priv->vis.my_info->skb_packet, ETH_HLEN + NET_IP_ALIGN); | 863 | skb_reserve(bat_priv->vis.my_info->skb_packet, ETH_HLEN); |
864 | tmp_skb = bat_priv->vis.my_info->skb_packet; | 864 | tmp_skb = bat_priv->vis.my_info->skb_packet; |
865 | packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet)); | 865 | packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet)); |
866 | 866 | ||