Search Linux Wireless

[PATCH 3/3] d80211: convert to use compare_ether_addr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



compare_ether_addr is faster than memcmp()

Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxxxxxxxxxxxxxx>
---
 net/d80211/ieee80211.c |   45 ++++++++++++++++++++++-----------------------
 1 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
index 73e34a0..6ffba74 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -2310,15 +2310,14 @@ static int ieee80211_open(struct net_dev
 	list_for_each_entry(nsdata, &local->sub_if_list, list) {
 		struct net_device *ndev = nsdata->dev;
 
-		if (ndev != dev && ndev != local->mdev &&
-		    netif_running(ndev) &&
-		    memcmp(dev->dev_addr, ndev->dev_addr, ETH_ALEN) == 0 &&
-		    !identical_mac_addr_allowed(sdata->type, nsdata->type)) {
+		if (ndev != dev && ndev != local->mdev && netif_running(ndev) &&
+		    compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0 &&
+		    !identical_mac_addr_allowed(sdata->type, nsdata->type))
 			return -ENOTUNIQ;
-		}
 	}
-	if (sdata->type == IEEE80211_IF_TYPE_WDS &&
-	    memcmp(sdata->u.wds.remote_addr, "\0\0\0\0\0\0", ETH_ALEN) == 0)
+
+	if (sdata->type == IEEE80211_IF_TYPE_WDS && 
+	    is_zero_ether_addr(sdata->u.wds.remote_addr))
 		return -ENOLINK;
 
 	if (sdata->type == IEEE80211_IF_TYPE_MNTR && local->open_count &&
@@ -2436,9 +2435,9 @@ static int header_parse_80211(struct sk_
 	return ETH_ALEN;
 }
 
-static inline int ieee80211_bssid_match(u8 *raddr, u8 *addr)
+static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
 {
-	return memcmp(raddr, addr, ETH_ALEN) == 0 ||
+	return compare_ether_addr(raddr, addr) == 0 ||
 	       is_broadcast_ether_addr(raddr);
 }
 
@@ -2545,9 +2544,9 @@ ieee80211_rx_h_data(struct ieee80211_txr
 
 	ethertype = (payload[6] << 8) | payload[7];
 
-	if (likely((memcmp(payload, rfc1042_header, 6) == 0 &&
+	if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
 		    ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
-		   memcmp(payload, bridge_tunnel_header, 6) == 0)) {
+		   compare_ether_addr(payload, bridge_tunnel_header) == 0)) {
 		/* remove RFC1042 or Bridge-Tunnel encapsulation and
 		 * replace EtherType */
 		skb_pull(skb, hdrlen + 6);
@@ -3038,8 +3037,8 @@ ieee80211_reassemble_find(struct ieee802
 		f_fc = le16_to_cpu(f_hdr->frame_control);
 
 		if ((fc & IEEE80211_FCTL_FTYPE) != (f_fc & IEEE80211_FCTL_FTYPE) ||
-		    memcmp(hdr->addr1, f_hdr->addr1, ETH_ALEN) != 0 ||
-		    memcmp(hdr->addr2, f_hdr->addr2, ETH_ALEN) != 0)
+		    compare_ether_addr(hdr->addr1, f_hdr->addr1) != 0 ||
+		    compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0)
 			continue;
 
 		if (entry->first_frag_time + 2 * HZ < jiffies) {
@@ -3208,7 +3207,7 @@ ieee80211_rx_h_check(struct ieee80211_tx
 
 	if (!rx->u.rx.ra_match)
 		rx->skb->pkt_type = PACKET_OTHERHOST;
-	else if (memcmp(rx->dev->dev_addr, hdr->addr1, ETH_ALEN) == 0)
+	else if (compare_ether_addr(rx->dev->dev_addr, hdr->addr1) == 0)
 		rx->skb->pkt_type = PACKET_HOST;
 	else if (is_multicast_ether_addr(hdr->addr1)) {
 		if (is_broadcast_ether_addr(hdr->addr1))
@@ -3318,7 +3317,7 @@ ieee80211_rx_h_sta_process(struct ieee80
 	 * other STAs are using different BSSID. */
 	if (rx->sdata->type == IEEE80211_IF_TYPE_IBSS) {
 		u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len);
-		if (memcmp(bssid, rx->sdata->u.sta.bssid, ETH_ALEN) == 0)
+		if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0)
 			sta->last_rx = jiffies;
 	} else
 	if (!is_multicast_ether_addr(hdr->addr1) ||
@@ -3797,8 +3796,8 @@ void __ieee80211_rx(struct ieee80211_hw 
 						continue;
 					rx.u.rx.ra_match = 0;
 				} else if (!multicast &&
-					   memcmp(sdata->dev->dev_addr,
-						  hdr->addr1, ETH_ALEN) != 0) {
+					   compare_ether_addr(sdata->dev->dev_addr,
+							      hdr->addr1) != 0) {
 					if (!sdata->promisc)
 						continue;
 					rx.u.rx.ra_match = 0;
@@ -3813,8 +3812,8 @@ void __ieee80211_rx(struct ieee80211_hw 
 						continue;
 					rx.u.rx.ra_match = 0;
 				} else if (!multicast &&
-					   memcmp(sdata->dev->dev_addr,
-						  hdr->addr1, ETH_ALEN) != 0) {
+					   compare_ether_addr(sdata->dev->dev_addr,
+							      hdr->addr1) != 0) {
 					if (!sdata->promisc)
 						continue;
 					rx.u.rx.ra_match = 0;
@@ -3827,8 +3826,8 @@ void __ieee80211_rx(struct ieee80211_hw 
 				break;
 			case IEEE80211_IF_TYPE_AP:
 				if (!bssid) {
-					if (memcmp(sdata->dev->dev_addr,
-						   hdr->addr1, ETH_ALEN) != 0)
+					if (compare_ether_addr(sdata->dev->dev_addr,
+							       hdr->addr1) != 0)
 						continue;
 				} else if (!ieee80211_bssid_match(bssid,
 							sdata->dev->dev_addr)) {
@@ -3846,8 +3845,8 @@ void __ieee80211_rx(struct ieee80211_hw 
 				if (bssid ||
 				    (rx.fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
 					continue;
-				if (memcmp(sdata->u.wds.remote_addr,
-					   hdr->addr2, ETH_ALEN) != 0)
+				if (compare_ether_addr(sdata->u.wds.remote_addr,
+						       hdr->addr2) != 0)
 					continue;
 				break;
 			}
-- 
1.4.1

-
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux