batman-adv: don't deal with NET_IP_ALIGN manually
authorAntonio Quartulli <ordex@autistici.org>
Tue, 2 Apr 2013 20:28:44 +0000 (22:28 +0200)
committerAntonio Quartulli <ordex@autistici.org>
Wed, 29 May 2013 00:44:54 +0000 (02:44 +0200)
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>
net/batman-adv/bat_iv_ogm.c
net/batman-adv/icmp_socket.c
net/batman-adv/translation-table.c
net/batman-adv/vis.c

index 42b7a94d61b368ce3e70eee976e4fa1a573e3b56..5b0a043c47c857dfa22c8f54a6a042433be9d03d 100644 (file)
@@ -453,16 +453,16 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
        else
                skb_size = packet_len;
 
-       skb_size += ETH_HLEN + NET_IP_ALIGN;
+       skb_size += ETH_HLEN;
 
-       forw_packet_aggr->skb = dev_alloc_skb(skb_size);
+       forw_packet_aggr->skb = netdev_alloc_skb_ip_align(NULL, skb_size);
        if (!forw_packet_aggr->skb) {
                if (!own_packet)
                        atomic_inc(&bat_priv->batman_queue_left);
                kfree(forw_packet_aggr);
                goto out;
        }
-       skb_reserve(forw_packet_aggr->skb, ETH_HLEN + NET_IP_ALIGN);
+       skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
 
        INIT_HLIST_NODE(&forw_packet_aggr->list);
 
index 0ba6c899b2d3512b9dd0bc0c4292fcf08d1f0154..b27508b8085cd84727bf89c434b0b56adcdcd87f 100644 (file)
@@ -177,13 +177,13 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
        if (len >= sizeof(struct batadv_icmp_packet_rr))
                packet_len = sizeof(struct batadv_icmp_packet_rr);
 
-       skb = dev_alloc_skb(packet_len + ETH_HLEN + NET_IP_ALIGN);
+       skb = netdev_alloc_skb_ip_align(NULL, packet_len + ETH_HLEN);
        if (!skb) {
                len = -ENOMEM;
                goto out;
        }
 
-       skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN);
+       skb_reserve(skb, ETH_HLEN);
        icmp_packet = (struct batadv_icmp_packet_rr *)skb_put(skb, packet_len);
 
        if (copy_from_user(icmp_packet, buff, packet_len)) {
index d35b73904e0411a0cd4a2884fdb73b605b97a4d1..52808c4ae081c620489bc1797cd45fffdd94bcf0 100644 (file)
@@ -1607,11 +1607,11 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
        tt_tot = tt_len / sizeof(struct batadv_tt_change);
 
        len = tt_query_size + tt_len;
-       skb = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN);
+       skb = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN);
        if (!skb)
                goto out;
 
-       skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN);
+       skb_reserve(skb, ETH_HLEN);
        tt_response = (struct batadv_tt_query_packet *)skb_put(skb, len);
        tt_response->ttvn = ttvn;
 
@@ -1672,11 +1672,11 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv,
        if (!tt_req_node)
                goto out;
 
-       skb = dev_alloc_skb(sizeof(*tt_request) + ETH_HLEN + NET_IP_ALIGN);
+       skb = netdev_alloc_skb_ip_align(NULL, sizeof(*tt_request) + ETH_HLEN);
        if (!skb)
                goto out;
 
-       skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN);
+       skb_reserve(skb, ETH_HLEN);
 
        tt_req_len = sizeof(*tt_request);
        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,
                tt_tot = tt_len / sizeof(struct batadv_tt_change);
 
                len = sizeof(*tt_response) + tt_len;
-               skb = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN);
+               skb = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN);
                if (!skb)
                        goto unlock;
 
-               skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN);
+               skb_reserve(skb, ETH_HLEN);
                packet_pos = skb_put(skb, len);
                tt_response = (struct batadv_tt_query_packet *)packet_pos;
                tt_response->ttvn = req_ttvn;
@@ -1885,11 +1885,11 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv,
                tt_tot = tt_len / sizeof(struct batadv_tt_change);
 
                len = sizeof(*tt_response) + tt_len;
-               skb = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN);
+               skb = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN);
                if (!skb)
                        goto unlock;
 
-               skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN);
+               skb_reserve(skb, ETH_HLEN);
                packet_pos = skb_put(skb, len);
                tt_response = (struct batadv_tt_query_packet *)packet_pos;
                tt_response->ttvn = req_ttvn;
@@ -2219,11 +2219,11 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client,
        if (!batadv_tt_check_roam_count(bat_priv, client))
                goto out;
 
-       skb = dev_alloc_skb(sizeof(*roam_adv_packet) + ETH_HLEN + NET_IP_ALIGN);
+       skb = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN);
        if (!skb)
                goto out;
 
-       skb_reserve(skb, ETH_HLEN + NET_IP_ALIGN);
+       skb_reserve(skb, ETH_HLEN);
 
        roam_adv_packet = (struct batadv_roam_adv_packet *)skb_put(skb, len);
 
index 1625e5793a895d02aec97966f901ccfb8a29e4ab..94eaeb521c17f62a5e455006cec1f261f6d5645d 100644 (file)
@@ -392,12 +392,12 @@ batadv_add_packet(struct batadv_priv *bat_priv,
                return NULL;
 
        len = sizeof(*packet) + vis_info_len;
-       info->skb_packet = dev_alloc_skb(len + ETH_HLEN + NET_IP_ALIGN);
+       info->skb_packet = netdev_alloc_skb_ip_align(NULL, len + ETH_HLEN);
        if (!info->skb_packet) {
                kfree(info);
                return NULL;
        }
-       skb_reserve(info->skb_packet, ETH_HLEN + NET_IP_ALIGN);
+       skb_reserve(info->skb_packet, ETH_HLEN);
        packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len);
 
        kref_init(&info->refcount);
@@ -854,13 +854,13 @@ int batadv_vis_init(struct batadv_priv *bat_priv)
        if (!bat_priv->vis.my_info)
                goto err;
 
-       len = sizeof(*packet) + BATADV_MAX_VIS_PACKET_SIZE;
-       len += ETH_HLEN + NET_IP_ALIGN;
-       bat_priv->vis.my_info->skb_packet = dev_alloc_skb(len);
+       len = sizeof(*packet) + BATADV_MAX_VIS_PACKET_SIZE + ETH_HLEN;
+       bat_priv->vis.my_info->skb_packet = netdev_alloc_skb_ip_align(NULL,
+                                                                     len);
        if (!bat_priv->vis.my_info->skb_packet)
                goto free_info;
 
-       skb_reserve(bat_priv->vis.my_info->skb_packet, ETH_HLEN + NET_IP_ALIGN);
+       skb_reserve(bat_priv->vis.my_info->skb_packet, ETH_HLEN);
        tmp_skb = bat_priv->vis.my_info->skb_packet;
        packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet));