diff options
author | Felix Fietkau <nbd@openwrt.org> | 2012-03-18 17:58:04 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-04-09 16:09:35 -0400 |
commit | c6fb08aaa879d1a70ed01e9ac1080066abf7ef78 (patch) | |
tree | 0ee780fb5dd69fb2dc083fba6f037403597a43f9 /net/wireless | |
parent | 4272a27f2f5773f4e4cb5285feba655450a720a8 (diff) |
cfg80211: use compare_ether_addr on MAC addresses instead of memcmp
Because of the constant size and guaranteed 16 bit alignment, the inline
compare_ether_addr function is much cheaper than calling memcmp.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/mlme.c | 32 | ||||
-rw-r--r-- | net/wireless/scan.c | 2 |
2 files changed, 18 insertions, 16 deletions
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index f5a7ac3a0939..e14fdcc1d7cd 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/etherdevice.h> | ||
9 | #include <linux/netdevice.h> | 10 | #include <linux/netdevice.h> |
10 | #include <linux/nl80211.h> | 11 | #include <linux/nl80211.h> |
11 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
@@ -100,7 +101,7 @@ void __cfg80211_send_deauth(struct net_device *dev, | |||
100 | ASSERT_WDEV_LOCK(wdev); | 101 | ASSERT_WDEV_LOCK(wdev); |
101 | 102 | ||
102 | if (wdev->current_bss && | 103 | if (wdev->current_bss && |
103 | memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { | 104 | compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) { |
104 | cfg80211_unhold_bss(wdev->current_bss); | 105 | cfg80211_unhold_bss(wdev->current_bss); |
105 | cfg80211_put_bss(&wdev->current_bss->pub); | 106 | cfg80211_put_bss(&wdev->current_bss->pub); |
106 | wdev->current_bss = NULL; | 107 | wdev->current_bss = NULL; |
@@ -115,7 +116,7 @@ void __cfg80211_send_deauth(struct net_device *dev, | |||
115 | 116 | ||
116 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); | 117 | reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); |
117 | 118 | ||
118 | from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0; | 119 | from_ap = compare_ether_addr(mgmt->sa, dev->dev_addr) != 0; |
119 | __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); | 120 | __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); |
120 | } else if (wdev->sme_state == CFG80211_SME_CONNECTING) { | 121 | } else if (wdev->sme_state == CFG80211_SME_CONNECTING) { |
121 | __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0, | 122 | __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0, |
@@ -154,7 +155,7 @@ void __cfg80211_send_disassoc(struct net_device *dev, | |||
154 | return; | 155 | return; |
155 | 156 | ||
156 | if (wdev->current_bss && | 157 | if (wdev->current_bss && |
157 | memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { | 158 | compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) { |
158 | cfg80211_sme_disassoc(dev, wdev->current_bss); | 159 | cfg80211_sme_disassoc(dev, wdev->current_bss); |
159 | cfg80211_unhold_bss(wdev->current_bss); | 160 | cfg80211_unhold_bss(wdev->current_bss); |
160 | cfg80211_put_bss(&wdev->current_bss->pub); | 161 | cfg80211_put_bss(&wdev->current_bss->pub); |
@@ -165,7 +166,7 @@ void __cfg80211_send_disassoc(struct net_device *dev, | |||
165 | 166 | ||
166 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); | 167 | reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); |
167 | 168 | ||
168 | from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0; | 169 | from_ap = compare_ether_addr(mgmt->sa, dev->dev_addr) != 0; |
169 | __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); | 170 | __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap); |
170 | } | 171 | } |
171 | EXPORT_SYMBOL(__cfg80211_send_disassoc); | 172 | EXPORT_SYMBOL(__cfg80211_send_disassoc); |
@@ -285,7 +286,7 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
285 | return -EINVAL; | 286 | return -EINVAL; |
286 | 287 | ||
287 | if (wdev->current_bss && | 288 | if (wdev->current_bss && |
288 | memcmp(bssid, wdev->current_bss->pub.bssid, ETH_ALEN) == 0) | 289 | compare_ether_addr(bssid, wdev->current_bss->pub.bssid) == 0) |
289 | return -EALREADY; | 290 | return -EALREADY; |
290 | 291 | ||
291 | memset(&req, 0, sizeof(req)); | 292 | memset(&req, 0, sizeof(req)); |
@@ -362,7 +363,7 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | |||
362 | memset(&req, 0, sizeof(req)); | 363 | memset(&req, 0, sizeof(req)); |
363 | 364 | ||
364 | if (wdev->current_bss && prev_bssid && | 365 | if (wdev->current_bss && prev_bssid && |
365 | memcmp(wdev->current_bss->pub.bssid, prev_bssid, ETH_ALEN) == 0) { | 366 | compare_ether_addr(wdev->current_bss->pub.bssid, prev_bssid) == 0) { |
366 | /* | 367 | /* |
367 | * Trying to reassociate: Allow this to proceed and let the old | 368 | * Trying to reassociate: Allow this to proceed and let the old |
368 | * association to be dropped when the new one is completed. | 369 | * association to be dropped when the new one is completed. |
@@ -446,7 +447,8 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, | |||
446 | 447 | ||
447 | if (local_state_change) { | 448 | if (local_state_change) { |
448 | if (wdev->current_bss && | 449 | if (wdev->current_bss && |
449 | memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) { | 450 | compare_ether_addr(wdev->current_bss->pub.bssid, bssid) |
451 | == 0) { | ||
450 | cfg80211_unhold_bss(wdev->current_bss); | 452 | cfg80211_unhold_bss(wdev->current_bss); |
451 | cfg80211_put_bss(&wdev->current_bss->pub); | 453 | cfg80211_put_bss(&wdev->current_bss->pub); |
452 | wdev->current_bss = NULL; | 454 | wdev->current_bss = NULL; |
@@ -495,7 +497,7 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, | |||
495 | req.local_state_change = local_state_change; | 497 | req.local_state_change = local_state_change; |
496 | req.ie = ie; | 498 | req.ie = ie; |
497 | req.ie_len = ie_len; | 499 | req.ie_len = ie_len; |
498 | if (memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) | 500 | if (compare_ether_addr(wdev->current_bss->pub.bssid, bssid) == 0) |
499 | req.bss = &wdev->current_bss->pub; | 501 | req.bss = &wdev->current_bss->pub; |
500 | else | 502 | else |
501 | return -ENOTCONN; | 503 | return -ENOTCONN; |
@@ -758,8 +760,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
758 | break; | 760 | break; |
759 | } | 761 | } |
760 | 762 | ||
761 | if (memcmp(wdev->current_bss->pub.bssid, | 763 | if (compare_ether_addr(wdev->current_bss->pub.bssid, |
762 | mgmt->bssid, ETH_ALEN)) { | 764 | mgmt->bssid)) { |
763 | err = -ENOTCONN; | 765 | err = -ENOTCONN; |
764 | break; | 766 | break; |
765 | } | 767 | } |
@@ -772,8 +774,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
772 | break; | 774 | break; |
773 | 775 | ||
774 | /* for station, check that DA is the AP */ | 776 | /* for station, check that DA is the AP */ |
775 | if (memcmp(wdev->current_bss->pub.bssid, | 777 | if (compare_ether_addr(wdev->current_bss->pub.bssid, |
776 | mgmt->da, ETH_ALEN)) { | 778 | mgmt->da)) { |
777 | err = -ENOTCONN; | 779 | err = -ENOTCONN; |
778 | break; | 780 | break; |
779 | } | 781 | } |
@@ -781,11 +783,11 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
781 | case NL80211_IFTYPE_AP: | 783 | case NL80211_IFTYPE_AP: |
782 | case NL80211_IFTYPE_P2P_GO: | 784 | case NL80211_IFTYPE_P2P_GO: |
783 | case NL80211_IFTYPE_AP_VLAN: | 785 | case NL80211_IFTYPE_AP_VLAN: |
784 | if (memcmp(mgmt->bssid, dev->dev_addr, ETH_ALEN)) | 786 | if (compare_ether_addr(mgmt->bssid, dev->dev_addr)) |
785 | err = -EINVAL; | 787 | err = -EINVAL; |
786 | break; | 788 | break; |
787 | case NL80211_IFTYPE_MESH_POINT: | 789 | case NL80211_IFTYPE_MESH_POINT: |
788 | if (memcmp(mgmt->sa, mgmt->bssid, ETH_ALEN)) { | 790 | if (compare_ether_addr(mgmt->sa, mgmt->bssid)) { |
789 | err = -EINVAL; | 791 | err = -EINVAL; |
790 | break; | 792 | break; |
791 | } | 793 | } |
@@ -804,7 +806,7 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
804 | return err; | 806 | return err; |
805 | } | 807 | } |
806 | 808 | ||
807 | if (memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0) | 809 | if (compare_ether_addr(mgmt->sa, dev->dev_addr) != 0) |
808 | return -EINVAL; | 810 | return -EINVAL; |
809 | 811 | ||
810 | /* Transmit the Action frame as requested by user space */ | 812 | /* Transmit the Action frame as requested by user space */ |
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 70faadf16a32..fdbcfe692a36 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
@@ -378,7 +378,7 @@ static int cmp_bss_core(struct cfg80211_bss *a, | |||
378 | b->len_information_elements); | 378 | b->len_information_elements); |
379 | } | 379 | } |
380 | 380 | ||
381 | return memcmp(a->bssid, b->bssid, ETH_ALEN); | 381 | return compare_ether_addr(a->bssid, b->bssid); |
382 | } | 382 | } |
383 | 383 | ||
384 | static int cmp_bss(struct cfg80211_bss *a, | 384 | static int cmp_bss(struct cfg80211_bss *a, |