All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: linux-wireless@vger.kernel.org
Subject: [PATCH 3/3] d80211: convert to use compare_ether_addr
Date: Thu, 22 Feb 2007 16:12:10 -0800	[thread overview]
Message-ID: <20070222161210.270f2905@freekitty> (raw)
In-Reply-To: <20070222161014.62d064a6@freekitty>

compare_ether_addr is faster than memcmp()

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
 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


  parent reply	other threads:[~2007-02-23  0:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-23  0:10 [PATCH 1/3] d80211: use const Stephen Hemminger
2007-02-23  0:11 ` [PATCH 2/3] bcm43xx: build failure Stephen Hemminger
2007-02-23  0:31   ` Michael Wu
2007-02-23  0:12 ` Stephen Hemminger [this message]
2007-02-23 16:55   ` [PATCH 3/3] d80211: convert to use compare_ether_addr Jiri Benc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070222161210.270f2905@freekitty \
    --to=shemminger@linux-foundation.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.