]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[ETH]: ether address compare
authorStephen Hemminger <shemminger@osdl.org>
Tue, 25 Oct 2005 22:03:41 +0000 (15:03 -0700)
committerArnaldo Carvalho de Melo <acme@mandriva.com>
Sat, 29 Oct 2005 04:23:58 +0000 (02:23 -0200)
Expose faster ether compare for use by protocols and other
driver. And change name to be more consistent with other ether
address manipulation routines in same file

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
include/linux/etherdevice.h
net/ethernet/eth.c

index 4522c7186bf378de1c4162b042ad8a3b78fc09ac..cc84934f90591a6d6020d2d3bcc2e874433621bb 100644 (file)
@@ -104,6 +104,22 @@ static inline void random_ether_addr(u8 *addr)
        addr [0] &= 0xfe;       /* clear multicast bit */
        addr [0] |= 0x02;       /* set local assignment bit (IEEE802) */
 }
+
+/**
+ * compare_ether_addr - Compare two Ethernet addresses
+ * @addr1: Pointer to a six-byte array containing the Ethernet address
+ * @addr2 Pointer other six-byte array containing the Ethernet address
+ *
+ * Compare two ethernet addresses, returns 0 if equal
+ */
+static inline unsigned compare_ether_addr(const u8 *_a, const u8 *_b)
+{
+       const u16 *a = (const u16 *) _a;
+       const u16 *b = (const u16 *) _b;
+
+       BUILD_BUG_ON(ETH_ALEN != 6);
+       return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
+}
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_ETHERDEVICE_H */
index 68a5ca866442c059c4d21359f5f7632fa971f8bd..e245773672749880e6b9a4bf28a36abd39a9081a 100644 (file)
@@ -146,19 +146,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 
@@ -176,7 +163,7 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
        eth = eth_hdr(skb);
        
        if (*eth->h_dest&1) {
-               if (!compare_eth_addr(eth->h_dest, dev->broadcast))
+               if (!compare_ether_addr(eth->h_dest, dev->broadcast))
                        skb->pkt_type = PACKET_BROADCAST;
                else
                        skb->pkt_type = PACKET_MULTICAST;
@@ -191,7 +178,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;
        }