aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2012-02-18 05:27:34 -0500
committerAntonio Quartulli <ordex@autistici.org>2012-04-18 03:54:01 -0400
commit0d125074ebc8c971e939f8c2c8f90a80fa09aeb4 (patch)
treefb31ee069ab0a2abc7681b999839fd81392110f7 /net/batman-adv
parent1eeb479fda2405269b3a85c86ba0eca41fcc4ea0 (diff)
batman-adv: use ETH_HLEN instead of sizeof(struct ethhdr)
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>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/bat_iv_ogm.c7
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c10
-rw-r--r--net/batman-adv/hard-interface.c3
-rw-r--r--net/batman-adv/icmp_socket.c4
-rw-r--r--net/batman-adv/routing.c8
-rw-r--r--net/batman-adv/send.c2
-rw-r--r--net/batman-adv/soft-interface.c2
-rw-r--r--net/batman-adv/types.h2
-rw-r--r--net/batman-adv/vis.c8
9 files changed, 21 insertions, 25 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 98f71827c7b3..d7fa8afd7ff8 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -355,10 +355,9 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
355 if ((atomic_read(&bat_priv->aggregated_ogms)) && 355 if ((atomic_read(&bat_priv->aggregated_ogms)) &&
356 (packet_len < MAX_AGGREGATION_BYTES)) 356 (packet_len < MAX_AGGREGATION_BYTES))
357 forw_packet_aggr->skb = dev_alloc_skb(MAX_AGGREGATION_BYTES + 357 forw_packet_aggr->skb = dev_alloc_skb(MAX_AGGREGATION_BYTES +
358 sizeof(struct ethhdr)); 358 ETH_HLEN);
359 else 359 else
360 forw_packet_aggr->skb = dev_alloc_skb(packet_len + 360 forw_packet_aggr->skb = dev_alloc_skb(packet_len + ETH_HLEN);
361 sizeof(struct ethhdr));
362 361
363 if (!forw_packet_aggr->skb) { 362 if (!forw_packet_aggr->skb) {
364 if (!own_packet) 363 if (!own_packet)
@@ -366,7 +365,7 @@ static void bat_iv_ogm_aggregate_new(const unsigned char *packet_buff,
366 kfree(forw_packet_aggr); 365 kfree(forw_packet_aggr);
367 goto out; 366 goto out;
368 } 367 }
369 skb_reserve(forw_packet_aggr->skb, sizeof(struct ethhdr)); 368 skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
370 369
371 INIT_HLIST_NODE(&forw_packet_aggr->list); 370 INIT_HLIST_NODE(&forw_packet_aggr->list);
372 371
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index c8642b586411..ad394c6496cc 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -290,9 +290,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
290 goto out; 290 goto out;
291 291
292 ethhdr = (struct ethhdr *)skb->data; 292 ethhdr = (struct ethhdr *)skb->data;
293 hw_src = (uint8_t *)ethhdr + 293 hw_src = (uint8_t *)ethhdr + ETH_HLEN + sizeof(struct arphdr);
294 sizeof(struct ethhdr) +
295 sizeof(struct arphdr);
296 294
297 /* now we pretend that the client would have sent this ... */ 295 /* now we pretend that the client would have sent this ... */
298 switch (claimtype) { 296 switch (claimtype) {
@@ -340,7 +338,7 @@ static void bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
340 skb_reset_mac_header(skb); 338 skb_reset_mac_header(skb);
341 skb->protocol = eth_type_trans(skb, soft_iface); 339 skb->protocol = eth_type_trans(skb, soft_iface);
342 bat_priv->stats.rx_packets++; 340 bat_priv->stats.rx_packets++;
343 bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr); 341 bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
344 soft_iface->last_rx = jiffies; 342 soft_iface->last_rx = jiffies;
345 343
346 netif_rx(skb); 344 netif_rx(skb);
@@ -844,7 +842,7 @@ static int bla_process_claim(struct bat_priv *bat_priv,
844 headlen = sizeof(*vhdr); 842 headlen = sizeof(*vhdr);
845 } else { 843 } else {
846 proto = ntohs(ethhdr->h_proto); 844 proto = ntohs(ethhdr->h_proto);
847 headlen = sizeof(*ethhdr); 845 headlen = ETH_HLEN;
848 } 846 }
849 847
850 if (proto != ETH_P_ARP) 848 if (proto != ETH_P_ARP)
@@ -1302,7 +1300,7 @@ int bla_is_backbone_gw(struct sk_buff *skb,
1302 return 0; 1300 return 0;
1303 1301
1304 /* first, find out the vid. */ 1302 /* first, find out the vid. */
1305 if (!pskb_may_pull(skb, hdr_size + sizeof(struct ethhdr))) 1303 if (!pskb_may_pull(skb, hdr_size + ETH_HLEN))
1306 return 0; 1304 return 0;
1307 1305
1308 ethhdr = (struct ethhdr *)(((uint8_t *)skb->data) + hdr_size); 1306 ethhdr = (struct ethhdr *)(((uint8_t *)skb->data) + hdr_size);
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index e8c5da379a80..47c79d724ba3 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -574,8 +574,7 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
574 goto err_free; 574 goto err_free;
575 575
576 /* expect a valid ethernet header here. */ 576 /* expect a valid ethernet header here. */
577 if (unlikely(skb->mac_len != sizeof(struct ethhdr) || 577 if (unlikely(skb->mac_len != ETH_HLEN || !skb_mac_header(skb)))
578 !skb_mac_header(skb)))
579 goto err_free; 578 goto err_free;
580 579
581 if (!hard_iface->soft_iface) 580 if (!hard_iface->soft_iface)
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index b87518edcef9..2e98a57f3407 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -175,13 +175,13 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
175 if (len >= sizeof(struct icmp_packet_rr)) 175 if (len >= sizeof(struct icmp_packet_rr))
176 packet_len = sizeof(struct icmp_packet_rr); 176 packet_len = sizeof(struct icmp_packet_rr);
177 177
178 skb = dev_alloc_skb(packet_len + sizeof(struct ethhdr)); 178 skb = dev_alloc_skb(packet_len + ETH_HLEN);
179 if (!skb) { 179 if (!skb) {
180 len = -ENOMEM; 180 len = -ENOMEM;
181 goto out; 181 goto out;
182 } 182 }
183 183
184 skb_reserve(skb, sizeof(struct ethhdr)); 184 skb_reserve(skb, ETH_HLEN);
185 icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len); 185 icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len);
186 186
187 if (copy_from_user(icmp_packet, buff, packet_len)) { 187 if (copy_from_user(icmp_packet, buff, packet_len)) {
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index ac13a6a7409d..ff560863bc74 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -313,7 +313,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
313 goto out; 313 goto out;
314 314
315 /* create a copy of the skb, if needed, to modify it. */ 315 /* create a copy of the skb, if needed, to modify it. */
316 if (skb_cow(skb, sizeof(struct ethhdr)) < 0) 316 if (skb_cow(skb, ETH_HLEN) < 0)
317 goto out; 317 goto out;
318 318
319 icmp_packet = (struct icmp_packet_rr *)skb->data; 319 icmp_packet = (struct icmp_packet_rr *)skb->data;
@@ -368,7 +368,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
368 goto out; 368 goto out;
369 369
370 /* create a copy of the skb, if needed, to modify it. */ 370 /* create a copy of the skb, if needed, to modify it. */
371 if (skb_cow(skb, sizeof(struct ethhdr)) < 0) 371 if (skb_cow(skb, ETH_HLEN) < 0)
372 goto out; 372 goto out;
373 373
374 icmp_packet = (struct icmp_packet *)skb->data; 374 icmp_packet = (struct icmp_packet *)skb->data;
@@ -454,7 +454,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
454 goto out; 454 goto out;
455 455
456 /* create a copy of the skb, if needed, to modify it. */ 456 /* create a copy of the skb, if needed, to modify it. */
457 if (skb_cow(skb, sizeof(struct ethhdr)) < 0) 457 if (skb_cow(skb, ETH_HLEN) < 0)
458 goto out; 458 goto out;
459 459
460 icmp_packet = (struct icmp_packet_rr *)skb->data; 460 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)
841 goto out; 841 goto out;
842 842
843 /* create a copy of the skb, if needed, to modify it. */ 843 /* create a copy of the skb, if needed, to modify it. */
844 if (skb_cow(skb, sizeof(struct ethhdr)) < 0) 844 if (skb_cow(skb, ETH_HLEN) < 0)
845 goto out; 845 goto out;
846 846
847 unicast_packet = (struct unicast_packet *)skb->data; 847 unicast_packet = (struct unicast_packet *)skb->data;
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index b5f078cacc09..7c66b6121fa6 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -51,7 +51,7 @@ int send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface,
51 } 51 }
52 52
53 /* push to the ethernet header. */ 53 /* push to the ethernet header. */
54 if (my_skb_head_push(skb, sizeof(*ethhdr)) < 0) 54 if (my_skb_head_push(skb, ETH_HLEN) < 0)
55 goto send_skb_err; 55 goto send_skb_err;
56 56
57 skb_reset_mac_header(skb); 57 skb_reset_mac_header(skb);
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index efe0fbaadcd6..6e2530b02043 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -292,7 +292,7 @@ void interface_rx(struct net_device *soft_iface,
292/* skb->ip_summed = CHECKSUM_UNNECESSARY;*/ 292/* skb->ip_summed = CHECKSUM_UNNECESSARY;*/
293 293
294 bat_priv->stats.rx_packets++; 294 bat_priv->stats.rx_packets++;
295 bat_priv->stats.rx_bytes += skb->len + sizeof(struct ethhdr); 295 bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
296 296
297 soft_iface->last_rx = jiffies; 297 soft_iface->last_rx = jiffies;
298 298
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 4d93aad899f7..2f4848b776a7 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -27,7 +27,7 @@
27#include "packet.h" 27#include "packet.h"
28#include "bitarray.h" 28#include "bitarray.h"
29 29
30#define BAT_HEADER_LEN (sizeof(struct ethhdr) + \ 30#define BAT_HEADER_LEN (ETH_HLEN + \
31 ((sizeof(struct unicast_packet) > sizeof(struct bcast_packet) ? \ 31 ((sizeof(struct unicast_packet) > sizeof(struct bcast_packet) ? \
32 sizeof(struct unicast_packet) : \ 32 sizeof(struct unicast_packet) : \
33 sizeof(struct bcast_packet)))) 33 sizeof(struct bcast_packet))))
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index c4a5b8cafada..cec216fb77c7 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -434,12 +434,12 @@ static struct vis_info *add_packet(struct bat_priv *bat_priv,
434 return NULL; 434 return NULL;
435 435
436 info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len + 436 info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len +
437 sizeof(struct ethhdr)); 437 ETH_HLEN);
438 if (!info->skb_packet) { 438 if (!info->skb_packet) {
439 kfree(info); 439 kfree(info);
440 return NULL; 440 return NULL;
441 } 441 }
442 skb_reserve(info->skb_packet, sizeof(struct ethhdr)); 442 skb_reserve(info->skb_packet, ETH_HLEN);
443 packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet) 443 packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet)
444 + vis_info_len); 444 + vis_info_len);
445 445
@@ -894,11 +894,11 @@ int vis_init(struct bat_priv *bat_priv)
894 894
895 bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) + 895 bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) +
896 MAX_VIS_PACKET_SIZE + 896 MAX_VIS_PACKET_SIZE +
897 sizeof(struct ethhdr)); 897 ETH_HLEN);
898 if (!bat_priv->my_vis_info->skb_packet) 898 if (!bat_priv->my_vis_info->skb_packet)
899 goto free_info; 899 goto free_info;
900 900
901 skb_reserve(bat_priv->my_vis_info->skb_packet, sizeof(struct ethhdr)); 901 skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN);
902 packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet, 902 packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet,
903 sizeof(*packet)); 903 sizeof(*packet));
904 904