aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mesh_hwmp.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/mesh_hwmp.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/mesh_hwmp.c')
-rw-r--r--net/mac80211/mesh_hwmp.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 639db14f43d..ae82ea75bc7 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);