]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
batman-adv: use ETH_HLEN instead of sizeof(struct ethhdr)
authorAntonio Quartulli <ordex@autistici.org>
Sat, 18 Feb 2012 10:27:34 +0000 (11:27 +0100)
committerAntonio Quartulli <ordex@autistici.org>
Wed, 18 Apr 2012 07:54:01 +0000 (09:54 +0200)
Instead of using sizeof(struct ethhdr) it is strongly recommended to use the
kernel macro ETH_HLEN. This patch substitute each occurrence of the former
expressione with the latter one.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
net/batman-adv/bat_iv_ogm.c
net/batman-adv/bridge_loop_avoidance.c
net/batman-adv/hard-interface.c
net/batman-adv/icmp_socket.c
net/batman-adv/routing.c
net/batman-adv/send.c
net/batman-adv/soft-interface.c
net/batman-adv/types.h
net/batman-adv/vis.c

index 98f71827c7b3f605fa667f953578df6ed5e4d2b2..d7fa8afd7ff8f1d36ec7c20cd5495716744ded75 100644 (file)
@@ -355,10 +355,9 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
        if ((atomic_read(&bat_priv->aggregated_ogms)) &&
            (packet_len < MAX_AGGREGATION_BYTES))
                forw_packet_aggr->skb = dev_alloc_skb(MAX_AGGREGATION_BYTES +
-                                                     sizeof(struct ethhdr));
+                                                     ETH_HLEN);
        else
-               forw_packet_aggr->skb = dev_alloc_skb(packet_len +
-                                                     sizeof(struct ethhdr));
+               forw_packet_aggr->skb = dev_alloc_skb(packet_len + ETH_HLEN);
 
        if (!forw_packet_aggr->skb) {
                if (!own_packet)
@@ -366,7 +365,7 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
                kfree(forw_packet_aggr);
                goto out;
        }
-       skb_reserve(forw_packet_aggr->skb, sizeof(struct ethhdr));
+       skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
 
        INIT_HLIST_NODE(&forw_packet_aggr->list);
 
index c8642b58641181de68af84a357a2ce67d50a3f58..ad394c6496ccf0aade9644842587ac247589d57e 100644 (file)
@@ -290,9 +290,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
                goto out;
 
        ethhdr = (struct ethhdr *)skb->data;
-       hw_src = (uint8_t *)ethhdr +
-                sizeof(struct ethhdr) +
-                sizeof(struct arphdr);
+       hw_src = (uint8_t *)ethhdr + ETH_HLEN + sizeof(struct arphdr);
 
        /* now we pretend that the client would have sent this ... */
        switch (claimtype) {
@@ -340,7 +338,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
        skb_reset_mac_header(skb);
        skb->protocol = eth_type_trans(skb, soft_iface);
        bat_priv->stats.rx_packets++;
-       bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr);
+       bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
        soft_iface->last_rx = jiffies;
 
        netif_rx(skb);
@@ -844,7 +842,7 @@ static int bla_process_claim(struct bat_priv *bat_priv,
                headlen = sizeof(*vhdr);
        } else {
                proto = ntohs(ethhdr->h_proto);
-               headlen = sizeof(*ethhdr);
+               headlen = ETH_HLEN;
        }
 
        if (proto != ETH_P_ARP)
