]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ethernet/eth.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/aia21/ntfs-2.6
[linux-2.6-omap-h63xx.git] / net / ethernet / eth.c
index 68a5ca866442c059c4d21359f5f7632fa971f8bd..c971f14712ec207608dd48d8477516bcb9af054b 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/errno.h>
 #include <linux/config.h>
 #include <linux/init.h>
+#include <linux/if_ether.h>
 #include <net/dst.h>
 #include <net/arp.h>
 #include <net/sock.h>
@@ -94,6 +95,12 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
                saddr = dev->dev_addr;
        memcpy(eth->h_source,saddr,dev->addr_len);
 
+       if(daddr)
+       {
+               memcpy(eth->h_dest,daddr,dev->addr_len);
+               return ETH_HLEN;
+       }
+       
        /*
         *      Anyway, the loopback-device should never use this function... 
         */
@@ -104,12 +111,6 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
                return ETH_HLEN;
        }
        
-       if(daddr)
-       {
-               memcpy(eth->h_dest,daddr,dev->addr_len);
-               return ETH_HLEN;
-       }
-       
        return -ETH_HLEN;
 }
 
@@ -146,19 +147,6 @@ int eth_rebuild_header(struct sk_buff *skb)
        return 0;
 }
 
-static inline unsigned int compare_eth_addr(const unsigned char *__a, const unsigned char *__b)
-{
-       const unsigned short *dest = (unsigned short *) __a;
-       const unsigned short *devaddr = (unsigned short *) __b;
-       unsigned int res;
-
-       BUILD_BUG_ON(ETH_ALEN != 6);
-       res = ((dest[0] ^ devaddr[0]) |
-              (dest[1] ^ devaddr[1]) |
-              (dest[2] ^ devaddr[2])) != 0;
-
-       return res;
-}
 
 /*
  *     Determine the packet's protocol ID. The rule here is that we 
@@ -175,8 +163,8 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
        skb_pull(skb,ETH_HLEN);
        eth = eth_hdr(skb);
        
-       if (*eth->h_dest&1) {
-               if (!compare_eth_addr(eth->h_dest, dev->broadcast))
+       if (is_multicast_ether_addr(eth->h_dest)) {
+               if (!compare_ether_addr(eth->h_dest, dev->broadcast))
                        skb->pkt_type = PACKET_BROADCAST;
                else
                        skb->pkt_type = PACKET_MULTICAST;
@@ -191,7 +179,7 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
         */
         
        else if(1 /*dev->flags&IFF_PROMISC*/) {
-               if (unlikely(compare_eth_addr(eth->h_dest, dev->dev_addr)))
+               if (unlikely(compare_ether_addr(eth->h_dest, dev->dev_addr)))
                        skb->pkt_type = PACKET_OTHERHOST;
        }
        
@@ -264,7 +252,7 @@ static int eth_mac_addr(struct net_device *dev, void *p)
 
 static int eth_change_mtu(struct net_device *dev, int new_mtu)
 {
-       if ((new_mtu < 68) || (new_mtu > 1500))
+       if (new_mtu < 68 || new_mtu > ETH_DATA_LEN)
                return -EINVAL;
        dev->mtu = new_mtu;
        return 0;
@@ -285,7 +273,7 @@ void ether_setup(struct net_device *dev)
 
        dev->type               = ARPHRD_ETHER;
        dev->hard_header_len    = ETH_HLEN;
-       dev->mtu                = 1500; /* eth_mtu */
+       dev->mtu                = ETH_DATA_LEN;
        dev->addr_len           = ETH_ALEN;
        dev->tx_queue_len       = 1000; /* Ethernet wants good queues */        
        dev->flags              = IFF_BROADCAST|IFF_MULTICAST;