diff options
| author | Felix Fietkau <nbd@openwrt.org> | 2012-03-01 09:22:09 -0500 |
|---|---|---|
| committer | John W. Linville <linville@tuxdriver.com> | 2012-03-05 15:38:31 -0500 |
| commit | 888d04dfbe7e09f930fdaafb257cce2c54c9c3f3 (patch) | |
| tree | cdf0c4d4008860fd91db31bcc620a8ecd3d95bc1 | |
| parent | 4d196e4b2ffd734393b54f351507462f19d737b5 (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>
| -rw-r--r-- | net/mac80211/ibss.c | 10 | ||||
| -rw-r--r-- | net/mac80211/mesh.c | 2 | ||||
| -rw-r--r-- | net/mac80211/mesh_hwmp.c | 19 | ||||
| -rw-r--r-- | net/mac80211/mesh_pathtbl.c | 14 | ||||
| -rw-r--r-- | net/mac80211/mlme.c | 30 | ||||
| -rw-r--r-- | net/mac80211/rx.c | 6 | ||||
| -rw-r--r-- | net/mac80211/scan.c | 3 | ||||
| -rw-r--r-- | net/mac80211/sta_info.c | 5 | ||||
| -rw-r--r-- | net/mac80211/sta_info.h | 3 | ||||
| -rw-r--r-- | net/mac80211/status.c | 3 |
10 files changed, 53 insertions, 42 deletions
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 7f9ac577600a..33fd8d9f714e 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
| @@ -66,7 +66,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
| 66 | skb_reset_tail_pointer(skb); | 66 | skb_reset_tail_pointer(skb); |
| 67 | skb_reserve(skb, sdata->local->hw.extra_tx_headroom); | 67 | skb_reserve(skb, sdata->local->hw.extra_tx_headroom); |
| 68 | 68 | ||
| 69 | if (memcmp(ifibss->bssid, bssid, ETH_ALEN)) | 69 | if (compare_ether_addr(ifibss->bssid, bssid)) |
| 70 | sta_info_flush(sdata->local, sdata); | 70 | sta_info_flush(sdata->local, sdata); |
| 71 | 71 | ||
| 72 | /* if merging, indicate to driver that we leave the old IBSS */ | 72 | /* if merging, indicate to driver that we leave the old IBSS */ |
| @@ -403,7 +403,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
| 403 | return; | 403 | return; |
| 404 | 404 | ||
| 405 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC && | 405 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC && |
| 406 | memcmp(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) { | 406 | compare_ether_addr(mgmt->bssid, sdata->u.ibss.bssid) == 0) { |
| 407 | 407 | ||
| 408 | rcu_read_lock(); | 408 | rcu_read_lock(); |
| 409 | sta = sta_info_get(sdata, mgmt->sa); | 409 | sta = sta_info_get(sdata, mgmt->sa); |
| @@ -508,7 +508,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
| 508 | goto put_bss; | 508 | goto put_bss; |
| 509 | 509 | ||
| 510 | /* same BSSID */ | 510 | /* same BSSID */ |
| 511 | if (memcmp(cbss->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) | 511 | if (compare_ether_addr(cbss->bssid, sdata->u.ibss.bssid) == 0) |
| 512 | goto put_bss; | 512 | goto put_bss; |
| 513 | 513 | ||
| 514 | if (rx_status->flag & RX_FLAG_MACTIME_MPDU) { | 514 | if (rx_status->flag & RX_FLAG_MACTIME_MPDU) { |
| @@ -831,8 +831,8 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, | |||
| 831 | if (!tx_last_beacon && is_multicast_ether_addr(mgmt->da)) | 831 | if (!tx_last_beacon && is_multicast_ether_addr(mgmt->da)) |
| 832 | return; | 832 | return; |
| 833 | 833 | ||
| 834 | if (memcmp(mgmt->bssid, ifibss->bssid, ETH_ALEN) != 0 && | 834 | if (compare_ether_addr(mgmt->bssid, ifibss->bssid) != 0 && |
| 835 | memcmp(mgmt->bssid, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0) | 835 | !is_broadcast_ether_addr(mgmt->bssid)) |
| 836 | return; | 836 | return; |
| 837 | 837 | ||
| 838 | end = ((u8 *) mgmt) + len; | 838 | end = ((u8 *) mgmt) + len; |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index c707c8bf6d2c..e5fbb7cf3562 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
| @@ -204,7 +204,7 @@ int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr, | |||
| 204 | kmem_cache_free(rm_cache, p); | 204 | kmem_cache_free(rm_cache, p); |
| 205 | --entries; | 205 | --entries; |
| 206 | } else if ((seqnum == p->seqnum) && | 206 | } else if ((seqnum == p->seqnum) && |
| 207 | (memcmp(sa, p->sa, ETH_ALEN) == 0)) | 207 | (compare_ether_addr(sa, p->sa) == 0)) |
| 208 | return -1; | 208 | return -1; |
| 209 | } | 209 | } |
| 210 | 210 | ||
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 639db14f43d2..ae82ea75bc74 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
| 11 | #include <linux/etherdevice.h> | ||
| 11 | #include <asm/unaligned.h> | 12 | #include <asm/unaligned.h> |
| 12 | #include "wme.h" | 13 | #include "wme.h" |
| 13 | #include "mesh.h" | 14 | #include "mesh.h" |
| @@ -419,7 +420,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
| 419 | new_metric = MAX_METRIC; | 420 | new_metric = MAX_METRIC; |
| 420 | exp_time = TU_TO_EXP_TIME(orig_lifetime); | 421 | exp_time = TU_TO_EXP_TIME(orig_lifetime); |
| 421 | 422 | ||
| 422 | if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) { | 423 | if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0) { |
| 423 | /* This MP is the originator, we are not interested in this | 424 | /* This MP is the originator, we are not interested in this |
| 424 | * frame, except for updating transmitter's path info. | 425 | * frame, except for updating transmitter's path info. |
| 425 | */ | 426 | */ |
| @@ -469,7 +470,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, | |||
| 469 | 470 | ||
| 470 | /* Update and check transmitter routing info */ | 471 | /* Update and check transmitter routing info */ |
| 471 | ta = mgmt->sa; | 472 | ta = mgmt->sa; |
| 472 | if (memcmp(orig_addr, ta, ETH_ALEN) == 0) | 473 | if (compare_ether_addr(orig_addr, ta) == 0) |
| 473 | fresh_info = false; | 474 | fresh_info = false; |
| 474 | else { | 475 | else { |
| 475 | fresh_info = true; | 476 | fresh_info = true; |
| @@ -530,7 +531,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, | |||
| 530 | 531 | ||
| 531 | mhwmp_dbg("received PREQ from %pM", orig_addr); | 532 | mhwmp_dbg("received PREQ from %pM", orig_addr); |
| 532 | 533 | ||
| 533 | if (memcmp(target_addr, sdata->vif.addr, ETH_ALEN) == 0) { | 534 | if (compare_ether_addr(target_addr, sdata->vif.addr) == 0) { |
| 534 | mhwmp_dbg("PREQ is for us"); | 535 | mhwmp_dbg("PREQ is for us"); |
| 535 | forward = false; | 536 | forward = false; |
| 536 | reply = true; | 537 | reply = true; |
| @@ -627,7 +628,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, | |||
| 627 | mhwmp_dbg("received PREP from %pM", PREP_IE_ORIG_ADDR(prep_elem)); | 628 | mhwmp_dbg("received PREP from %pM", PREP_IE_ORIG_ADDR(prep_elem)); |
| 628 | 629 | ||
| 629 | orig_addr = PREP_IE_ORIG_ADDR(prep_elem); | 630 | orig_addr = PREP_IE_ORIG_ADDR(prep_elem); |
| 630 | if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) | 631 | if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0) |
| 631 | /* destination, no forwarding required */ | 632 | /* destination, no forwarding required */ |
| 632 | return; | 633 | return; |
| 633 | 634 | ||
| @@ -697,10 +698,12 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, | |||
| 697 | rcu_read_lock(); | 698 | rcu_read_lock(); |
| 698 | mpath = mesh_path_lookup(target_addr, sdata); | 699 | mpath = mesh_path_lookup(target_addr, sdata); |
| 699 | if (mpath) { | 700 | if (mpath) { |
| 701 | struct sta_info *sta; | ||
| 702 | |||
| 700 | spin_lock_bh(&mpath->state_lock); | 703 | spin_lock_bh(&mpath->state_lock); |
| 704 | sta = next_hop_deref_protected(mpath); | ||
| 701 | if (mpath->flags & MESH_PATH_ACTIVE && | 705 | if (mpath->flags & MESH_PATH_ACTIVE && |
| 702 | memcmp(ta, next_hop_deref_protected(mpath)->sta.addr, | 706 | compare_ether_addr(ta, sta->sta.addr) == 0 && |
| 703 | ETH_ALEN) == 0 && | ||
| 704 | (!(mpath->flags & MESH_PATH_SN_VALID) || | 707 | (!(mpath->flags & MESH_PATH_SN_VALID) || |
| 705 | SN_GT(target_sn, mpath->sn))) { | 708 | SN_GT(target_sn, mpath->sn))) { |
| 706 | mpath->flags &= ~MESH_PATH_ACTIVE; | 709 | mpath->flags &= ~MESH_PATH_ACTIVE; |
| @@ -742,7 +745,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, | |||
| 742 | metric = rann->rann_metric; | 745 | metric = rann->rann_metric; |
| 743 | 746 | ||
| 744 | /* Ignore our own RANNs */ | 747 | /* Ignore our own RANNs */ |
| 745 | if (memcmp(orig_addr, sdata->vif.addr, ETH_ALEN) == 0) | 748 | if (compare_ether_addr(orig_addr, sdata->vif.addr) == 0) |
| 746 | return; | 749 | return; |
| 747 | 750 | ||
| 748 | mhwmp_dbg("received RANN from %pM via neighbour %pM (is_gate=%d)", | 751 | mhwmp_dbg("received RANN from %pM via neighbour %pM (is_gate=%d)", |
| @@ -1074,7 +1077,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, | |||
| 1074 | if (time_after(jiffies, | 1077 | if (time_after(jiffies, |
| 1075 | mpath->exp_time - | 1078 | mpath->exp_time - |
| 1076 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && | 1079 | msecs_to_jiffies(sdata->u.mesh.mshcfg.path_refresh_time)) && |
| 1077 | !memcmp(sdata->vif.addr, hdr->addr4, ETH_ALEN) && | 1080 | !compare_ether_addr(sdata->vif.addr, hdr->addr4) && |
| 1078 | !(mpath->flags & MESH_PATH_RESOLVING) && | 1081 | !(mpath->flags & MESH_PATH_RESOLVING) && |
| 1079 | !(mpath->flags & MESH_PATH_FIXED)) | 1082 | !(mpath->flags & MESH_PATH_FIXED)) |
| 1080 | mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); | 1083 | mesh_queue_preq(mpath, PREQ_Q_F_START | PREQ_Q_F_REFRESH); |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index dc51669e67d8..157642f780b9 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
| @@ -348,7 +348,7 @@ static struct mesh_path *mpath_lookup(struct mesh_table *tbl, u8 *dst, | |||
| 348 | hlist_for_each_entry_rcu(node, n, bucket, list) { | 348 | hlist_for_each_entry_rcu(node, n, bucket, list) { |
| 349 | mpath = node->mpath; | 349 | mpath = node->mpath; |
| 350 | if (mpath->sdata == sdata && | 350 | if (mpath->sdata == sdata && |
| 351 | memcmp(dst, mpath->dst, ETH_ALEN) == 0) { | 351 | compare_ether_addr(dst, mpath->dst) == 0) { |
| 352 | if (MPATH_EXPIRED(mpath)) { | 352 | if (MPATH_EXPIRED(mpath)) { |
| 353 | spin_lock_bh(&mpath->state_lock); | 353 | spin_lock_bh(&mpath->state_lock); |
| 354 | mpath->flags &= ~MESH_PATH_ACTIVE; | 354 | mpath->flags &= ~MESH_PATH_ACTIVE; |
| @@ -523,7 +523,7 @@ int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata) | |||
| 523 | int err = 0; | 523 | int err = 0; |
| 524 | u32 hash_idx; | 524 | u32 hash_idx; |
| 525 | 525 | ||
| 526 | if (memcmp(dst, sdata->vif.addr, ETH_ALEN) == 0) | 526 | if (compare_ether_addr(dst, sdata->vif.addr) == 0) |
| 527 | /* never add ourselves as neighbours */ | 527 | /* never add ourselves as neighbours */ |
| 528 | return -ENOTSUPP; | 528 | return -ENOTSUPP; |
| 529 | 529 | ||
| @@ -564,7 +564,8 @@ int mesh_path_add | |||
