]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - net/batman-adv/soft-interface.c
batman-adv: prefer ether_addr_copy to memcpy
[mirror_ubuntu-artful-kernel.git] / net / batman-adv / soft-interface.c
index f82c267e1886ee04cb50339d91e20fa559161737..db3e46783c6b1dd0a8786437a017ad72d0cf6d90 100644 (file)
@@ -111,8 +111,8 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
        if (!is_valid_ether_addr(addr->sa_data))
                return -EADDRNOTAVAIL;
 
-       memcpy(old_addr, dev->dev_addr, ETH_ALEN);
-       memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+       ether_addr_copy(old_addr, dev->dev_addr);
+       ether_addr_copy(dev->dev_addr, addr->sa_data);
 
        /* only modify transtable if it has been initialized before */
        if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) {
@@ -176,11 +176,11 @@ static int batadv_interface_tx(struct sk_buff *skb,
 
        soft_iface->trans_start = jiffies;
        vid = batadv_get_vid(skb, 0);
-       ethhdr = (struct ethhdr *)skb->data;
+       ethhdr = eth_hdr(skb);
 
        switch (ntohs(ethhdr->h_proto)) {
        case ETH_P_8021Q:
-               vhdr = (struct vlan_ethhdr *)skb->data;
+               vhdr = vlan_eth_hdr(skb);
 
                if (vhdr->h_vlan_encapsulated_proto != ethertype)
                        break;
@@ -194,7 +194,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
                goto dropped;
 
        /* skb->data might have been reallocated by batadv_bla_tx() */
-       ethhdr = (struct ethhdr *)skb->data;
+       ethhdr = eth_hdr(skb);
 
        /* Register the client MAC in the transtable */
        if (!is_multicast_ether_addr(ethhdr->h_source)) {
@@ -230,7 +230,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
                /* skb->data may have been modified by
                 * batadv_gw_dhcp_recipient_get()
                 */
-               ethhdr = (struct ethhdr *)skb->data;
+               ethhdr = eth_hdr(skb);
                /* if gw_mode is on, broadcast any non-DHCP message.
                 * All the DHCP packets are going to be sent as unicast
                 */
@@ -279,8 +279,8 @@ send:
                /* hw address of first interface is the orig mac because only
                 * this mac is known throughout the mesh
                 */
-               memcpy(bcast_packet->orig,
-                      primary_if->net_dev->dev_addr, ETH_ALEN);
+               ether_addr_copy(bcast_packet->orig,
+                               primary_if->net_dev->dev_addr);
 
                /* set broadcast sequence number */
                seqno = atomic_inc_return(&bat_priv->bcast_seqno);