@@ -1302,7 +1300,7 @@ int bla_is_backbone_gw(struct sk_buff *skb,
                return 0;
 
        /* first, find out the vid. */
-       if (!pskb_may_pull(skb, hdr_size + sizeof(struct ethhdr)))
+       if (!pskb_may_pull(skb, hdr_size + ETH_HLEN))
                return 0;
 
        ethhdr = (struct ethhdr *)(((uint8_t *)skb->data) + hdr_size);
index e8c5da379a805844da0d584e4918e91e16c12a8b..47c79d724ba3286d54699ec891028cb5e6d1a566 100644 (file)
@@ -574,8 +574,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
                goto err_free;
 
        /* expect a valid ethernet header here. */
-       if (unlikely(skb->mac_len != sizeof(struct ethhdr) ||
-                    !skb_mac_header(skb)))
+       if (unlikely(skb->mac_len != ETH_HLEN || !skb_mac_header(skb)))
                goto err_free;
 
        if (!hard_iface->soft_iface)
index b87518edcef935d749e46d552c1860d2045b7616..2e98a57f3407c2e9a9a499dfa8ad86b0d5e9f0f0 100644 (file)
@@ -175,13 +175,13 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
        if (len >= sizeof(struct icmp_packet_rr))
                packet_len = sizeof(struct icmp_packet_rr);
 
-       skb = dev_alloc_skb(packet_len + sizeof(struct ethhdr));
+       skb = dev_alloc_skb(packet_len + ETH_HLEN);
        if (!skb) {
                len = -ENOMEM;
                goto out;
        }
 
-       skb_reserve(skb, sizeof(struct ethhdr));
+       skb_reserve(skb, ETH_HLEN);
        icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len);
 
        if (copy_from_user(icmp_packet, buff, packet_len)) {
index ac13a6a7409d0ff090f7e41747b1da5f35c30f62..ff560863bc746f3c9be2156b81d82551ed79551b 100644 (file)
@@ -313,7 +313,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
                goto out;
 
        /* create a copy of the skb, if needed, to modify it. */
-       if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+       if (skb_cow(skb, ETH_HLEN) < 0)
                goto out;
 
        icmp_packet = (struct icmp_packet_rr *)skb->data;
@@ -368,7 +368,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
                goto out;
 
        /* create a copy of the skb, if needed, to modify it. */
-       if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+       if (skb_cow(skb, ETH_HLEN) < 0)
                goto out;
 
        icmp_packet = (struct icmp_packet *)skb->data;
@@ -454,7 +454,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
                goto out;
 
        /* create a copy of the skb, if needed, to modify it. */
-       if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+       if (skb_cow(skb, ETH_HLEN) < 0)
                goto out;
 
        icmp_packet = (struct icmp_packet_rr *)skb->data;
@@ -841,7 +841,7 @@ static int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
                goto out;
 
        /* create a copy of the skb, if needed, to modify it. */
-       if (skb_cow(skb, sizeof(struct ethhdr)) < 0)
+       if (skb_cow(skb, ETH_HLEN) < 0)
                goto out;
 
        unicast_packet = (struct unicast_packet *)skb->data;
index b5f078cacc09bb9bf598bc16afef345e367f7327..7c66b6121fa655c75d496eecd4d0cbee88dfb63a 100644 (file)
@@ -51,7 +51,7 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
        }
 
        /* push to the ethernet header. */
-       if (my_skb_head_push(skb, sizeof(*ethhdr)) < 0)
+       if (my_skb_head_push(skb, ETH_HLEN) < 0)
                goto send_skb_err;
 
        skb_reset_mac_header(skb);
index efe0fbaadcd64ae1d9b6041242270f8349a844a8..6e2530b020437e7243ff2a71d6098a11d7d5df52 100644 (file)
@@ -292,7 +292,7 @@ void interface_rx(struct net_device *soft_iface,
 /*     skb->ip_summed = CHECKSUM_UNNECESSARY;*/
 
        bat_priv->stats.rx_packets++;
-       bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr);
+       bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
 
        soft_iface->last_rx = jiffies;
 
index 4d93aad899f7637a68c91c9d52d31583fcf5df5b..2f4848b776a7229758d82bce4dfee8a162bd90d9 100644 (file)
@@ -27,7 +27,7 @@
 #include "packet.h"
 #include "bitarray.h"
 
-#define BAT_HEADER_LEN (sizeof(struct ethhdr) + \
+#define BAT_HEADER_LEN (ETH_HLEN + \
        ((sizeof(struct unicast_packet) > sizeof(struct bcast_packet) ? \
         sizeof(struct unicast_packet) : \
         sizeof(struct bcast_packet))))
index c4a5b8cafadae068582e44b213b0e09422443b28..cec216fb77c77356489e3d3e1fc8ac0024221c17 100644 (file)
@@ -434,12 +434,12 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
                return NULL;
 
        info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len +
-                                        sizeof(struct ethhdr));
+                                        ETH_HLEN);
        if (!info->skb_packet) {
                kfree(info);
                return NULL;
        }
-       skb_reserve(info->skb_packet, sizeof(struct ethhdr));
+       skb_reserve(info->skb_packet, ETH_HLEN);
        packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet)
                                              + vis_info_len);
 
@@ -894,11 +894,11 @@ int vis_init(struct bat_priv *bat_priv)
 
        bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) +
                                                          MAX_VIS_PACKET_SIZE +
-                                                        sizeof(struct ethhdr));
+                                                         ETH_HLEN);
        if (!bat_priv->my_vis_info->skb_packet)
                goto free_info;
 
-       skb_reserve(bat_priv->my_vis_info->skb_packet, sizeof(struct ethhdr));
+       skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN);
        packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet,
                                              sizeof(*packet));