aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authordingtianhong <dingtianhong@huawei.com>2013-12-26 06:41:15 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-26 13:31:35 -0500
commitd22fbd70c2770b5e3ba0d7bc5b29f6ee686cdba4 (patch)
tree5ae7fe8532ab5d1739b99f7046f6d4907294fd8c /drivers/net/wireless
parent5e231c2c5aeda0763c0b6e1337ca7bb61a887af8 (diff)
hostap: slight optimization of addr compare
Use possibly more efficient ether_addr_equal instead of memcmp. Cc: Jouni Malinen <j@w1.fi> Cc: John W. Linville <linville@tuxdriver.com> Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Weilong Chen <chenweilong@huawei.com> Signed-off-by: Ding Tianhong <dingtianhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_tx.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c28
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c8
5 files changed, 22 insertions, 24 deletions
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c
index 344a981a052e..8bde77689469 100644
--- a/drivers/net/wireless/hostap/hostap_80211_tx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_tx.c
@@ -1,5 +1,6 @@
1#include <linux/slab.h> 1#include <linux/slab.h>
2#include <linux/export.h> 2#include <linux/export.h>
3#include <linux/etherdevice.h>
3 4
4#include "hostap_80211.h" 5#include "hostap_80211.h"
5#include "hostap_common.h" 6#include "hostap_common.h"
@@ -103,8 +104,7 @@ netdev_tx_t hostap_data_start_xmit(struct sk_buff *skb,
103 return NETDEV_TX_OK; 104 return NETDEV_TX_OK;
104 } else if (local->iw_mode == IW_MODE_INFRA && 105 } else if (local->iw_mode == IW_MODE_INFRA &&
105 (local->wds_type & HOSTAP_WDS_AP_CLIENT) && 106 (local->wds_type & HOSTAP_WDS_AP_CLIENT) &&
106 memcmp(skb->data + ETH_ALEN, dev->dev_addr, 107 !ether_addr_equal(skb->data + ETH_ALEN, dev->dev_addr)) {
107 ETH_ALEN) != 0) {
108 /* AP client mode: send frames with foreign src addr 108 /* AP client mode: send frames with foreign src addr
109 * using 4-addr WDS frames */ 109 * using 4-addr WDS frames */
110 use_wds = WDS_COMPLIANT_FRAME; 110 use_wds = WDS_COMPLIANT_FRAME;
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index d6033a8e5dea..d36e252d2ccb 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -24,6 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/export.h> 25#include <linux/export.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/etherdevice.h>
27 28
28#include "hostap_wlan.h" 29#include "hostap_wlan.h"
29#include "hostap.h" 30#include "hostap.h"
@@ -106,13 +107,12 @@ static void ap_sta_hash_del(struct ap_data *ap, struct sta_info *sta)
106 107
107 s = ap->sta_hash[STA_HASH(sta->addr)]; 108 s = ap->sta_hash[STA_HASH(sta->addr)];
108 if (s == NULL) return; 109 if (s == NULL) return;
109 if (memcmp(s->addr, sta->addr, ETH_ALEN) == 0) { 110 if (ether_addr_equal(s->addr, sta->addr)) {
110 ap->sta_hash[STA_HASH(sta->addr)] = s->hnext; 111 ap->sta_hash[STA_HASH(sta->addr)] = s->hnext;
111 return; 112 return;
112 } 113 }
113 114
114 while (s->hnext != NULL && memcmp(s->hnext->addr, sta->addr, ETH_ALEN) 115 while (s->hnext != NULL && !ether_addr_equal(s->hnext->addr, sta->addr))
115 != 0)
116 s = s->hnext; 116 s = s->hnext;
117 if (s->hnext != NULL) 117 if (s->hnext != NULL)
118 s->hnext = s->hnext->hnext; 118 s->hnext = s->hnext->hnext;
@@ -435,7 +435,7 @@ int ap_control_del_mac(struct mac_restrictions *mac_restrictions, u8 *mac)
435 ptr != &mac_restrictions->mac_list; ptr = ptr->next) { 435 ptr != &mac_restrictions->mac_list; ptr = ptr->next) {
436 entry = list_entry(ptr, struct mac_entry, list); 436 entry = list_entry(ptr, struct mac_entry, list);
437 437
438 if (memcmp(entry->addr, mac, ETH_ALEN) == 0) { 438 if (ether_addr_equal(entry->addr, mac)) {
439 list_del(ptr); 439 list_del(ptr);
440 kfree(entry); 440 kfree(entry);
441 mac_restrictions->entries--; 441 mac_restrictions->entries--;
@@ -459,7 +459,7 @@ static int ap_control_mac_deny(struct mac_restrictions *mac_restrictions,
459 459
460 spin_lock_bh(&mac_restrictions->lock); 460 spin_lock_bh(&mac_restrictions->lock);
461 list_for_each_entry(entry, &mac_restrictions->mac_list, list) { 461 list_for_each_entry(entry, &mac_restrictions->mac_list, list) {
462 if (memcmp(entry->addr, mac, ETH_ALEN) == 0) { 462 if (ether_addr_equal(entry->addr, mac)) {
463 found = 1; 463 found = 1;
464 break; 464 break;
465 } 465 }
@@ -957,7 +957,7 @@ static struct sta_info* ap_get_sta(struct ap_data *ap, u8 *sta)
957 struct sta_info *s; 957 struct sta_info *s;
958 958
959 s = ap->sta_hash[STA_HASH(sta)]; 959 s = ap->sta_hash[STA_HASH(sta)];
960 while (s != NULL && memcmp(s->addr, sta, ETH_ALEN) != 0) 960 while (s != NULL && !ether_addr_equal(s->addr, sta))
961 s = s->hnext; 961 s = s->hnext;
962 return s; 962 return s;
963} 963}
@@ -1391,7 +1391,7 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
1391 status_code = __le16_to_cpu(*pos); 1391 status_code = __le16_to_cpu(*pos);
1392 pos++; 1392 pos++;
1393 1393
1394 if (memcmp(dev->dev_addr, hdr->addr2, ETH_ALEN) == 0 || 1394 if (ether_addr_equal(dev->dev_addr, hdr->addr2) ||
1395 ap_control_mac_deny(&ap->mac_restrictions, hdr->addr2)) { 1395 ap_control_mac_deny(&ap->mac_restrictions, hdr->addr2)) {
1396 txt = "authentication denied"; 1396 txt = "authentication denied";
1397 resp = WLAN_STATUS_UNSPECIFIED_FAILURE; 1397 resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
@@ -1935,7 +1935,7 @@ static void handle_pspoll(local_info_t *local,
1935 PDEBUG(DEBUG_PS2, "handle_pspoll: BSSID=%pM, TA=%pM PWRMGT=%d\n", 1935 PDEBUG(DEBUG_PS2, "handle_pspoll: BSSID=%pM, TA=%pM PWRMGT=%d\n",
1936 hdr->addr1, hdr->addr2, !!ieee80211_has_pm(hdr->frame_control)); 1936 hdr->addr1, hdr->addr2, !!ieee80211_has_pm(hdr->frame_control));
1937 1937
1938 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 1938 if (!ether_addr_equal(hdr->addr1, dev->dev_addr)) {
1939 PDEBUG(DEBUG_AP, 1939 PDEBUG(DEBUG_AP,
1940 "handle_pspoll - addr1(BSSID)=%pM not own MAC\n", 1940 "handle_pspoll - addr1(BSSID)=%pM not own MAC\n",
1941 hdr->addr1); 1941 hdr->addr1);
@@ -2230,7 +2230,7 @@ static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
2230 goto done; 2230 goto done;
2231 } 2231 }
2232 2232
2233 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 2233 if (!ether_addr_equal(hdr->addr1, dev->dev_addr)) {
2234 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(BSSID)=%pM" 2234 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(BSSID)=%pM"
2235 " not own MAC\n", hdr->addr1); 2235 " not own MAC\n", hdr->addr1);
2236 goto done; 2236 goto done;
@@ -2267,13 +2267,13 @@ static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
2267 goto done; 2267 goto done;
2268 } 2268 }
2269 2269
2270 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 2270 if (!ether_addr_equal(hdr->addr1, dev->dev_addr)) {
2271 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(DA)=%pM" 2271 PDEBUG(DEBUG_AP, "handle_ap_item - addr1(DA)=%pM"
2272 " not own MAC\n", hdr->addr1); 2272 " not own MAC\n", hdr->addr1);
2273 goto done; 2273 goto done;
2274 } 2274 }
2275 2275
2276 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN)) { 2276 if (!ether_addr_equal(hdr->addr3, dev->dev_addr)) {
2277 PDEBUG(DEBUG_AP, "handle_ap_item - addr3(BSSID)=%pM" 2277 PDEBUG(DEBUG_AP, "handle_ap_item - addr3(BSSID)=%pM"
2278 " not own MAC\n", hdr->addr3); 2278 " not own MAC\n", hdr->addr3);
2279 goto done; 2279 goto done;
@@ -3035,7 +3035,7 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
3035 if (!wds) { 3035 if (!wds) {
3036 /* FromDS frame - not for us; probably 3036 /* FromDS frame - not for us; probably
3037 * broadcast/multicast in another BSS - drop */ 3037 * broadcast/multicast in another BSS - drop */
3038 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) { 3038 if (ether_addr_equal(hdr->addr1, dev->dev_addr)) {
3039 printk(KERN_DEBUG "Odd.. FromDS packet " 3039 printk(KERN_DEBUG "Odd.. FromDS packet "
3040 "received with own BSSID\n"); 3040 "received with own BSSID\n");
3041 hostap_dump_rx_80211(dev->name, skb, rx_stats); 3041 hostap_dump_rx_80211(dev->name, skb, rx_stats);
@@ -3044,7 +3044,7 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
3044 goto out; 3044 goto out;
3045 } 3045 }
3046 } else if (stype == IEEE80211_STYPE_NULLFUNC && sta == NULL && 3046 } else if (stype == IEEE80211_STYPE_NULLFUNC && sta == NULL &&
3047 memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) { 3047 ether_addr_equal(hdr->addr1, dev->dev_addr)) {
3048 3048
3049 if (local->hostapd) { 3049 if (local->hostapd) {
3050 prism2_rx_80211(local->apdev, skb, rx_stats, 3050 prism2_rx_80211(local->apdev, skb, rx_stats,
@@ -3073,7 +3073,7 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
3073 /* If BSSID (Addr3) is foreign, this frame is a normal 3073 /* If BSSID (Addr3) is foreign, this frame is a normal
3074 * broadcast frame from an IBSS network. Drop it silently. 3074 * broadcast frame from an IBSS network. Drop it silently.
3075 * If BSSID is own, report the dropping of this frame. */ 3075 * If BSSID is own, report the dropping of this frame. */
3076 if (memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) { 3076 if (ether_addr_equal(hdr->addr3, dev->dev_addr)) {
3077 printk(KERN_DEBUG "%s: dropped received packet from %pM" 3077 printk(KERN_DEBUG "%s: dropped received packet from %pM"
3078 " with no ToDS flag " 3078 " with no ToDS flag "
3079 "(type=0x%02x, subtype=0x%02x)\n", dev->name, 3079 "(type=0x%02x, subtype=0x%02x)\n", dev->name,
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index c275dc1623fe..6df3ee561d52 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -2175,7 +2175,7 @@ static void hostap_tx_callback(local_info_t *local,
2175 struct hostap_tx_callback_info *cb; 2175 struct hostap_tx_callback_info *cb;
2176 2176
2177 /* Make sure that frame was from us. */ 2177 /* Make sure that frame was from us. */
2178 if (memcmp(txdesc->addr2, local->dev->dev_addr, ETH_ALEN)) { 2178 if (!ether_addr_equal(txdesc->addr2, local->dev->dev_addr)) {
2179 printk(KERN_DEBUG "%s: TX callback - foreign frame\n", 2179 printk(KERN_DEBUG "%s: TX callback - foreign frame\n",
2180 local->dev->name); 2180 local->dev->name);
2181 return; 2181 return;
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index e5090309824e..2454a740ea50 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -655,7 +655,7 @@ static int hostap_join_ap(struct net_device *dev)
655 if (!local->last_scan_results) 655 if (!local->last_scan_results)
656 break; 656 break;
657 entry = &local->last_scan_results[i]; 657 entry = &local->last_scan_results[i];
658 if (memcmp(local->preferred_ap, entry->bssid, ETH_ALEN) == 0) { 658 if (ether_addr_equal(local->preferred_ap, entry->bssid)) {
659 req.channel = entry->chid; 659 req.channel = entry->chid;
660 break; 660 break;
661 } 661 }
@@ -1978,7 +1978,7 @@ static inline int prism2_translate_scan(local_info_t *local,
1978 list_for_each(ptr, &local->bss_list) { 1978 list_for_each(ptr, &local->bss_list) {
1979 struct hostap_bss_info *bss; 1979 struct hostap_bss_info *bss;
1980 bss = list_entry(ptr, struct hostap_bss_info, list); 1980 bss = list_entry(ptr, struct hostap_bss_info, list);
1981 if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) { 1981 if (ether_addr_equal(bss->bssid, scan->bssid)) {
1982 bss->included = 1; 1982 bss->included = 1;
1983 current_ev = __prism2_translate_scan( 1983 current_ev = __prism2_translate_scan(
1984 local, info, scan, bss, current_ev, 1984 local, info, scan, bss, current_ev,
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index a1257c92afc4..67db34e56d7e 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -155,8 +155,7 @@ int prism2_wds_add(local_info_t *local, u8 *remote_addr,
155 155
156 if (prism2_wds_special_addr(iface->u.wds.remote_addr)) 156 if (prism2_wds_special_addr(iface->u.wds.remote_addr))
157 empty = iface; 157 empty = iface;
158 else if (memcmp(iface->u.wds.remote_addr, remote_addr, 158 else if (ether_addr_equal(iface->u.wds.remote_addr, remote_addr)) {
159 ETH_ALEN) == 0) {
160 match = iface; 159 match = iface;
161 break; 160 break;
162 } 161 }
@@ -214,8 +213,7 @@ int prism2_wds_del(local_info_t *local, u8 *remote_addr,
214 if (iface->type != HOSTAP_INTERFACE_WDS) 213 if (iface->type != HOSTAP_INTERFACE_WDS)
215 continue; 214 continue;
216 215
217 if (memcmp(iface->u.wds.remote_addr, remote_addr, 216 if (ether_addr_equal(iface->u.wds.remote_addr, remote_addr)) {
218 ETH_ALEN) == 0) {
219 selected = iface; 217 selected = iface;
220 break; 218 break;
221 } 219 }
@@ -1085,7 +1083,7 @@ int prism2_sta_deauth(local_info_t *local, u16 reason)
1085 1083
1086 if (local->iw_mode != IW_MODE_INFRA || 1084 if (local->iw_mode != IW_MODE_INFRA ||
1087 is_zero_ether_addr(local->bssid) || 1085 is_zero_ether_addr(local->bssid) ||
1088 memcmp(local->bssid, "\x44\x44\x44\x44\x44\x44", ETH_ALEN) == 0) 1086 ether_addr_equal(local->bssid, "\x44\x44\x44\x44\x44\x44"))
1089 return 0; 1087 return 0;
1090 1088
1091 ret = prism2_sta_send_mgmt(local, local->bssid, IEEE80211_STYPE_DEAUTH, 1089 ret = prism2_sta_send_mgmt(local, local->bssid, IEEE80211_STYPE_DEAUTH,