batman-adv: use eth_hdr() when it makes sense
authorAntonio Quartulli <ordex@autistici.org>
Mon, 8 Apr 2013 13:08:18 +0000 (15:08 +0200)
committerAntonio Quartulli <ordex@autistici.org>
Wed, 29 May 2013 00:44:54 +0000 (02:44 +0200)
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>
net/batman-adv/bat_iv_ogm.c
net/batman-adv/bridge_loop_avoidance.c
net/batman-adv/network-coding.c
net/batman-adv/routing.c
net/batman-adv/send.c
net/batman-adv/soft-interface.c

index bd50e0d..ef41be4 100644 (file)
@@ -1268,7 +1268,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
                           skb->len + ETH_HLEN);
 
        packet_len = skb_headlen(skb);
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
        packet_buff = skb->data;
        batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff;
 
index 379061c..082189e 100644 (file)
@@ -864,7 +864,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
        short vid = -1;
        int ret;
 
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) {
                vhdr = (struct vlan_ethhdr *)ethhdr;
@@ -885,7 +885,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
                return 0;
 
        /* pskb_may_pull() may have modified the pointers, get ethhdr again */
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
        arphdr = (struct arphdr *)((uint8_t *)ethhdr + headlen);
 
        /* 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,
        struct batadv_hard_iface *primary_if;
        int ret;
 
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        primary_if = batadv_primary_if_get_selected(bat_priv);
        if (!primary_if)
@@ -1539,7 +1539,7 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid)
        if (batadv_bla_process_claim(bat_priv, primary_if, skb))
                goto handled;
 
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        if (unlikely(atomic_read(&bat_priv->bla.num_requests)))
                /* don't allow broadcasts while requests are in flight */
index e84629e..0787a34 100644 (file)
@@ -1245,7 +1245,7 @@ static void batadv_nc_skb_store_before_coding(struct batadv_priv *bat_priv,
                return;
 
        /* Set the mac header as if we actually sent the packet uncoded */
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
        memcpy(ethhdr->h_source, ethhdr->h_dest, ETH_ALEN);
        memcpy(ethhdr->h_dest, eth_dst_new, ETH_ALEN);
 
@@ -1423,7 +1423,7 @@ void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv,
 {
        struct batadv_unicast_packet *packet;
        struct batadv_nc_path *nc_path;
-       struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       struct ethhdr *ethhdr = eth_hdr(skb);
        __be32 packet_id;
        u8 *payload;
 
@@ -1482,7 +1482,7 @@ out:
 void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv,
                                         struct sk_buff *skb)
 {
-       struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       struct ethhdr *ethhdr = eth_hdr(skb);
 
        if (batadv_is_my_mac(bat_priv, ethhdr->h_dest))
                return;
@@ -1533,7 +1533,7 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
        skb_reset_network_header(skb);
 
        /* Reconstruct original mac header */
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
        memcpy(ethhdr, &ethhdr_tmp, sizeof(*ethhdr));
 
        /* 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,
                return NET_RX_DROP;
 
        coded_packet = (struct batadv_coded_packet *)skb->data;
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        /* Verify frame is destined for us */
        if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest) &&
index b27a4d7..beeab2e 100644 (file)
@@ -256,7 +256,7 @@ bool batadv_check_management_packet(struct sk_buff *skb,
        if (unlikely(!pskb_may_pull(skb, header_len)))
                return false;
 
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        /* packet with broadcast indication but unicast recipient */
        if (!is_broadcast_ether_addr(ethhdr->h_dest))
@@ -392,7 +392,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
        if (unlikely(!pskb_may_pull(skb, hdr_size)))
                goto out;
 
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        /* packet with unicast indication but broadcast recipient */
        if (is_broadcast_ether_addr(ethhdr->h_dest))
@@ -569,7 +569,7 @@ static int batadv_check_unicast_packet(struct batadv_priv *bat_priv,
        if (unlikely(!pskb_may_pull(skb, hdr_size)))
                return -ENODATA;
 
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        /* packet with unicast indication but broadcast recipient */
        if (is_broadcast_ether_addr(ethhdr->h_dest))
@@ -803,7 +803,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
        struct batadv_orig_node *orig_node = NULL;
        struct batadv_neigh_node *neigh_node = NULL;
        struct batadv_unicast_packet *unicast_packet;
-       struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       struct ethhdr *ethhdr = eth_hdr(skb);
        int ret = NET_RX_DROP;
        struct sk_buff *new_skb;
 
@@ -1165,7 +1165,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
        if (unlikely(!pskb_may_pull(skb, hdr_size)))
                goto out;
 
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        /* packet with broadcast indication but unicast recipient */
        if (!is_broadcast_ether_addr(ethhdr->h_dest))
@@ -1265,7 +1265,7 @@ int batadv_recv_vis_packet(struct sk_buff *skb,
                return NET_RX_DROP;
 
        vis_packet = (struct batadv_vis_packet *)skb->data;
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        /* not for me */
        if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest))
index eb16b04..ed7072a 100644 (file)
@@ -61,7 +61,7 @@ int batadv_send_skb_packet(struct sk_buff *skb,
 
        skb_reset_mac_header(skb);
 
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
        memcpy(ethhdr->h_source, hard_iface->net_dev->dev_addr, ETH_ALEN);
        memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN);
        ethhdr->h_proto = __constant_htons(ETH_P_BATMAN);
index 819dfb0..b26a6cd 100644 (file)
@@ -316,7 +316,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
        skb_pull_rcsum(skb, hdr_size);
        skb_reset_mac_header(skb);
 
-       ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       ethhdr = eth_hdr(skb);
 
        switch (ntohs(ethhdr->h_proto)) {
        case ETH_P_8021Q: