diff options
author | Antonio Quartulli <ordex@autistici.org> | 2013-04-08 09:08:18 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2013-05-28 20:44:54 -0400 |
commit | 7ed4be9523455a061e62236dc3caa9211cd7edda (patch) | |
tree | 476ba10f0a15e50ff9f5409f4a4f4ee0e1388a47 /net/batman-adv | |
parent | 7db3fc291bb22bf43667b009dd0e701ed4eb7c96 (diff) |
batman-adv: use eth_hdr() when it makes sense
Instead of casting the result of skb_mac_header() to
"struct ethhdr *" every time, the eth_hdr inline function
can be use to beautify the code and improve its readability.
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 | 2 | ||||
-rw-r--r-- | net/batman-adv/bridge_loop_avoidance.c | 8 | ||||
-rw-r--r-- | net/batman-adv/network-coding.c | 10 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 12 | ||||
-rw-r--r-- | net/batman-adv/send.c | 2 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 2 |
6 files changed, 18 insertions, 18 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index bd50e0d76aea..ef41be49b314 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -1268,7 +1268,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb, | |||
1268 | skb->len + ETH_HLEN); | 1268 | skb->len + ETH_HLEN); |
1269 | 1269 | ||
1270 | packet_len = skb_headlen(skb); | 1270 | packet_len = skb_headlen(skb); |
1271 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1271 | ethhdr = eth_hdr(skb); |
1272 | packet_buff = skb->data; | 1272 | packet_buff = skb->data; |
1273 | batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff; | 1273 | batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff; |
1274 | 1274 | ||
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 379061c72549..082189e2e40d 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c | |||
@@ -864,7 +864,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, | |||
864 | short vid = -1; | 864 | short vid = -1; |
865 | int ret; | 865 | int ret; |
866 | 866 | ||
867 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 867 | ethhdr = eth_hdr(skb); |
868 | 868 | ||
869 | if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) { | 869 | if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) { |
870 | vhdr = (struct vlan_ethhdr *)ethhdr; | 870 | vhdr = (struct vlan_ethhdr *)ethhdr; |
@@ -885,7 +885,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, | |||
885 | return 0; | 885 | return 0; |
886 | 886 | ||
887 | /* pskb_may_pull() may have modified the pointers, get ethhdr again */ | 887 | /* pskb_may_pull() may have modified the pointers, get ethhdr again */ |
888 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 888 | ethhdr = eth_hdr(skb); |
889 | arphdr = (struct arphdr *)((uint8_t *)ethhdr + headlen); | 889 | arphdr = (struct arphdr *)((uint8_t *)ethhdr + headlen); |
890 | 890 | ||
891 | /* Check whether the ARP frame carries a valid | 891 | /* Check whether the ARP frame carries a valid |
@@ -1432,7 +1432,7 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid, | |||
1432 | struct batadv_hard_iface *primary_if; | 1432 | struct batadv_hard_iface *primary_if; |
1433 | int ret; | 1433 | int ret; |
1434 | 1434 | ||
1435 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1435 | ethhdr = eth_hdr(skb); |
1436 | 1436 | ||
1437 | primary_if = batadv_primary_if_get_selected(bat_priv); | 1437 | primary_if = batadv_primary_if_get_selected(bat_priv); |
1438 | if (!primary_if) | 1438 | if (!primary_if) |
@@ -1539,7 +1539,7 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) | |||
1539 | if (batadv_bla_process_claim(bat_priv, primary_if, skb)) | 1539 | if (batadv_bla_process_claim(bat_priv, primary_if, skb)) |
1540 | goto handled; | 1540 | goto handled; |
1541 | 1541 | ||
1542 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1542 | ethhdr = eth_hdr(skb); |
1543 | 1543 | ||
1544 | if (unlikely(atomic_read(&bat_priv->bla.num_requests))) | 1544 | if (unlikely(atomic_read(&bat_priv->bla.num_requests))) |
1545 | /* don't allow broadcasts while requests are in flight */ | 1545 | /* don't allow broadcasts while requests are in flight */ |
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index e84629ece9b7..0787a34609b9 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c | |||
@@ -1245,7 +1245,7 @@ static void batadv_nc_skb_store_before_coding(struct batadv_priv *bat_priv, | |||
1245 | return; | 1245 | return; |
1246 | 1246 | ||
1247 | /* Set the mac header as if we actually sent the packet uncoded */ | 1247 | /* Set the mac header as if we actually sent the packet uncoded */ |
1248 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1248 | ethhdr = eth_hdr(skb); |
1249 | memcpy(ethhdr->h_source, ethhdr->h_dest, ETH_ALEN); | 1249 | memcpy(ethhdr->h_source, ethhdr->h_dest, ETH_ALEN); |
1250 | memcpy(ethhdr->h_dest, eth_dst_new, ETH_ALEN); | 1250 | memcpy(ethhdr->h_dest, eth_dst_new, ETH_ALEN); |
1251 | 1251 | ||
@@ -1423,7 +1423,7 @@ void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv, | |||
1423 | { | 1423 | { |
1424 | struct batadv_unicast_packet *packet; | 1424 | struct batadv_unicast_packet *packet; |
1425 | struct batadv_nc_path *nc_path; | 1425 | struct batadv_nc_path *nc_path; |
1426 | struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1426 | struct ethhdr *ethhdr = eth_hdr(skb); |
1427 | __be32 packet_id; | 1427 | __be32 packet_id; |
1428 | u8 *payload; | 1428 | u8 *payload; |
1429 | 1429 | ||
@@ -1482,7 +1482,7 @@ out: | |||
1482 | void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv, | 1482 | void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv, |
1483 | struct sk_buff *skb) | 1483 | struct sk_buff *skb) |
1484 | { | 1484 | { |
1485 | struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1485 | struct ethhdr *ethhdr = eth_hdr(skb); |
1486 | 1486 | ||
1487 | if (batadv_is_my_mac(bat_priv, ethhdr->h_dest)) | 1487 | if (batadv_is_my_mac(bat_priv, ethhdr->h_dest)) |
1488 | return; | 1488 | return; |
@@ -1533,7 +1533,7 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, | |||
1533 | skb_reset_network_header(skb); | 1533 | skb_reset_network_header(skb); |
1534 | 1534 | ||
1535 | /* Reconstruct original mac header */ | 1535 | /* Reconstruct original mac header */ |
1536 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1536 | ethhdr = eth_hdr(skb); |
1537 | memcpy(ethhdr, ðhdr_tmp, sizeof(*ethhdr)); | 1537 | memcpy(ethhdr, ðhdr_tmp, sizeof(*ethhdr)); |
1538 | 1538 | ||
1539 | /* Select the correct unicast header information based on the location | 1539 | /* Select the correct unicast header information based on the location |
@@ -1677,7 +1677,7 @@ static int batadv_nc_recv_coded_packet(struct sk_buff *skb, | |||
1677 | return NET_RX_DROP; | 1677 | return NET_RX_DROP; |
1678 | 1678 | ||
1679 | coded_packet = (struct batadv_coded_packet *)skb->data; | 1679 | coded_packet = (struct batadv_coded_packet *)skb->data; |
1680 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1680 | ethhdr = eth_hdr(skb); |
1681 | 1681 | ||
1682 | /* Verify frame is destined for us */ | 1682 | /* Verify frame is destined for us */ |
1683 | if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest) && | 1683 | if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest) && |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index b27a4d792d15..beeab2e8cd66 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -256,7 +256,7 @@ bool batadv_check_management_packet(struct sk_buff *skb, | |||
256 | if (unlikely(!pskb_may_pull(skb, header_len))) | 256 | if (unlikely(!pskb_may_pull(skb, header_len))) |
257 | return false; | 257 | return false; |
258 | 258 | ||
259 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 259 | ethhdr = eth_hdr(skb); |
260 | 260 | ||
261 | /* packet with broadcast indication but unicast recipient */ | 261 | /* packet with broadcast indication but unicast recipient */ |
262 | if (!is_broadcast_ether_addr(ethhdr->h_dest)) | 262 | if (!is_broadcast_ether_addr(ethhdr->h_dest)) |
@@ -392,7 +392,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, | |||
392 | if (unlikely(!pskb_may_pull(skb, hdr_size))) | 392 | if (unlikely(!pskb_may_pull(skb, hdr_size))) |
393 | goto out; | 393 | goto out; |
394 | 394 | ||
395 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 395 | ethhdr = eth_hdr(skb); |
396 | 396 | ||
397 | /* packet with unicast indication but broadcast recipient */ | 397 | /* packet with unicast indication but broadcast recipient */ |
398 | if (is_broadcast_ether_addr(ethhdr->h_dest)) | 398 | if (is_broadcast_ether_addr(ethhdr->h_dest)) |
@@ -569,7 +569,7 @@ static int batadv_check_unicast_packet(struct batadv_priv *bat_priv, | |||
569 | if (unlikely(!pskb_may_pull(skb, hdr_size))) | 569 | if (unlikely(!pskb_may_pull(skb, hdr_size))) |
570 | return -ENODATA; | 570 | return -ENODATA; |
571 | 571 | ||
572 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 572 | ethhdr = eth_hdr(skb); |
573 | 573 | ||
574 | /* packet with unicast indication but broadcast recipient */ | 574 | /* packet with unicast indication but broadcast recipient */ |
575 | if (is_broadcast_ether_addr(ethhdr->h_dest)) | 575 | if (is_broadcast_ether_addr(ethhdr->h_dest)) |
@@ -803,7 +803,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb, | |||
803 | struct batadv_orig_node *orig_node = NULL; | 803 | struct batadv_orig_node *orig_node = NULL; |
804 | struct batadv_neigh_node *neigh_node = NULL; | 804 | struct batadv_neigh_node *neigh_node = NULL; |
805 | struct batadv_unicast_packet *unicast_packet; | 805 | struct batadv_unicast_packet *unicast_packet; |
806 | struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb); | 806 | struct ethhdr *ethhdr = eth_hdr(skb); |
807 | int ret = NET_RX_DROP; | 807 | int ret = NET_RX_DROP; |
808 | struct sk_buff *new_skb; | 808 | struct sk_buff *new_skb; |
809 | 809 | ||
@@ -1165,7 +1165,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, | |||
1165 | if (unlikely(!pskb_may_pull(skb, hdr_size))) | 1165 | if (unlikely(!pskb_may_pull(skb, hdr_size))) |
1166 | goto out; | 1166 | goto out; |
1167 | 1167 | ||
1168 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1168 | ethhdr = eth_hdr(skb); |
1169 | 1169 | ||
1170 | /* packet with broadcast indication but unicast recipient */ | 1170 | /* packet with broadcast indication but unicast recipient */ |
1171 | if (!is_broadcast_ether_addr(ethhdr->h_dest)) | 1171 | if (!is_broadcast_ether_addr(ethhdr->h_dest)) |
@@ -1265,7 +1265,7 @@ int batadv_recv_vis_packet(struct sk_buff *skb, | |||
1265 | return NET_RX_DROP; | 1265 | return NET_RX_DROP; |
1266 | 1266 | ||
1267 | vis_packet = (struct batadv_vis_packet *)skb->data; | 1267 | vis_packet = (struct batadv_vis_packet *)skb->data; |
1268 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 1268 | ethhdr = eth_hdr(skb); |
1269 | 1269 | ||
1270 | /* not for me */ | 1270 | /* not for me */ |
1271 | if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest)) | 1271 | if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest)) |
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index eb16b04d4bee..ed7072ad84e8 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c | |||
@@ -61,7 +61,7 @@ int batadv_send_skb_packet(struct sk_buff *skb, | |||
61 | 61 | ||
62 | skb_reset_mac_header(skb); | 62 | skb_reset_mac_header(skb); |
63 | 63 | ||
64 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 64 | ethhdr = eth_hdr(skb); |
65 | memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN); | 65 | memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN); |
66 | memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); | 66 | memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); |
67 | ethhdr->h_proto = __constant_htons(ETH_P_BATMAN); | 67 | ethhdr->h_proto = __constant_htons(ETH_P_BATMAN); |
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 819dfb006cdf..b26a6cdb934c 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -316,7 +316,7 @@ void batadv_interface_rx(struct net_device *soft_iface, | |||
316 | skb_pull_rcsum(skb, hdr_size); | 316 | skb_pull_rcsum(skb, hdr_size); |
317 | skb_reset_mac_header(skb); | 317 | skb_reset_mac_header(skb); |
318 | 318 | ||
319 | ethhdr = (struct ethhdr *)skb_mac_header(skb); | 319 | ethhdr = eth_hdr(skb); |
320 | 320 | ||
321 | switch (ntohs(ethhdr->h_proto)) { | 321 | switch (ntohs(ethhdr->h_proto)) { |
322 | case ETH_P_8021Q: | 322 | case ETH_P_8021Q: |