aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mlme.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-03-01 09:22:09 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-03-05 15:38:31 -0500
commit888d04dfbe7e09f930fdaafb257cce2c54c9c3f3 (patch)
treecdf0c4d4008860fd91db31bcc620a8ecd3d95bc1 /net/mac80211/mlme.c
parent4d196e4b2ffd734393b54f351507462f19d737b5 (diff)
mac80211: 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> Acked-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r--net/mac80211/mlme.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index caf97f5a2937..7190da4f2138 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1822,7 +1822,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
1822 1822
1823 memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN); 1823 memcpy(bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN);
1824 1824
1825 if (memcmp(bssid, mgmt->bssid, ETH_ALEN)) 1825 if (compare_ether_addr(bssid, mgmt->bssid))
1826 return RX_MGMT_NONE; 1826 return RX_MGMT_NONE;
1827 1827
1828 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); 1828 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
@@ -1903,7 +1903,7 @@ ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
1903 return RX_MGMT_NONE; 1903 return RX_MGMT_NONE;
1904 1904
1905 if (!ifmgd->associated || 1905 if (!ifmgd->associated ||
1906 memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN)) 1906 compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
1907 return RX_MGMT_NONE; 1907 return RX_MGMT_NONE;
1908 1908
1909 bssid = ifmgd->associated->bssid; 1909 bssid = ifmgd->associated->bssid;
@@ -1936,7 +1936,7 @@ ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
1936 return RX_MGMT_NONE; 1936 return RX_MGMT_NONE;
1937 1937
1938 if (!ifmgd->associated || 1938 if (!ifmgd->associated ||
1939 memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN)) 1939 compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
1940 return RX_MGMT_NONE; 1940 return RX_MGMT_NONE;
1941 1941
1942 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); 1942 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
@@ -2203,7 +2203,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
2203 2203
2204 if (!assoc_data) 2204 if (!assoc_data)
2205 return RX_MGMT_NONE; 2205 return RX_MGMT_NONE;
2206 if (memcmp(assoc_data->bss->bssid, mgmt->bssid, ETH_ALEN)) 2206 if (compare_ether_addr(assoc_data->bss->bssid, mgmt->bssid))
2207 return RX_MGMT_NONE; 2207 return RX_MGMT_NONE;
2208 2208
2209 /* 2209 /*
@@ -2291,8 +2291,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
2291 bool need_ps = false; 2291 bool need_ps = false;
2292 2292
2293 if (sdata->u.mgd.associated && 2293 if (sdata->u.mgd.associated &&
2294 memcmp(mgmt->bssid, sdata->u.mgd.associated->bssid, 2294 compare_ether_addr(mgmt->bssid, sdata->u.mgd.associated->bssid)
2295 ETH_ALEN) == 0) { 2295 == 0) {
2296 bss = (void *)sdata->u.mgd.associated->priv; 2296 bss = (void *)sdata->u.mgd.associated->priv;
2297 /* not previously set so we may need to recalc */ 2297 /* not previously set so we may need to recalc */
2298 need_ps = !bss->dtim_period; 2298 need_ps = !bss->dtim_period;
@@ -2347,7 +2347,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
2347 2347
2348 ASSERT_MGD_MTX(ifmgd); 2348 ASSERT_MGD_MTX(ifmgd);
2349 2349
2350 if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN)) 2350 if (compare_ether_addr(mgmt->da, sdata->vif.addr))
2351 return; /* ignore ProbeResp to foreign address */ 2351 return; /* ignore ProbeResp to foreign address */
2352 2352
2353 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; 2353 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
@@ -2360,11 +2360,12 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
2360 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); 2360 ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false);
2361 2361
2362 if (ifmgd->associated && 2362 if (ifmgd->associated &&
2363 memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN) == 0) 2363 compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid) == 0)
2364 ieee80211_reset_ap_probe(sdata); 2364 ieee80211_reset_ap_probe(sdata);
2365 2365
2366 if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies && 2366 if (ifmgd->auth_data && !ifmgd->auth_data->bss->proberesp_ies &&
2367 memcmp(mgmt->bssid, ifmgd->auth_data->bss->bssid, ETH_ALEN) == 0) { 2367 compare_ether_addr(mgmt->bssid, ifmgd->auth_data->bss->bssid)
2368 == 0) {
2368 /* got probe response, continue with auth */ 2369 /* got probe response, continue with auth */
2369 printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name); 2370 printk(KERN_DEBUG "%s: direct probe responded\n", sdata->name);
2370 ifmgd->auth_data->tries = 0; 2371 ifmgd->auth_data->tries = 0;
@@ -2421,7 +2422,8 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2421 return; 2422 return;
2422 2423
2423 if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && 2424 if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon &&
2424 memcmp(mgmt->bssid, ifmgd->assoc_data->bss->bssid, ETH_ALEN) == 0) { 2425 compare_ether_addr(mgmt->bssid, ifmgd->assoc_data->bss->bssid)
2426 == 0) {
2425 ieee802_11_parse_elems(mgmt->u.beacon.variable, 2427 ieee802_11_parse_elems(mgmt->u.beacon.variable,
2426 len - baselen, &elems); 2428 len - baselen, &elems);
2427 2429
@@ -2436,7 +2438,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2436 } 2438 }
2437 2439
2438 if (!ifmgd->associated || 2440 if (!ifmgd->associated ||
2439 memcmp(mgmt->bssid, ifmgd->associated->bssid, ETH_ALEN)) 2441 compare_ether_addr(mgmt->bssid, ifmgd->associated->bssid))
2440 return; 2442 return;
2441 bssid = ifmgd->associated->bssid; 2443 bssid = ifmgd->associated->bssid;
2442 2444
@@ -3299,7 +3301,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
3299 bool match; 3301 bool match;
3300 3302
3301 /* keep sta info, bssid if matching */ 3303 /* keep sta info, bssid if matching */
3302 match = memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN) == 0; 3304 match = compare_ether_addr(ifmgd->bssid, req->bss->bssid) == 0;
3303 ieee80211_destroy_auth_data(sdata, match); 3305 ieee80211_destroy_auth_data(sdata, match);
3304 } 3306 }
3305 3307
@@ -3421,7 +3423,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
3421 goto err_clear; 3423 goto err_clear;
3422 } 3424 }
3423 } else 3425 } else
3424 WARN_ON_ONCE(memcmp(ifmgd->bssid, req->bss->bssid, ETH_ALEN)); 3426 WARN_ON_ONCE(compare_ether_addr(ifmgd->bssid, req->bss->bssid));
3425 3427
3426 if (!bss->dtim_period && 3428 if (!bss->dtim_period &&
3427 sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) { 3429 sdata->local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) {
@@ -3471,7 +3473,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
3471 sdata->name, req->bssid, req->reason_code); 3473 sdata->name, req->bssid, req->reason_code);
3472 3474
3473 if (ifmgd->associated && 3475 if (ifmgd->associated &&
3474 memcmp(ifmgd->associated->bssid, req->bssid, ETH_ALEN) == 0) 3476 compare_ether_addr(ifmgd->associated->bssid, req->bssid) == 0)
3475 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, 3477 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
3476 req->reason_code, true, frame_buf); 3478 req->reason_code, true, frame_buf);
3477 else 3479 else