Skip to contentSkip to conversation

net,drivers/net: Use ether_addr_equal and ether_addr_equal_64bits

PATCH Applied Joe Perches 4 participants 16 messages May 10, 2012 – May 31, 2012 1 message not in the archive

Subsystems (13)
lore
Share & tools
lore
#0 lore raw

cover net,drivers/net: Use ether_addr_equal and ether_addr_equal_64bits

Joe Perches (3):
drivers/net: Convert compare_ether_addr to ether_addr_equal etherdevice.h: Add ether_addr_equal_64bits
net,drivers/net: Convert compare_ether_addr_64bits to ether_addr_equal_64bits

 drivers/net/bonding/bond_alb.c                    |   58 ++++++++++----------
 drivers/net/bonding/bond_main.c                   |    2 +-
 drivers/net/ethernet/amd/depca.c                  |    3 +-
 drivers/net/ethernet/cisco/enic/enic_main.c       |   12 ++---
 drivers/net/ethernet/dec/ewrk3.c                  |    3 +-
 drivers/net/ethernet/dec/tulip/de4x5.c            |    2 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c  |    5 +-
 drivers/net/ethernet/sfc/ethtool.c                |    2 +-
 drivers/net/ethernet/sun/sunvnet.c                |    2 +-
 drivers/net/ethernet/tile/tilepro.c               |    2 +-
 drivers/net/ethernet/toshiba/ps3_gelic_wireless.c |    8 ++--
 drivers/net/macvlan.c                             |    7 +--
 drivers/net/tun.c                                 |    2 +-
 drivers/net/wireless/at76c50x-usb.c               |    2 +-
 drivers/net/wireless/ath/ath5k/base.c             |    6 +-
 drivers/net/wireless/ath/ath9k/recv.c             |    2 +-
 drivers/net/wireless/ath/carl9170/rx.c            |    2 +-
 drivers/net/wireless/ipw2x00/libipw_rx.c          |   16 +++---
 drivers/net/wireless/iwlegacy/3945.c              |    4 +-
 drivers/net/wireless/iwlegacy/4965-mac.c          |    2 +-
 drivers/net/wireless/iwlegacy/common.c            |   14 +++---
 drivers/net/wireless/iwlwifi/iwl-agn-rx.c         |    4 +-
 drivers/net/wireless/iwlwifi/iwl-agn-rxon.c       |    8 ++--
 drivers/net/wireless/iwlwifi/iwl-agn-sta.c        |    6 +-
 drivers/net/wireless/mwl8k.c                      |    2 +-
 drivers/net/wireless/p54/txrx.c                   |    2 +-
 drivers/net/wireless/rndis_wlan.c                 |   12 ++--
 drivers/net/wireless/rtlwifi/base.c               |    2 +-
 drivers/net/wireless/rtlwifi/ps.c                 |    2 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/trx.c      |   10 ++--
 drivers/net/wireless/rtlwifi/rtl8192cu/mac.c      |   10 ++--
 drivers/net/wireless/rtlwifi/rtl8192de/trx.c      |   11 ++--
 drivers/net/wireless/rtlwifi/rtl8192se/trx.c      |   11 ++--
 include/linux/etherdevice.h                       |   20 +++++++
 net/ethernet/eth.c                                |    5 +-
 35 files changed, 140 insertions(+), 121 deletions(-)
Signature · 1 line
1.7.8.111.gad25c.dirty
#1 lore raw

PATCH 1/3 drivers/net: Convert compare_ether_addr to ether_addr_equal

Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.

Done via cocci script:

$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
-	!compare_ether_addr(a, b)
+	ether_addr_equal(a, b)

@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)

@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)

@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)

@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)

@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)

@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)

---
 drivers/net/bonding/bond_main.c                   |    2 +-
 drivers/net/ethernet/amd/depca.c                  |    3 ++-
 drivers/net/ethernet/cisco/enic/enic_main.c       |   12 ++++--------
 drivers/net/ethernet/dec/ewrk3.c                  |    3 ++-
 drivers/net/ethernet/dec/tulip/de4x5.c            |    2 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c  |    5 ++---
 drivers/net/ethernet/sfc/ethtool.c                |    2 +-
 drivers/net/ethernet/sun/sunvnet.c                |    2 +-
 drivers/net/ethernet/tile/tilepro.c               |    2 +-
 drivers/net/ethernet/toshiba/ps3_gelic_wireless.c |    8 ++++----
 drivers/net/tun.c                                 |    2 +-
 drivers/net/wireless/at76c50x-usb.c               |    2 +-
 drivers/net/wireless/ath/ath5k/base.c             |    6 +++---
 drivers/net/wireless/ath/ath9k/recv.c             |    2 +-
 drivers/net/wireless/ath/carl9170/rx.c            |    2 +-
 drivers/net/wireless/ipw2x00/libipw_rx.c          |   16 ++++++++--------
 drivers/net/wireless/iwlegacy/3945.c              |    4 ++--
 drivers/net/wireless/iwlegacy/4965-mac.c          |    2 +-
 drivers/net/wireless/iwlegacy/common.c            |   14 +++++++-------
 drivers/net/wireless/iwlwifi/iwl-agn-rx.c         |    4 ++--
 drivers/net/wireless/iwlwifi/iwl-agn-rxon.c       |    8 ++++----
 drivers/net/wireless/iwlwifi/iwl-agn-sta.c        |    6 +++---
 drivers/net/wireless/mwl8k.c                      |    2 +-
 drivers/net/wireless/p54/txrx.c                   |    2 +-
 drivers/net/wireless/rndis_wlan.c                 |   12 ++++++------
 drivers/net/wireless/rtlwifi/base.c               |    2 +-
 drivers/net/wireless/rtlwifi/ps.c                 |    2 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/trx.c      |   10 +++++-----
 drivers/net/wireless/rtlwifi/rtl8192cu/mac.c      |   10 +++++-----
 drivers/net/wireless/rtlwifi/rtl8192de/trx.c      |   11 ++++++-----
 drivers/net/wireless/rtlwifi/rtl8192se/trx.c      |   11 ++++++-----
 31 files changed, 85 insertions(+), 86 deletions(-)
drivers/net/bonding/bond_main.c +1 -1
index 16dbf53..bbb0043 100644
@@ -1961,7 +1961,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
 	write_lock_bh(&bond->lock);
 
 	if (!bond->params.fail_over_mac) {
-		if (!compare_ether_addr(bond_dev->dev_addr, slave->perm_hwaddr) &&
+		if (ether_addr_equal(bond_dev->dev_addr, slave->perm_hwaddr) &&
 		    bond->slave_cnt > 1)
 			pr_warning("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s. Set the HWaddr of %s to a different address to avoid conflicts.\n",
 				   bond_dev->name, slave_dev->name,
drivers/net/ethernet/amd/depca.c +2 -1
index 86dd957..7f7b99a 100644
@@ -1079,7 +1079,8 @@ static int depca_rx(struct net_device *dev)
 						} else {
 							lp->pktStats.multicast++;
 						}
-					} else if (compare_ether_addr(buf, dev->dev_addr) == 0) {
+					} else if (ether_addr_equal(buf,
+								    dev->dev_addr)) {
 						lp->pktStats.unicast++;
 					}
 
drivers/net/ethernet/cisco/enic/enic_main.c +4 -8
index d7ac6c1..8132c78 100644
@@ -944,8 +944,7 @@ static void enic_update_multicast_addr_list(struct enic *enic)
 
 	for (i = 0; i < enic->mc_count; i++) {
 		for (j = 0; j < mc_count; j++)
-			if (compare_ether_addr(enic->mc_addr[i],
-				mc_addr[j]) == 0)
+			if (ether_addr_equal(enic->mc_addr[i], mc_addr[j]))
 				break;
 		if (j == mc_count)
 			enic_dev_del_addr(enic, enic->mc_addr[i]);
@@ -953,8 +952,7 @@ static void enic_update_multicast_addr_list(struct enic *enic)
 
 	for (i = 0; i < mc_count; i++) {
 		for (j = 0; j < enic->mc_count; j++)
-			if (compare_ether_addr(mc_addr[i],
-				enic->mc_addr[j]) == 0)
+			if (ether_addr_equal(mc_addr[i], enic->mc_addr[j]))
 				break;
 		if (j == enic->mc_count)
 			enic_dev_add_addr(enic, mc_addr[i]);
@@ -999,8 +997,7 @@ static void enic_update_unicast_addr_list(struct enic *enic)
 
 	for (i = 0; i < enic->uc_count; i++) {
 		for (j = 0; j < uc_count; j++)
-			if (compare_ether_addr(enic->uc_addr[i],
-				uc_addr[j]) == 0)
+			if (ether_addr_equal(enic->uc_addr[i], uc_addr[j]))
 				break;
 		if (j == uc_count)
 			enic_dev_del_addr(enic, enic->uc_addr[i]);
@@ -1008,8 +1005,7 @@ static void enic_update_unicast_addr_list(struct enic *enic)
 
 	for (i = 0; i < uc_count; i++) {
 		for (j = 0; j < enic->uc_count; j++)
-			if (compare_ether_addr(uc_addr[i],
-				enic->uc_addr[j]) == 0)
+			if (ether_addr_equal(uc_addr[i], enic->uc_addr[j]))
 				break;
 		if (j == enic->uc_count)
 			enic_dev_add_addr(enic, uc_addr[i]);
drivers/net/ethernet/dec/ewrk3.c +2 -1
index 1879f84..17ae8c6 100644
@@ -1016,7 +1016,8 @@ static int ewrk3_rx(struct net_device *dev)
 							} else {
 								lp->pktStats.multicast++;
 							}
-						} else if (compare_ether_addr(p, dev->dev_addr) == 0) {
+						} else if (ether_addr_equal(p,
+									    dev->dev_addr)) {
 							lp->pktStats.unicast++;
 						}
 						lp->pktStats.bins[0]++;		/* Duplicates stats.rx_packets */
drivers/net/ethernet/dec/tulip/de4x5.c +1 -1
index 18b106c..d3cd489 100644
@@ -1874,7 +1874,7 @@ de4x5_local_stats(struct net_device *dev, char *buf, int pkt_len)
 	} else {
 	    lp->pktStats.multicast++;
 	}
-    } else if (compare_ether_addr(buf, dev->dev_addr) == 0) {
+    } else if (ether_addr_equal(buf, dev->dev_addr)) {
         lp->pktStats.unicast++;
     }
 
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +2 -3
index 5c47135..46e77a2 100644
@@ -1965,7 +1965,7 @@ qlcnic_send_filter(struct qlcnic_adapter *adapter,
 	__le16 vlan_id = 0;
 	u8 hindex;
 
-	if (!compare_ether_addr(phdr->h_source, adapter->mac_addr))
+	if (ether_addr_equal(phdr->h_source, adapter->mac_addr))
 		return;
 
 	if (adapter->fhash.fnum >= adapter->fhash.fmax)
@@ -2235,8 +2235,7 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 
 	if (adapter->flags & QLCNIC_MACSPOOF) {
 		phdr = (struct ethhdr *)skb->data;
-		if (compare_ether_addr(phdr->h_source,
-					adapter->mac_addr))
+		if (!ether_addr_equal(phdr->h_source, adapter->mac_addr))
 			goto drop_packet;
 	}
 
drivers/net/ethernet/sfc/ethtool.c +1 -1
index f22f45f..62d4b81 100644
@@ -1023,7 +1023,7 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx,
 			return -EINVAL;
 
 		/* Is it a default UC or MC filter? */
-		if (!compare_ether_addr(mac_mask->h_dest, mac_addr_mc_mask) &&
+		if (ether_addr_equal(mac_mask->h_dest, mac_addr_mc_mask) &&
 		    vlan_tag_mask == 0) {
 			if (is_multicast_ether_addr(mac_entry->h_dest))
 				rc = efx_filter_set_mc_def(&spec);
drivers/net/ethernet/sun/sunvnet.c +1 -1
index 38e3ae9..a108db3 100644
@@ -618,7 +618,7 @@ struct vnet_port *__tx_port_find(struct vnet *vp, struct sk_buff *skb)
 	struct vnet_port *port;
 
 	hlist_for_each_entry(port, n, hp, hash) {
-		if (!compare_ether_addr(port->raddr, skb->data))
+		if (ether_addr_equal(port->raddr, skb->data))
 			return port;
 	}
 	port = NULL;
drivers/net/ethernet/tile/tilepro.c +1 -1
index 3d501ec..96070e9 100644
@@ -843,7 +843,7 @@ static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
 		if (!is_multicast_ether_addr(buf)) {
 			/* Filter packets not for our address. */
 			const u8 *mine = dev->dev_addr;
-			filter = compare_ether_addr(mine, buf);
+			filter = !ether_addr_equal(mine, buf);
 		}
 	}
 
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +4 -4
index 5c14f82..961c832 100644
@@ -1590,8 +1590,8 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
 		found = 0;
 		oldest = NULL;
 		list_for_each_entry(target, &wl->network_list, list) {
-			if (!compare_ether_addr(&target->hwinfo->bssid[2],
-						&scan_info->bssid[2])) {
+			if (ether_addr_equal(&target->hwinfo->bssid[2],
+					     &scan_info->bssid[2])) {
 				found = 1;
 				pr_debug("%s: same BBS found scanned list\n",
 					 __func__);
@@ -1691,8 +1691,8 @@ struct gelic_wl_scan_info *gelic_wl_find_best_bss(struct gelic_wl_info *wl)
 
 		/* If bss specified, check it only */
 		if (test_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat)) {
-			if (!compare_ether_addr(&scan_info->hwinfo->bssid[2],
-						wl->bssid)) {
+			if (ether_addr_equal(&scan_info->hwinfo->bssid[2],
+					     wl->bssid)) {
 				best_bss = scan_info;
 				pr_debug("%s: bssid matched\n", __func__);
 				break;
drivers/net/tun.c +1 -1
index bb8c72c..987aeef 100644
@@ -313,7 +313,7 @@ static int run_filter(struct tap_filter *filter, const struct sk_buff *skb)
 
 	/* Exact match */
 	for (i = 0; i < filter->count; i++)
-		if (!compare_ether_addr(eh->h_dest, filter->addr[i]))
+		if (ether_addr_equal(eh->h_dest, filter->addr[i]))
 			return 1;
 
 	/* Inexact match (multicast only) */
drivers/net/wireless/at76c50x-usb.c +1 -1
index faa8bcb..5ad74c8 100644
@@ -1751,7 +1751,7 @@ static void at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 	 * following workaround is necessary. If the TX frame is an
 	 * authentication frame extract the bssid and send the CMD_JOIN. */
 	if (mgmt->frame_control & cpu_to_le16(IEEE80211_STYPE_AUTH)) {
-		if (compare_ether_addr(priv->bssid, mgmt->bssid)) {
+		if (!ether_addr_equal(priv->bssid, mgmt->bssid)) {
 			memcpy(priv->bssid, mgmt->bssid, ETH_ALEN);
 			ieee80211_queue_work(hw, &priv->work_join_bssid);
 			dev_kfree_skb_any(skb);
drivers/net/wireless/ath/ath5k/base.c +3 -3
index 49e3b19..0ba81a6 100644
@@ -462,7 +462,7 @@ void ath5k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
 	}
 
 	if (iter_data->need_set_hw_addr && iter_data->hw_macaddr)
-		if (compare_ether_addr(iter_data->hw_macaddr, mac) == 0)
+		if (ether_addr_equal(iter_data->hw_macaddr, mac))
 			iter_data->need_set_hw_addr = false;
 
 	if (!iter_data->any_assoc) {
@@ -1170,7 +1170,7 @@ ath5k_check_ibss_tsf(struct ath5k_hw *ah, struct sk_buff *skb,
 
 	if (ieee80211_is_beacon(mgmt->frame_control) &&
 	    le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS &&
-	    compare_ether_addr(mgmt->bssid, common->curbssid) == 0) {
+	    ether_addr_equal(mgmt->bssid, common->curbssid)) {
 		/*
 		 * Received an IBSS beacon with the same BSSID. Hardware *must*
 		 * have updated the local TSF. We have to work around various
@@ -1234,7 +1234,7 @@ ath5k_update_beacon_rssi(struct ath5k_hw *ah, struct sk_buff *skb, int rssi)
 
 	/* only beacons from our BSSID */
 	if (!ieee80211_is_beacon(mgmt->frame_control) ||
-	    compare_ether_addr(mgmt->bssid, common->curbssid) != 0)
+	    !ether_addr_equal(mgmt->bssid, common->curbssid))
 		return;
 
 	ewma_add(&ah->ah_beacon_rssi_avg, rssi);
drivers/net/wireless/ath/ath9k/recv.c +1 -1
index 544e549..e1fcc68 100644
@@ -1833,7 +1833,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
 		if (ieee80211_is_beacon(hdr->frame_control)) {
 			RX_STAT_INC(rx_beacons);
 			if (!is_zero_ether_addr(common->curbssid) &&
-			    !compare_ether_addr(hdr->addr3, common->curbssid))
+			    ether_addr_equal(hdr->addr3, common->curbssid))
 				rs.is_mybeacon = true;
 			else
 				rs.is_mybeacon = false;
drivers/net/wireless/ath/carl9170/rx.c +1 -1
index dc99030..84b22ee 100644
@@ -538,7 +538,7 @@ static void carl9170_ps_beacon(struct ar9170 *ar, void *data, unsigned int len)
 		return;
 
 	/* and only beacons from the associated BSSID, please */
-	if (compare_ether_addr(hdr->addr3, ar->common.curbssid) ||
+	if (!ether_addr_equal(hdr->addr3, ar->common.curbssid) ||
 	    !ar->common.curaid)
 		return;
 
drivers/net/wireless/ipw2x00/libipw_rx.c +8 -8
index c4955d2..02e0579 100644
@@ -77,8 +77,8 @@ static struct libipw_frag_entry *libipw_frag_cache_find(struct
 
 		if (entry->skb != NULL && entry->seq == seq &&
 		    (entry->last_frag + 1 == frag || frag == -1) &&
-		    !compare_ether_addr(entry->src_addr, src) &&
-		    !compare_ether_addr(entry->dst_addr, dst))
+		    ether_addr_equal(entry->src_addr, src) &&
+		    ether_addr_equal(entry->dst_addr, dst))
 			return entry;
 	}
 
@@ -245,12 +245,12 @@ static int libipw_is_eapol_frame(struct libipw_device *ieee,
 	/* check that the frame is unicast frame to us */
 	if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
 	    IEEE80211_FCTL_TODS &&
-	    !compare_ether_addr(hdr->addr1, dev->dev_addr) &&
-	    !compare_ether_addr(hdr->addr3, dev->dev_addr)) {
+	    ether_addr_equal(hdr->addr1, dev->dev_addr) &&
+	    ether_addr_equal(hdr->addr3, dev->dev_addr)) {
 		/* ToDS frame with own addr BSSID and DA */
 	} else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
 		   IEEE80211_FCTL_FROMDS &&
-		   !compare_ether_addr(hdr->addr1, dev->dev_addr)) {
+		   ether_addr_equal(hdr->addr1, dev->dev_addr)) {
 		/* FromDS frame with own addr as DA */
 	} else
 		return 0;
@@ -523,8 +523,8 @@ int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
 
 	if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
 	    (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
-	    IEEE80211_FCTL_FROMDS && ieee->stadev
-	    && !compare_ether_addr(hdr->addr2, ieee->assoc_ap_addr)) {
+	    IEEE80211_FCTL_FROMDS && ieee->stadev &&
+	    ether_addr_equal(hdr->addr2, ieee->assoc_ap_addr)) {
 		/* Frame from BSSID of the AP for which we are a client */
 		skb->dev = dev = ieee->stadev;
 		stats = hostap_get_stats(dev);
@@ -1468,7 +1468,7 @@ static inline int is_same_network(struct libipw_network *src,
 	 * as one network */
 	return ((src->ssid_len == dst->ssid_len) &&
 		(src->channel == dst->channel) &&
-		!compare_ether_addr(src->bssid, dst->bssid) &&
+		ether_addr_equal(src->bssid, dst->bssid) &&
 		!memcmp(src->ssid, dst->ssid, src->ssid_len));
 }
 
drivers/net/wireless/iwlegacy/3945.c +2 -2
index b25c01b..87e5398 100644
@@ -453,10 +453,10 @@ il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header)
 	switch (il->iw_mode) {
 	case NL80211_IFTYPE_ADHOC:	/* Header: Dest. | Source    | BSSID */
 		/* packets to our IBSS update information */
-		return !compare_ether_addr(header->addr3, il->bssid);
+		return ether_addr_equal(header->addr3, il->bssid);
 	case NL80211_IFTYPE_STATION:	/* Header: Dest. | AP{BSSID} | Source */
 		/* packets to our IBSS update information */
-		return !compare_ether_addr(header->addr2, il->bssid);
+		return ether_addr_equal(header->addr2, il->bssid);
 	default:
 		return 1;
 	}
drivers/net/wireless/iwlegacy/4965-mac.c +1 -1
index f2baf94..509301a 100644
@@ -2565,7 +2565,7 @@ il4965_find_station(struct il_priv *il, const u8 *addr)
 	spin_lock_irqsave(&il->sta_lock, flags);
 	for (i = start; i < il->hw_params.max_stations; i++)
 		if (il->stations[i].used &&
-		    (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) {
+		    ether_addr_equal(il->stations[i].sta.sta.addr, addr)) {
 			ret = i;
 			goto out;
 		}
drivers/net/wireless/iwlegacy/common.c +7 -7
index eaf24945..cbf2dc1 100644
@@ -1896,8 +1896,8 @@ il_prep_station(struct il_priv *il, const u8 *addr, bool is_ap,
 		sta_id = il->hw_params.bcast_id;
 	else
 		for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) {
-			if (!compare_ether_addr
-			    (il->stations[i].sta.sta.addr, addr)) {
+			if (ether_addr_equal(il->stations[i].sta.sta.addr,
+					     addr)) {
 				sta_id = i;
 				break;
 			}
@@ -1926,7 +1926,7 @@ il_prep_station(struct il_priv *il, const u8 *addr, bool is_ap,
 
 	if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) &&
 	    (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) &&
-	    !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) {
+	    ether_addr_equal(il->stations[sta_id].sta.sta.addr, addr)) {
 		D_ASSOC("STA %d (%pM) already added, not adding again.\n",
 			sta_id, addr);
 		return sta_id;
@@ -3744,10 +3744,10 @@ il_full_rxon_required(struct il_priv *il)
 
 	/* These items are only settable from the full RXON command */
 	CHK(!il_is_associated(il));
-	CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr));
-	CHK(compare_ether_addr(staging->node_addr, active->node_addr));
-	CHK(compare_ether_addr
-	    (staging->wlap_bssid_addr, active->wlap_bssid_addr));
+	CHK(!ether_addr_equal(staging->bssid_addr, active->bssid_addr));
+	CHK(!ether_addr_equal(staging->node_addr, active->node_addr));
+	CHK(!ether_addr_equal(staging->wlap_bssid_addr,
+			      active->wlap_bssid_addr));
 	CHK_NEQ(staging->dev_type, active->dev_type);
 	CHK_NEQ(staging->channel, active->channel);
 	CHK_NEQ(staging->air_propagation, active->air_propagation);
drivers/net/wireless/iwlwifi/iwl-agn-rx.c +2 -2
index 0c252c5..779f819 100644
@@ -779,8 +779,8 @@ static void iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
 	*/
 	if (unlikely(ieee80211_is_beacon(fc) && priv->passive_no_rx)) {
 		for_each_context(priv, ctx) {
-			if (compare_ether_addr(hdr->addr3,
-					       ctx->active.bssid_addr))
+			if (!ether_addr_equal(hdr->addr3,
+					      ctx->active.bssid_addr))
 				continue;
 			iwlagn_lift_passive_no_rx(priv);
 		}
drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +4 -4
index 0f7c444..74fbee6 100644
@@ -881,10 +881,10 @@ int iwl_full_rxon_required(struct iwl_priv *priv,
 
 	/* These items are only settable from the full RXON command */
 	CHK(!iwl_is_associated_ctx(ctx));
-	CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr));
-	CHK(compare_ether_addr(staging->node_addr, active->node_addr));
-	CHK(compare_ether_addr(staging->wlap_bssid_addr,
-				active->wlap_bssid_addr));
+	CHK(!ether_addr_equal(staging->bssid_addr, active->bssid_addr));
+	CHK(!ether_addr_equal(staging->node_addr, active->node_addr));
+	CHK(!ether_addr_equal(staging->wlap_bssid_addr,
+			      active->wlap_bssid_addr));
 	CHK_NEQ(staging->dev_type, active->dev_type);
 	CHK_NEQ(staging->channel, active->channel);
 	CHK_NEQ(staging->air_propagation, active->air_propagation);
drivers/net/wireless/iwlwifi/iwl-agn-sta.c +3 -3
index 67e6f1d..b31584e 100644
@@ -322,8 +322,8 @@ u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
 		sta_id = ctx->bcast_sta_id;
 	else
 		for (i = IWL_STA_ID; i < IWLAGN_STATION_COUNT; i++) {
-			if (!compare_ether_addr(priv->stations[i].sta.sta.addr,
-						addr)) {
+			if (ether_addr_equal(priv->stations[i].sta.sta.addr,
+					     addr)) {
 				sta_id = i;
 				break;
 			}
@@ -353,7 +353,7 @@ u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
 
 	if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
 	    (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) &&
-	    !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) {
+	    ether_addr_equal(priv->stations[sta_id].sta.sta.addr, addr)) {
 		IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not "
 				"adding again.\n", sta_id, addr);
 		return sta_id;
drivers/net/wireless/mwl8k.c +1 -1
index e30cc32..cf7bdc6 100644
@@ -1235,7 +1235,7 @@ mwl8k_capture_bssid(struct mwl8k_priv *priv, struct ieee80211_hdr *wh)
 {
 	return priv->capture_beacon &&
 		ieee80211_is_beacon(wh->frame_control) &&
-		!compare_ether_addr(wh->addr3, priv->capture_bssid);
+		ether_addr_equal(wh->addr3, priv->capture_bssid);
 }
 
 static inline void mwl8k_save_beacon(struct ieee80211_hw *hw,
drivers/net/wireless/p54/txrx.c +1 -1
index 7c8f118..82a1cac 100644
@@ -308,7 +308,7 @@ static void p54_pspoll_workaround(struct p54_common *priv, struct sk_buff *skb)
 		return;
 
 	/* only consider beacons from the associated BSSID */
-	if (compare_ether_addr(hdr->addr3, priv->bssid))
+	if (!ether_addr_equal(hdr->addr3, priv->bssid))
 		return;
 
 	tim = p54_find_ie(skb, WLAN_EID_TIM);
drivers/net/wireless/rndis_wlan.c +6 -6
index d66e298..dcf0e7e 100644
@@ -1801,8 +1801,8 @@ static struct ndis_80211_pmkid *remove_pmkid(struct usbnet *usbdev,
 		count = max_pmkids;
 
 	for (i = 0; i < count; i++)
-		if (!compare_ether_addr(pmkids->bssid_info[i].bssid,
-							pmksa->bssid))
+		if (ether_addr_equal(pmkids->bssid_info[i].bssid,
+				     pmksa->bssid))
 			break;
 
 	/* pmkid not found */
@@ -1843,8 +1843,8 @@ static struct ndis_80211_pmkid *update_pmkid(struct usbnet *usbdev,
 
 	/* update with new pmkid */
 	for (i = 0; i < count; i++) {
-		if (compare_ether_addr(pmkids->bssid_info[i].bssid,
-							pmksa->bssid))
+		if (!ether_addr_equal(pmkids->bssid_info[i].bssid,
+				      pmksa->bssid))
 			continue;
 
 		memcpy(pmkids->bssid_info[i].pmkid, pmksa->pmkid,
@@ -2139,7 +2139,7 @@ resize_buf:
 	while (check_bssid_list_item(bssid, bssid_len, buf, len)) {
 		if (rndis_bss_info_update(usbdev, bssid) && match_bssid &&
 		    matched) {
-			if (compare_ether_addr(bssid->mac, match_bssid))
+			if (!ether_addr_equal(bssid->mac, match_bssid))
 				*matched = true;
 		}
 
@@ -2531,7 +2531,7 @@ static int rndis_get_station(struct wiphy *wiphy, struct net_device *dev,
 	struct rndis_wlan_private *priv = wiphy_priv(wiphy);
 	struct usbnet *usbdev = priv->usbdev;
 
-	if (compare_ether_addr(priv->bssid, mac))
+	if (!ether_addr_equal(priv->bssid, mac))
 		return -ENOENT;
 
 	rndis_fill_station_info(usbdev, sinfo);
drivers/net/wireless/rtlwifi/base.c +1 -1
index e54488d..f4c852c 100644
@@ -1460,7 +1460,7 @@ void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len)
 		return;
 
 	/* and only beacons from the associated BSSID, please */
-	if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
+	if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
 		return;
 
 	if (rtl_find_221_ie(hw, data, len))
drivers/net/wireless/rtlwifi/ps.c +1 -1
index 5b9c3b5..5ae2664 100644
@@ -480,7 +480,7 @@ void rtl_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len)
 		return;
 
 	/* and only beacons from the associated BSSID, please */
-	if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
+	if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
 		return;
 
 	rtlpriv->psc.last_beacon = jiffies;
drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +5 -5
index 37b1363..3af874e 100644
@@ -508,14 +508,14 @@ static void _rtl92ce_translate_rx_signal_stuff(struct ieee80211_hw *hw,
 
 	packet_matchbssid =
 	    ((IEEE80211_FTYPE_CTL != type) &&
-	     (!compare_ether_addr(mac->bssid,
-				  (c_fc & IEEE80211_FCTL_TODS) ?
-				  hdr->addr1 : (c_fc & IEEE80211_FCTL_FROMDS) ?
-				  hdr->addr2 : hdr->addr3)) &&
+	     ether_addr_equal(mac->bssid,
+			      (c_fc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+			      (c_fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+			      hdr->addr3) &&
 	     (!pstats->hwerror) && (!pstats->crc) && (!pstats->icv));
 
 	packet_toself = packet_matchbssid &&
-	    (!compare_ether_addr(praddr, rtlefuse->dev_addr));
+	     ether_addr_equal(praddr, rtlefuse->dev_addr);
 
 	if (ieee80211_is_beacon(fc))
 		packet_beacon = true;
drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +5 -5
index 025bdc2..7e91c76 100644
@@ -1099,14 +1099,14 @@ void rtl92c_translate_rx_signal_stuff(struct ieee80211_hw *hw,
 	praddr = hdr->addr1;
 	packet_matchbssid =
 	    ((IEEE80211_FTYPE_CTL != type) &&
-	     (!compare_ether_addr(mac->bssid,
-			  (cpu_fc & IEEE80211_FCTL_TODS) ?
-			  hdr->addr1 : (cpu_fc & IEEE80211_FCTL_FROMDS) ?
-			  hdr->addr2 : hdr->addr3)) &&
+	     ether_addr_equal(mac->bssid,
+			      (cpu_fc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+			      (cpu_fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+			      hdr->addr3) &&
 	     (!pstats->hwerror) && (!pstats->crc) && (!pstats->icv));
 
 	packet_toself = packet_matchbssid &&
-	    (!compare_ether_addr(praddr, rtlefuse->dev_addr));
+	    ether_addr_equal(praddr, rtlefuse->dev_addr);
 	if (ieee80211_is_beacon(fc))
 		packet_beacon = true;
 	_rtl92c_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
drivers/net/wireless/rtlwifi/rtl8192de/trx.c +6 -5
index a7f6126..1666ef7 100644
@@ -466,12 +466,13 @@ static void _rtl92de_translate_rx_signal_stuff(struct ieee80211_hw *hw,
 	type = WLAN_FC_GET_TYPE(fc);
 	praddr = hdr->addr1;
 	packet_matchbssid = ((IEEE80211_FTYPE_CTL != type) &&
-	     (!compare_ether_addr(mac->bssid, (cfc & IEEE80211_FCTL_TODS) ?
-		  hdr->addr1 : (cfc & IEEE80211_FCTL_FROMDS) ?
-		  hdr->addr2 : hdr->addr3)) && (!pstats->hwerror) &&
-		  (!pstats->crc) && (!pstats->icv));
+	     ether_addr_equal(mac->bssid,
+			      (cfc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+			      (cfc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+			      hdr->addr3) &&
+	     (!pstats->hwerror) && (!pstats->crc) && (!pstats->icv));
 	packet_toself = packet_matchbssid &&
-			(!compare_ether_addr(praddr, rtlefuse->dev_addr));
+			ether_addr_equal(praddr, rtlefuse->dev_addr);
 	if (ieee80211_is_beacon(fc))
 		packet_beacon = true;
 	_rtl92de_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
drivers/net/wireless/rtlwifi/rtl8192se/trx.c +6 -5
index 2fd3d13..812b585 100644
@@ -492,13 +492,14 @@ static void _rtl92se_translate_rx_signal_stuff(struct ieee80211_hw *hw,
 	praddr = hdr->addr1;
 
 	packet_matchbssid = ((IEEE80211_FTYPE_CTL != type) &&
-	     (!compare_ether_addr(mac->bssid, (cfc & IEEE80211_FCTL_TODS) ?
-			hdr->addr1 : (cfc & IEEE80211_FCTL_FROMDS) ?
-			hdr->addr2 : hdr->addr3)) && (!pstats->hwerror) &&
-			(!pstats->crc) && (!pstats->icv));
+	     ether_addr_equal(mac->bssid,
+			      (cfc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+			      (cfc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+			      hdr->addr3) &&
+	     (!pstats->hwerror) && (!pstats->crc) && (!pstats->icv));
 
 	packet_toself = packet_matchbssid &&
-	    (!compare_ether_addr(praddr, rtlefuse->dev_addr));
+	    ether_addr_equal(praddr, rtlefuse->dev_addr);
 
 	if (ieee80211_is_beacon(fc))
 		packet_beacon = true;
Signature · 1 line
1.7.8.111.gad25c.dirty

A message that is not in the archive (sent off-list or not yet received): 7c9881a67c52c2f218480b6742155b6d6928122d.1336618708.git.joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org

#3 lore raw

Re: [PATCH 1/3] drivers/net: Convert compare_ether_addr to ether_addr_equal

Quoting Joe Perches <[email protected]>:

Quoted 642 lines

Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.

Done via cocci script:

$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
(quoted diff) +1 -1
-	!compare_ether_addr(a, b)
+	ether_addr_equal(a, b)

@@
expression a,b;
@@

(quoted diff) +1 -1
-	compare_ether_addr(a, b)
+	!ether_addr_equal(a, b)

@@
expression a,b;
@@

(quoted diff) +1 -1
-	!ether_addr_equal(a, b) == 0
+	ether_addr_equal(a, b)

@@
expression a,b;
@@

(quoted diff) +1 -1
-	!ether_addr_equal(a, b) != 0
+	!ether_addr_equal(a, b)

@@
expression a,b;
@@

(quoted diff) +1 -1
-	ether_addr_equal(a, b) == 0
+	!ether_addr_equal(a, b)

@@
expression a,b;
@@

(quoted diff) +1 -1
-	ether_addr_equal(a, b) != 0
+	ether_addr_equal(a, b)

@@
expression a,b;
@@

(quoted diff) +1 -1
-	!!ether_addr_equal(a, b)
+	ether_addr_equal(a, b)
---
 drivers/net/bonding/bond_main.c                   |    2 +-
 drivers/net/ethernet/amd/depca.c                  |    3 ++-
 drivers/net/ethernet/cisco/enic/enic_main.c       |   12 ++++--------
 drivers/net/ethernet/dec/ewrk3.c                  |    3 ++-
 drivers/net/ethernet/dec/tulip/de4x5.c            |    2 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c  |    5 ++---
 drivers/net/ethernet/sfc/ethtool.c                |    2 +-
 drivers/net/ethernet/sun/sunvnet.c                |    2 +-
 drivers/net/ethernet/tile/tilepro.c               |    2 +-
 drivers/net/ethernet/toshiba/ps3_gelic_wireless.c |    8 ++++----
 drivers/net/tun.c                                 |    2 +-
 drivers/net/wireless/at76c50x-usb.c               |    2 +-
 drivers/net/wireless/ath/ath5k/base.c             |    6 +++---
 drivers/net/wireless/ath/ath9k/recv.c             |    2 +-
 drivers/net/wireless/ath/carl9170/rx.c            |    2 +-
 drivers/net/wireless/ipw2x00/libipw_rx.c          |   16 ++++++++--------
 drivers/net/wireless/iwlegacy/3945.c              |    4 ++--
 drivers/net/wireless/iwlegacy/4965-mac.c          |    2 +-
 drivers/net/wireless/iwlegacy/common.c            |   14 +++++++-------
 drivers/net/wireless/iwlwifi/iwl-agn-rx.c         |    4 ++--
 drivers/net/wireless/iwlwifi/iwl-agn-rxon.c       |    8 ++++----
 drivers/net/wireless/iwlwifi/iwl-agn-sta.c        |    6 +++---
 drivers/net/wireless/mwl8k.c                      |    2 +-
 drivers/net/wireless/p54/txrx.c                   |    2 +-
 drivers/net/wireless/rndis_wlan.c                 |   12 ++++++------
 drivers/net/wireless/rtlwifi/base.c               |    2 +-
 drivers/net/wireless/rtlwifi/ps.c                 |    2 +-
 drivers/net/wireless/rtlwifi/rtl8192ce/trx.c      |   10 +++++-----
 drivers/net/wireless/rtlwifi/rtl8192cu/mac.c      |   10 +++++-----
 drivers/net/wireless/rtlwifi/rtl8192de/trx.c      |   11 ++++++-----
 drivers/net/wireless/rtlwifi/rtl8192se/trx.c      |   11 ++++++-----
 31 files changed, 85 insertions(+), 86 deletions(-)
drivers/net/bonding/bond_main.c +1 -1
index 16dbf53..bbb0043 100644
@@ -1961,7 +1961,7 @@ int bond_release(struct net_device *bond_dev,  
 struct net_device *slave_dev)
 	write_lock_bh(&bond->lock);
 
 	if (!bond->params.fail_over_mac) {
-		if (!compare_ether_addr(bond_dev->dev_addr, slave->perm_hwaddr) &&
+		if (ether_addr_equal(bond_dev->dev_addr, slave->perm_hwaddr) &&
 		    bond->slave_cnt > 1)
 			pr_warning("%s: Warning: the permanent HWaddr of %s - %pM - is  

still in use by %s. Set the HWaddr of %s to a different address to avoid conflicts.\n",

drivers/net/bonding/bond_main.c +0 -0
 				   bond_dev->name, slave_dev->name,
drivers/net/ethernet/amd/depca.c +2 -1
index 86dd957..7f7b99a 100644
@@ -1079,7 +1079,8 @@ static int depca_rx(struct net_device *dev)
 						} else {
 							lp->pktStats.multicast++;
 						}
-					} else if (compare_ether_addr(buf, dev->dev_addr) == 0) {
+					} else if (ether_addr_equal(buf,
+								    dev->dev_addr)) {
 						lp->pktStats.unicast++;
 					}
 
drivers/net/ethernet/cisco/enic/enic_main.c +1 -2
index d7ac6c1..8132c78 100644
@@ -944,8 +944,7 @@ static void  
 enic_update_multicast_addr_list(struct enic *enic)
 
 	for (i = 0; i < enic->mc_count; i++) {
 		for (j = 0; j < mc_count; j++)
-			if (compare_ether_addr(enic->mc_addr[i],
-				mc_addr[j]) == 0)
+			if (ether_addr_equal(enic->mc_addr[i], mc_addr[j]))
 				break;
 		if (j == mc_count)
drivers/net/ethernet/cisco/enic/enic_main.c +1 -2
 			enic_dev_del_addr(enic, enic->mc_addr[i]);
@@ -953,8 +952,7 @@ static void  
 enic_update_multicast_addr_list(struct enic *enic)
 
 	for (i = 0; i < mc_count; i++) {
 		for (j = 0; j < enic->mc_count; j++)
-			if (compare_ether_addr(mc_addr[i],
-				enic->mc_addr[j]) == 0)
+			if (ether_addr_equal(mc_addr[i], enic->mc_addr[j]))
 				break;
 		if (j == enic->mc_count)
drivers/net/ethernet/cisco/enic/enic_main.c +1 -2
 			enic_dev_add_addr(enic, mc_addr[i]);
@@ -999,8 +997,7 @@ static void enic_update_unicast_addr_list(struct  
 enic *enic)
 
 	for (i = 0; i < enic->uc_count; i++) {
 		for (j = 0; j < uc_count; j++)
-			if (compare_ether_addr(enic->uc_addr[i],
-				uc_addr[j]) == 0)
+			if (ether_addr_equal(enic->uc_addr[i], uc_addr[j]))
 				break;
 		if (j == uc_count)
drivers/net/ethernet/cisco/enic/enic_main.c +1 -2
 			enic_dev_del_addr(enic, enic->uc_addr[i]);
@@ -1008,8 +1005,7 @@ static void  
 enic_update_unicast_addr_list(struct enic *enic)
 
 	for (i = 0; i < uc_count; i++) {
 		for (j = 0; j < enic->uc_count; j++)
-			if (compare_ether_addr(uc_addr[i],
-				enic->uc_addr[j]) == 0)
+			if (ether_addr_equal(uc_addr[i], enic->uc_addr[j]))
 				break;
 		if (j == enic->uc_count)
drivers/net/ethernet/cisco/enic/enic_main.c +0 -0
 			enic_dev_add_addr(enic, uc_addr[i]);
drivers/net/ethernet/dec/ewrk3.c +2 -1
index 1879f84..17ae8c6 100644
@@ -1016,7 +1016,8 @@ static int ewrk3_rx(struct net_device *dev)
 							} else {
 								lp->pktStats.multicast++;
 							}
-						} else if (compare_ether_addr(p, dev->dev_addr) == 0) {
+						} else if (ether_addr_equal(p,
+									    dev->dev_addr)) {
 							lp->pktStats.unicast++;
 						}
 						lp->pktStats.bins[0]++;		/* Duplicates stats.rx_packets */
drivers/net/ethernet/dec/tulip/de4x5.c +1 -1
index 18b106c..d3cd489 100644
@@ -1874,7 +1874,7 @@ de4x5_local_stats(struct net_device *dev, char  
 *buf, int pkt_len)
 	} else {
 	    lp->pktStats.multicast++;
 	}
-    } else if (compare_ether_addr(buf, dev->dev_addr) == 0) {
+    } else if (ether_addr_equal(buf, dev->dev_addr)) {
         lp->pktStats.unicast++;
     }
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +2 -3
index 5c47135..46e77a2 100644
@@ -1965,7 +1965,7 @@ qlcnic_send_filter(struct qlcnic_adapter *adapter,
 	__le16 vlan_id = 0;
 	u8 hindex;
 
-	if (!compare_ether_addr(phdr->h_source, adapter->mac_addr))
+	if (ether_addr_equal(phdr->h_source, adapter->mac_addr))
 		return;
 
 	if (adapter->fhash.fnum >= adapter->fhash.fmax)
@@ -2235,8 +2235,7 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct  
 net_device *netdev)
 
 	if (adapter->flags & QLCNIC_MACSPOOF) {
 		phdr = (struct ethhdr *)skb->data;
-		if (compare_ether_addr(phdr->h_source,
-					adapter->mac_addr))
+		if (!ether_addr_equal(phdr->h_source, adapter->mac_addr))
 			goto drop_packet;
 	}
drivers/net/ethernet/sfc/ethtool.c +1 -1
index f22f45f..62d4b81 100644
@@ -1023,7 +1023,7 @@ static int efx_ethtool_set_class_rule(struct  
 efx_nic *efx,
 			return -EINVAL;
 
 		/* Is it a default UC or MC filter? */
-		if (!compare_ether_addr(mac_mask->h_dest, mac_addr_mc_mask) &&
+		if (ether_addr_equal(mac_mask->h_dest, mac_addr_mc_mask) &&
 		    vlan_tag_mask == 0) {
 			if (is_multicast_ether_addr(mac_entry->h_dest))
drivers/net/ethernet/sfc/ethtool.c +0 -0
 				rc = efx_filter_set_mc_def(&spec);
drivers/net/ethernet/sun/sunvnet.c +1 -1
index 38e3ae9..a108db3 100644
@@ -618,7 +618,7 @@ struct vnet_port *__tx_port_find(struct vnet  
 *vp, struct sk_buff *skb)
 	struct vnet_port *port;
 
 	hlist_for_each_entry(port, n, hp, hash) {
-		if (!compare_ether_addr(port->raddr, skb->data))
+		if (ether_addr_equal(port->raddr, skb->data))
 			return port;
 	}
drivers/net/ethernet/sun/sunvnet.c +0 -0
 	port = NULL;
drivers/net/ethernet/tile/tilepro.c +1 -1
index 3d501ec..96070e9 100644
@@ -843,7 +843,7 @@ static bool tile_net_poll_aux(struct  
 tile_net_cpu *info, int index)
 		if (!is_multicast_ether_addr(buf)) {
 			/* Filter packets not for our address. */
 			const u8 *mine = dev->dev_addr;
-			filter = compare_ether_addr(mine, buf);
+			filter = !ether_addr_equal(mine, buf);
 		}
 	}
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +2 -2
index 5c14f82..961c832 100644
@@ -1590,8 +1590,8 @@ static void  
 gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
 		found = 0;
 		oldest = NULL;
 		list_for_each_entry(target, &wl->network_list, list) {
-			if (!compare_ether_addr(&target->hwinfo->bssid[2],
-						&scan_info->bssid[2])) {
+			if (ether_addr_equal(&target->hwinfo->bssid[2],
+					     &scan_info->bssid[2])) {
 				found = 1;
 				pr_debug("%s: same BBS found scanned list\n",
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +2 -2
 					 __func__);
@@ -1691,8 +1691,8 @@ struct gelic_wl_scan_info  
 *gelic_wl_find_best_bss(struct gelic_wl_info *wl)
 
 		/* If bss specified, check it only */
 		if (test_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat)) {
-			if (!compare_ether_addr(&scan_info->hwinfo->bssid[2],
-						wl->bssid)) {
+			if (ether_addr_equal(&scan_info->hwinfo->bssid[2],
+					     wl->bssid)) {
 				best_bss = scan_info;
 				pr_debug("%s: bssid matched\n", __func__);
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +0 -0
 				break;
drivers/net/tun.c +1 -1
index bb8c72c..987aeef 100644
@@ -313,7 +313,7 @@ static int run_filter(struct tap_filter *filter,  
 const struct sk_buff *skb)
 
 	/* Exact match */
 	for (i = 0; i < filter->count; i++)
-		if (!compare_ether_addr(eh->h_dest, filter->addr[i]))
+		if (ether_addr_equal(eh->h_dest, filter->addr[i]))
 			return 1;
 
drivers/net/tun.c +0 -0
 	/* Inexact match (multicast only) */
drivers/net/wireless/at76c50x-usb.c +1 -1
index faa8bcb..5ad74c8 100644
@@ -1751,7 +1751,7 @@ static void at76_mac80211_tx(struct  
 ieee80211_hw *hw, struct sk_buff *skb)
 	 * following workaround is necessary. If the TX frame is an
 	 * authentication frame extract the bssid and send the CMD_JOIN. */
 	if (mgmt->frame_control & cpu_to_le16(IEEE80211_STYPE_AUTH)) {
-		if (compare_ether_addr(priv->bssid, mgmt->bssid)) {
+		if (!ether_addr_equal(priv->bssid, mgmt->bssid)) {
 			memcpy(priv->bssid, mgmt->bssid, ETH_ALEN);
 			ieee80211_queue_work(hw, &priv->work_join_bssid);
drivers/net/wireless/at76c50x-usb.c +0 -0
 			dev_kfree_skb_any(skb);
drivers/net/wireless/ath/ath5k/base.c +1 -1
index 49e3b19..0ba81a6 100644
@@ -462,7 +462,7 @@ void ath5k_vif_iter(void *data, u8 *mac, struct  
 ieee80211_vif *vif)
 	}
 
 	if (iter_data->need_set_hw_addr && iter_data->hw_macaddr)
-		if (compare_ether_addr(iter_data->hw_macaddr, mac) == 0)
+		if (ether_addr_equal(iter_data->hw_macaddr, mac))
 			iter_data->need_set_hw_addr = false;
 
drivers/net/wireless/ath/ath5k/base.c +1 -1
 	if (!iter_data->any_assoc) {
@@ -1170,7 +1170,7 @@ ath5k_check_ibss_tsf(struct ath5k_hw *ah,  
 struct sk_buff *skb,
 
 	if (ieee80211_is_beacon(mgmt->frame_control) &&
 	    le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS &&
-	    compare_ether_addr(mgmt->bssid, common->curbssid) == 0) {
+	    ether_addr_equal(mgmt->bssid, common->curbssid)) {
 		/*
 		 * Received an IBSS beacon with the same BSSID. Hardware *must*
drivers/net/wireless/ath/ath5k/base.c +1 -1
 		 * have updated the local TSF. We have to work around various
@@ -1234,7 +1234,7 @@ ath5k_update_beacon_rssi(struct ath5k_hw *ah,  
 struct sk_buff *skb, int rssi)
 
 	/* only beacons from our BSSID */
 	if (!ieee80211_is_beacon(mgmt->frame_control) ||
-	    compare_ether_addr(mgmt->bssid, common->curbssid) != 0)
+	    !ether_addr_equal(mgmt->bssid, common->curbssid))
 		return;
 
drivers/net/wireless/ath/ath5k/base.c +0 -0
 	ewma_add(&ah->ah_beacon_rssi_avg, rssi);
drivers/net/wireless/ath/ath9k/recv.c +1 -1
index 544e549..e1fcc68 100644
@@ -1833,7 +1833,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int  
 flush, bool hp)
 		if (ieee80211_is_beacon(hdr->frame_control)) {
 			RX_STAT_INC(rx_beacons);
 			if (!is_zero_ether_addr(common->curbssid) &&
-			    !compare_ether_addr(hdr->addr3, common->curbssid))
+			    ether_addr_equal(hdr->addr3, common->curbssid))
 				rs.is_mybeacon = true;
 			else
drivers/net/wireless/ath/ath9k/recv.c +0 -0
 				rs.is_mybeacon = false;
drivers/net/wireless/ath/carl9170/rx.c +1 -1
index dc99030..84b22ee 100644
@@ -538,7 +538,7 @@ static void carl9170_ps_beacon(struct ar9170  
 *ar, void *data, unsigned int len)
 		return;
 
 	/* and only beacons from the associated BSSID, please */
-	if (compare_ether_addr(hdr->addr3, ar->common.curbssid) ||
+	if (!ether_addr_equal(hdr->addr3, ar->common.curbssid) ||
 	    !ar->common.curaid)
 		return;
drivers/net/wireless/ipw2x00/libipw_rx.c +5 -5
index c4955d2..02e0579 100644
@@ -77,8 +77,8 @@ static struct libipw_frag_entry  
 *libipw_frag_cache_find(struct
 
 		if (entry->skb != NULL && entry->seq == seq &&
 		    (entry->last_frag + 1 == frag || frag == -1) &&
-		    !compare_ether_addr(entry->src_addr, src) &&
-		    !compare_ether_addr(entry->dst_addr, dst))
+		    ether_addr_equal(entry->src_addr, src) &&
+		    ether_addr_equal(entry->dst_addr, dst))
 			return entry;
 	}
@@ -245,12 +245,12 @@ static int libipw_is_eapol_frame(struct  
 libipw_device *ieee,
 	/* check that the frame is unicast frame to us */
 	if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
 	    IEEE80211_FCTL_TODS &&
-	    !compare_ether_addr(hdr->addr1, dev->dev_addr) &&
-	    !compare_ether_addr(hdr->addr3, dev->dev_addr)) {
+	    ether_addr_equal(hdr->addr1, dev->dev_addr) &&
+	    ether_addr_equal(hdr->addr3, dev->dev_addr)) {
 		/* ToDS frame with own addr BSSID and DA */
 	} else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
 		   IEEE80211_FCTL_FROMDS &&
-		   !compare_ether_addr(hdr->addr1, dev->dev_addr)) {
+		   ether_addr_equal(hdr->addr1, dev->dev_addr)) {
 		/* FromDS frame with own addr as DA */
 	} else
drivers/net/wireless/ipw2x00/libipw_rx.c +2 -2
 		return 0;
@@ -523,8 +523,8 @@ int libipw_rx(struct libipw_device *ieee, struct  
 sk_buff *skb,
 
 	if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
 	    (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
-	    IEEE80211_FCTL_FROMDS && ieee->stadev
-	    && !compare_ether_addr(hdr->addr2, ieee->assoc_ap_addr)) {
+	    IEEE80211_FCTL_FROMDS && ieee->stadev &&
+	    ether_addr_equal(hdr->addr2, ieee->assoc_ap_addr)) {
 		/* Frame from BSSID of the AP for which we are a client */
 		skb->dev = dev = ieee->stadev;
drivers/net/wireless/ipw2x00/libipw_rx.c +1 -1
 		stats = hostap_get_stats(dev);
@@ -1468,7 +1468,7 @@ static inline int is_same_network(struct  
 libipw_network *src,
 	 * as one network */
 	return ((src->ssid_len == dst->ssid_len) &&
 		(src->channel == dst->channel) &&
-		!compare_ether_addr(src->bssid, dst->bssid) &&
+		ether_addr_equal(src->bssid, dst->bssid) &&
 		!memcmp(src->ssid, dst->ssid, src->ssid_len));
 }
drivers/net/wireless/iwlegacy/3945.c +2 -2
index b25c01b..87e5398 100644
@@ -453,10 +453,10 @@ il3945_is_network_packet(struct il_priv *il,  
 struct ieee80211_hdr *header)
 	switch (il->iw_mode) {
 	case NL80211_IFTYPE_ADHOC:	/* Header: Dest. | Source    | BSSID */
 		/* packets to our IBSS update information */
-		return !compare_ether_addr(header->addr3, il->bssid);
+		return ether_addr_equal(header->addr3, il->bssid);
 	case NL80211_IFTYPE_STATION:	/* Header: Dest. | AP{BSSID} | Source */
 		/* packets to our IBSS update information */
-		return !compare_ether_addr(header->addr2, il->bssid);
+		return ether_addr_equal(header->addr2, il->bssid);
 	default:
 		return 1;
drivers/net/wireless/iwlegacy/3945.c +0 -0
 	}
drivers/net/wireless/iwlegacy/4965-mac.c +1 -1
index f2baf94..509301a 100644
@@ -2565,7 +2565,7 @@ il4965_find_station(struct il_priv *il, const u8 *addr)
 	spin_lock_irqsave(&il->sta_lock, flags);
 	for (i = start; i < il->hw_params.max_stations; i++)
 		if (il->stations[i].used &&
-		    (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) {
+		    ether_addr_equal(il->stations[i].sta.sta.addr, addr)) {
 			ret = i;
 			goto out;
 		}
drivers/net/wireless/iwlegacy/common.c +2 -2
index eaf24945..cbf2dc1 100644
@@ -1896,8 +1896,8 @@ il_prep_station(struct il_priv *il, const u8  
 *addr, bool is_ap,
 		sta_id = il->hw_params.bcast_id;
 	else
 		for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) {
-			if (!compare_ether_addr
-			    (il->stations[i].sta.sta.addr, addr)) {
+			if (ether_addr_equal(il->stations[i].sta.sta.addr,
+					     addr)) {
 				sta_id = i;
 				break;
drivers/net/wireless/iwlegacy/common.c +1 -1
 			}
@@ -1926,7 +1926,7 @@ il_prep_station(struct il_priv *il, const u8  
 *addr, bool is_ap,
 
 	if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) &&
 	    (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) &&
-	    !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) {
+	    ether_addr_equal(il->stations[sta_id].sta.sta.addr, addr)) {
 		D_ASSOC("STA %d (%pM) already added, not adding again.\n",
 			sta_id, addr);
drivers/net/wireless/iwlegacy/common.c +4 -4
 		return sta_id;
@@ -3744,10 +3744,10 @@ il_full_rxon_required(struct il_priv *il)
 
 	/* These items are only settable from the full RXON command */
 	CHK(!il_is_associated(il));
-	CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr));
-	CHK(compare_ether_addr(staging->node_addr, active->node_addr));
-	CHK(compare_ether_addr
-	    (staging->wlap_bssid_addr, active->wlap_bssid_addr));
+	CHK(!ether_addr_equal(staging->bssid_addr, active->bssid_addr));
+	CHK(!ether_addr_equal(staging->node_addr, active->node_addr));
+	CHK(!ether_addr_equal(staging->wlap_bssid_addr,
+			      active->wlap_bssid_addr));
 	CHK_NEQ(staging->dev_type, active->dev_type);
 	CHK_NEQ(staging->channel, active->channel);
 	CHK_NEQ(staging->air_propagation, active->air_propagation);
drivers/net/wireless/iwlwifi/iwl-agn-rx.c +2 -2
index 0c252c5..779f819 100644
@@ -779,8 +779,8 @@ static void  
 iwlagn_pass_packet_to_mac80211(struct iwl_priv *priv,
 	*/
 	if (unlikely(ieee80211_is_beacon(fc) && priv->passive_no_rx)) {
 		for_each_context(priv, ctx) {
-			if (compare_ether_addr(hdr->addr3,
-					       ctx->active.bssid_addr))
+			if (!ether_addr_equal(hdr->addr3,
+					      ctx->active.bssid_addr))
 				continue;
 			iwlagn_lift_passive_no_rx(priv);
drivers/net/wireless/iwlwifi/iwl-agn-rx.c +0 -0
 		}
drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +4 -4
index 0f7c444..74fbee6 100644
@@ -881,10 +881,10 @@ int iwl_full_rxon_required(struct iwl_priv *priv,
 
 	/* These items are only settable from the full RXON command */
 	CHK(!iwl_is_associated_ctx(ctx));
-	CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr));
-	CHK(compare_ether_addr(staging->node_addr, active->node_addr));
-	CHK(compare_ether_addr(staging->wlap_bssid_addr,
-				active->wlap_bssid_addr));
+	CHK(!ether_addr_equal(staging->bssid_addr, active->bssid_addr));
+	CHK(!ether_addr_equal(staging->node_addr, active->node_addr));
+	CHK(!ether_addr_equal(staging->wlap_bssid_addr,
+			      active->wlap_bssid_addr));
 	CHK_NEQ(staging->dev_type, active->dev_type);
 	CHK_NEQ(staging->channel, active->channel);
 	CHK_NEQ(staging->air_propagation, active->air_propagation);
drivers/net/wireless/iwlwifi/iwl-agn-sta.c +2 -2
index 67e6f1d..b31584e 100644
@@ -322,8 +322,8 @@ u8 iwl_prep_station(struct iwl_priv *priv,  
 struct iwl_rxon_context *ctx,
 		sta_id = ctx->bcast_sta_id;
 	else
 		for (i = IWL_STA_ID; i < IWLAGN_STATION_COUNT; i++) {
-			if (!compare_ether_addr(priv->stations[i].sta.sta.addr,
-						addr)) {
+			if (ether_addr_equal(priv->stations[i].sta.sta.addr,
+					     addr)) {
 				sta_id = i;
 				break;
drivers/net/wireless/iwlwifi/iwl-agn-sta.c +1 -1
 			}
@@ -353,7 +353,7 @@ u8 iwl_prep_station(struct iwl_priv *priv,  
 struct iwl_rxon_context *ctx,
 
 	if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
 	    (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) &&
-	    !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) {
+	    ether_addr_equal(priv->stations[sta_id].sta.sta.addr, addr)) {
 		IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not "
 				"adding again.\n", sta_id, addr);
drivers/net/wireless/iwlwifi/iwl-agn-sta.c +0 -0
 		return sta_id;
drivers/net/wireless/mwl8k.c +1 -1
index e30cc32..cf7bdc6 100644
@@ -1235,7 +1235,7 @@ mwl8k_capture_bssid(struct mwl8k_priv *priv,  
 struct ieee80211_hdr *wh)
 {
 	return priv->capture_beacon &&
 		ieee80211_is_beacon(wh->frame_control) &&
-		!compare_ether_addr(wh->addr3, priv->capture_bssid);
+		ether_addr_equal(wh->addr3, priv->capture_bssid);
 }
 

static inline void mwl8k_save_beacon(struct ieee80211_hw *hw,

drivers/net/wireless/p54/txrx.c +1 -1
index 7c8f118..82a1cac 100644
@@ -308,7 +308,7 @@ static void p54_pspoll_workaround(struct  
 p54_common *priv, struct sk_buff *skb)
 		return;
 
 	/* only consider beacons from the associated BSSID */
-	if (compare_ether_addr(hdr->addr3, priv->bssid))
+	if (!ether_addr_equal(hdr->addr3, priv->bssid))
 		return;
 
drivers/net/wireless/p54/txrx.c +0 -0
 	tim = p54_find_ie(skb, WLAN_EID_TIM);
drivers/net/wireless/rndis_wlan.c +2 -2
index d66e298..dcf0e7e 100644
@@ -1801,8 +1801,8 @@ static struct ndis_80211_pmkid  
 *remove_pmkid(struct usbnet *usbdev,
 		count = max_pmkids;
 
 	for (i = 0; i < count; i++)
-		if (!compare_ether_addr(pmkids->bssid_info[i].bssid,
-							pmksa->bssid))
+		if (ether_addr_equal(pmkids->bssid_info[i].bssid,
+				     pmksa->bssid))
 			break;
 
drivers/net/wireless/rndis_wlan.c +2 -2
 	/* pmkid not found */
@@ -1843,8 +1843,8 @@ static struct ndis_80211_pmkid  
 *update_pmkid(struct usbnet *usbdev,
 
 	/* update with new pmkid */
 	for (i = 0; i < count; i++) {
-		if (compare_ether_addr(pmkids->bssid_info[i].bssid,
-							pmksa->bssid))
+		if (!ether_addr_equal(pmkids->bssid_info[i].bssid,
+				      pmksa->bssid))
 			continue;
 
drivers/net/wireless/rndis_wlan.c +0 -0
 		memcpy(pmkids->bssid_info[i].pmkid, pmksa->pmkid,

drivers/net/wireless/rndis_wlan.c resize_buf: · line 2142

Quoted 5 lines
drivers/net/wireless/rndis_wlan.c +1 -1
@@ -2139,7 +2139,7 @@ resize_buf:
 	while (check_bssid_list_item(bssid, bssid_len, buf, len)) {
 		if (rndis_bss_info_update(usbdev, bssid) && match_bssid &&
 		    matched) {
-			if (compare_ether_addr(bssid->mac, match_bssid))
+			if (!ether_addr_equal(bssid->mac, match_bssid))

While reviewing this, noticed that above original code is wrong. It should be !compare_ether_addr. So do I push patch fixing this through wireless-testing althought it will later cause conflict with this patch?

-Jussi

Quoted 151 lines
drivers/net/wireless/rndis_wlan.c +1 -1
 				*matched = true;
 		}
 
@@ -2531,7 +2531,7 @@ static int rndis_get_station(struct wiphy  
 *wiphy, struct net_device *dev,
 	struct rndis_wlan_private *priv = wiphy_priv(wiphy);
 	struct usbnet *usbdev = priv->usbdev;
 
-	if (compare_ether_addr(priv->bssid, mac))
+	if (!ether_addr_equal(priv->bssid, mac))
 		return -ENOENT;
 
drivers/net/wireless/rndis_wlan.c +0 -0
 	rndis_fill_station_info(usbdev, sinfo);
drivers/net/wireless/rtlwifi/base.c +1 -1
index e54488d..f4c852c 100644
@@ -1460,7 +1460,7 @@ void rtl_recognize_peer(struct ieee80211_hw  
 *hw, u8 *data, unsigned int len)
 		return;
 
 	/* and only beacons from the associated BSSID, please */
-	if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
+	if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
 		return;
 
drivers/net/wireless/rtlwifi/base.c +0 -0
 	if (rtl_find_221_ie(hw, data, len))
drivers/net/wireless/rtlwifi/ps.c +1 -1
index 5b9c3b5..5ae2664 100644
@@ -480,7 +480,7 @@ void rtl_swlps_beacon(struct ieee80211_hw *hw,  
 void *data, unsigned int len)
 		return;
 
 	/* and only beacons from the associated BSSID, please */
-	if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
+	if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
 		return;
 
drivers/net/wireless/rtlwifi/ps.c +0 -0
 	rtlpriv->psc.last_beacon = jiffies;
drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +5 -5
index 37b1363..3af874e 100644
@@ -508,14 +508,14 @@ static void  
 _rtl92ce_translate_rx_signal_stuff(struct ieee80211_hw *hw,
 
 	packet_matchbssid =
 	    ((IEEE80211_FTYPE_CTL != type) &&
-	     (!compare_ether_addr(mac->bssid,
-				  (c_fc & IEEE80211_FCTL_TODS) ?
-				  hdr->addr1 : (c_fc & IEEE80211_FCTL_FROMDS) ?
-				  hdr->addr2 : hdr->addr3)) &&
+	     ether_addr_equal(mac->bssid,
+			      (c_fc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+			      (c_fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+			      hdr->addr3) &&
 	     (!pstats->hwerror) && (!pstats->crc) && (!pstats->icv));
 
 	packet_toself = packet_matchbssid &&
-	    (!compare_ether_addr(praddr, rtlefuse->dev_addr));
+	     ether_addr_equal(praddr, rtlefuse->dev_addr);
 
 	if (ieee80211_is_beacon(fc))
drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +0 -0
 		packet_beacon = true;
drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +5 -5
index 025bdc2..7e91c76 100644
@@ -1099,14 +1099,14 @@ void rtl92c_translate_rx_signal_stuff(struct  
 ieee80211_hw *hw,
 	praddr = hdr->addr1;
 	packet_matchbssid =
 	    ((IEEE80211_FTYPE_CTL != type) &&
-	     (!compare_ether_addr(mac->bssid,
-			  (cpu_fc & IEEE80211_FCTL_TODS) ?
-			  hdr->addr1 : (cpu_fc & IEEE80211_FCTL_FROMDS) ?
-			  hdr->addr2 : hdr->addr3)) &&
+	     ether_addr_equal(mac->bssid,
+			      (cpu_fc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+			      (cpu_fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+			      hdr->addr3) &&
 	     (!pstats->hwerror) && (!pstats->crc) && (!pstats->icv));
 
 	packet_toself = packet_matchbssid &&
-	    (!compare_ether_addr(praddr, rtlefuse->dev_addr));
+	    ether_addr_equal(praddr, rtlefuse->dev_addr);
 	if (ieee80211_is_beacon(fc))
 		packet_beacon = true;
drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +0 -0
 	_rtl92c_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
drivers/net/wireless/rtlwifi/rtl8192de/trx.c +6 -5
index a7f6126..1666ef7 100644
@@ -466,12 +466,13 @@ static void  
 _rtl92de_translate_rx_signal_stuff(struct ieee80211_hw *hw,
 	type = WLAN_FC_GET_TYPE(fc);
 	praddr = hdr->addr1;
 	packet_matchbssid = ((IEEE80211_FTYPE_CTL != type) &&
-	     (!compare_ether_addr(mac->bssid, (cfc & IEEE80211_FCTL_TODS) ?
-		  hdr->addr1 : (cfc & IEEE80211_FCTL_FROMDS) ?
-		  hdr->addr2 : hdr->addr3)) && (!pstats->hwerror) &&
-		  (!pstats->crc) && (!pstats->icv));
+	     ether_addr_equal(mac->bssid,
+			      (cfc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+			      (cfc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+			      hdr->addr3) &&
+	     (!pstats->hwerror) && (!pstats->crc) && (!pstats->icv));
 	packet_toself = packet_matchbssid &&
-			(!compare_ether_addr(praddr, rtlefuse->dev_addr));
+			ether_addr_equal(praddr, rtlefuse->dev_addr);
 	if (ieee80211_is_beacon(fc))
 		packet_beacon = true;
drivers/net/wireless/rtlwifi/rtl8192de/trx.c +0 -0
 	_rtl92de_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
drivers/net/wireless/rtlwifi/rtl8192se/trx.c +6 -5
index 2fd3d13..812b585 100644
@@ -492,13 +492,14 @@ static void  
 _rtl92se_translate_rx_signal_stuff(struct ieee80211_hw *hw,
 	praddr = hdr->addr1;
 
 	packet_matchbssid = ((IEEE80211_FTYPE_CTL != type) &&
-	     (!compare_ether_addr(mac->bssid, (cfc & IEEE80211_FCTL_TODS) ?
-			hdr->addr1 : (cfc & IEEE80211_FCTL_FROMDS) ?
-			hdr->addr2 : hdr->addr3)) && (!pstats->hwerror) &&
-			(!pstats->crc) && (!pstats->icv));
+	     ether_addr_equal(mac->bssid,
+			      (cfc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
+			      (cfc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
+			      hdr->addr3) &&
+	     (!pstats->hwerror) && (!pstats->crc) && (!pstats->icv));
 
 	packet_toself = packet_matchbssid &&
-	    (!compare_ether_addr(praddr, rtlefuse->dev_addr));
+	    ether_addr_equal(praddr, rtlefuse->dev_addr);
 
 	if (ieee80211_is_beacon(fc))

packet_beacon = true;
--
1.7.8.111.gad25c.dirty

#4 lore raw

Re: [PATCH 1/3] drivers/net: Convert compare_ether_addr to ether_addr_equal

(cc's trimmed)

Quoted 4 lines · Jussi Kivilinna

Quoting Joe Perches <[email protected]>:

Quoted 3 lines

Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.

[]

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

[]

Quoted 11 lines

Review resize_buf: · line 2142

Quoted 6 lines
(quoted diff) +1 -1
@@ -2139,7 +2139,7 @@ resize_buf:
 	while (check_bssid_list_item(bssid, bssid_len, buf, len)) {
 		if (rndis_bss_info_update(usbdev, bssid) && match_bssid &&
 		    matched) {
-			if (compare_ether_addr(bssid->mac, match_bssid))
+			if (!ether_addr_equal(bssid->mac, match_bssid))

While reviewing this, noticed that above original code is wrong. It should be !compare_ether_addr. So do I push patch fixing this through wireless-testing althought it will later cause conflict with this patch?

Quoted 5 lines

-Jussi

Quoted 3 lines
(quoted diff) +0 -0
 				*matched = true;
 		}
 

Up to John.

Here's the patch I would send against net-next
updating the test and the style a little.

drivers/net/wireless/rndis_wlan.c +4 -5
index dcf0e7e..29cccc5 100644
@@ -2137,11 +2137,10 @@ resize_buf:
 	 * received 'num_items' and walking through full bssid buffer instead.
 	 */
 	while (check_bssid_list_item(bssid, bssid_len, buf, len)) {
-		if (rndis_bss_info_update(usbdev, bssid) && match_bssid &&
-		    matched) {
-			if (!ether_addr_equal(bssid->mac, match_bssid))
-				*matched = true;
-		}
+		if (rndis_bss_info_update(usbdev, bssid) &&
+		    match_bssid && matched &&
+		    ether_addr_equal(bssid->mac, match_bssid))
+			*matched = true;
 
 		real_count++;
 		bssid = next_bssid_list_item(bssid, &bssid_len, buf, len);
maintainer
#5 lore raw

Re: [PATCH 1/3] drivers/net: Convert compare_ether_addr to ether_addr_equal

From: Joe Perches <[email protected]>
Date: Thu, 10 May 2012 09:11:28 -0700

Quoted 23 lines

(cc's trimmed)

Quoted 4 lines · Jussi Kivilinna

Quoting Joe Perches <[email protected]>:

Quoted 3 lines

Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.

[]

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

[]

Quoted 13 lines

Review resize_buf: · line 2142

Quoted 6 lines
(quoted diff) +1 -1
@@ -2139,7 +2139,7 @@ resize_buf:
 	while (check_bssid_list_item(bssid, bssid_len, buf, len)) {
 		if (rndis_bss_info_update(usbdev, bssid) && match_bssid &&
 		    matched) {
-			if (compare_ether_addr(bssid->mac, match_bssid))
+			if (!ether_addr_equal(bssid->mac, match_bssid))

While reviewing this, noticed that above original code is wrong. It should be !compare_ether_addr. So do I push patch fixing this through wireless-testing althought it will later cause conflict with this patch?

-Jussi

Quoted 8 lines
Quoted 3 lines

Review resize_buf: · line 2145

Quoted 3 lines
(quoted diff) +0 -0
 				*matched = true;
 		}
 

Up to John.

Here's the patch I would send against net-next
updating the test and the style a little.

I think in this specific case it's better to push this one directly through net-next. But yes, it's up to John.

#6 lore raw

Re: [PATCH 1/3] drivers/net: Convert compare_ether_addr to ether_addr_equal

Quoting David Miller <[email protected]>:

Quoted 30 lines

From: Joe Perches <[email protected]>
Date: Thu, 10 May 2012 09:11:28 -0700

Quoted 27 lines

(cc's trimmed)

Quoted 4 lines · Jussi Kivilinna

Quoting Joe Perches <[email protected]>:

Quoted 3 lines

Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.

[]

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

[]

Quoted 16 lines

Review resize_buf: · line 2142

Quoted 6 lines
(quoted diff) +1 -1
@@ -2139,7 +2139,7 @@ resize_buf:
 	while (check_bssid_list_item(bssid, bssid_len, buf, len)) {
 		if (rndis_bss_info_update(usbdev, bssid) && match_bssid &&
 		    matched) {
-			if (compare_ether_addr(bssid->mac, match_bssid))
+			if (!ether_addr_equal(bssid->mac, match_bssid))

While reviewing this, noticed that above original code is wrong. It should be !compare_ether_addr. So do I push patch fixing this through wireless-testing althought it will later cause conflict with this patch?

-Jussi

Quoted 3 lines
(quoted diff) +0 -0
 				*matched = true;
 		}
 
Quoted 8 lines
Quoted 4 lines

Up to John.

Here's the patch I would send against net-next
updating the test and the style a little.

I think in this specific case it's better to push this one directly through net-next. But yes, it's up to John.

It's been some time now, and I think it's ok to wait until wireless-testing has this patch merged and then fix it there.

That line/compare was added as response to hardware bug, where bssid-list does not contain BSSID and other information of currently connected AP (spec insists that device must provide this information in the list when connected). Lack bssid-data on current connection then causes WARN_ON somewhere in cfg80211. Workaround was to check if bssid-list returns current bssid and if it does not, manually construct bssid information in other ways. And this workaround worked, with inverse check. Which must mean that when hardware is experiencing the problem, it's actually returning empty bssid-list.

Inverse check causes workaround be activated when bssid-list returns only entry, currently connected BSSID. That does not cause problems in itself, just slightly more inaccurate information in scan-list.

-Jussi

#7 lore raw

Re: [PATCH 1/3] drivers/net: Convert compare_ether_addr to ether_addr_equal

Quoted 21 lines · Jussi Kivilinna

Quoting David Miller <davem-fT/PcQaiUtIeIZ0/[email protected]>:

Quoted 20 lines

From: Joe Perches <[email protected]>
Date: Thu, 10 May 2012 09:11:28 -0700

Quoted 18 lines · Jussi Kivilinna
Quoted 4 lines

Quoting Joe Perches <[email protected]>:

Quoted 3 lines

Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.

[]

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

[]

Quoted 10 lines

Review resize_buf: · line 2142

Quoted 6 lines
(quoted diff) +1 -1
@@ -2139,7 +2139,7 @@ resize_buf:
 	while (check_bssid_list_item(bssid, bssid_len, buf, len)) {
 		if (rndis_bss_info_update(usbdev, bssid) && match_bssid &&
 		    matched) {
-			if (compare_ether_addr(bssid->mac, match_bssid))
+			if (!ether_addr_equal(bssid->mac, match_bssid))

While reviewing this, noticed that above original code is wrong. It should be !compare_ether_addr. So do I push patch fixing this through wireless-testing althought it will later cause conflict with this patch?

[]

Quoted 12 lines

That line/compare was added as response to hardware bug, where bssid-list does not contain BSSID and other information of currently connected AP (spec insists
that device must provide this information in the list when connected). Lack bssid-data on current connection then causes WARN_ON somewhere in cfg80211. Workaround was to check if bssid-list returns current bssid and if it does not,
manually construct bssid information in other ways. And this workaround worked,
with inverse check. Which must mean that when hardware is experiencing the problem, it's actually returning empty bssid-list.

Quoted 3 lines

Inverse check causes workaround be activated when bssid-list returns only entry, currently connected BSSID. That does not cause problems in itself, just slightly more inaccurate information in scan-list.

Thanks.

That information would be useful in the
eventual commit message.

cheers, Joe

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#8 lore raw

Re: [PATCH 1/3] drivers/net: Convert compare_ether_addr to ether_addr_equal

In reply to Jussi Kivilinna

Never, EVER, quote an entire large patch just to make a comment on one small hunk.

I very nearly missed what you had to say because when scrolling through it it appeared as if you made no comments at all.

Again, NEVER, EVER, do this. It's extremely anti-social. Edit out the irrelevant quoted content when replying to people, always.

#9 lore raw

Re: [PATCH 1/3] drivers/net: Convert compare_ether_addr to ether_addr_equal

Quoting David Miller <[email protected]>:

Quoted 10 lines

Never, EVER, quote an entire large patch just to make a comment on one small hunk.

I very nearly missed what you had to say because when scrolling through it it appeared as if you made no comments at all.

Again, NEVER, EVER, do this. It's extremely anti-social. Edit out the irrelevant quoted content when replying to people, always.

I'm sorry. I will not do this again.

-Jussi

maintainer Applied
#10 lore raw

Re: [PATCH 1/3] drivers/net: Convert compare_ether_addr to ether_addr_equal

In reply to Joe Perches

From: Joe Perches <[email protected]>
Date: Wed, 9 May 2012 20:17:46 -0700

Quoted 5 lines

Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.

Done via cocci script:

...

Quoted 1 line

Applied.

#11 lore raw

PATCH 2/3 etherdevice.h: Add ether_addr_equal_64bits

In reply to Joe Perches

Add an optimized boolean function to check if
2 ethernet addresses are the same.

This is to avoid any confusion about compare_ether_addr_64bits returning an unsigned, and not being able to use the compare_ether_addr_64bits function for sorting ala memcmp.

---
 include/linux/etherdevice.h |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
include/linux/etherdevice.h +20 -0
index f330114..afacf85 100644
@@ -225,6 +225,26 @@ static inline unsigned compare_ether_addr_64bits(const u8 addr1[6+2],
 }
 
 /**
+ * ether_addr_equal_64bits - Compare two Ethernet addresses
+ * @addr1: Pointer to an array of 8 bytes
+ * @addr2: Pointer to an other array of 8 bytes
+ *
+ * Compare two ethernet addresses, returns true if equal, false otherwise.
+ *
+ * The function doesn't need any conditional branches and possibly uses
+ * word memory accesses on CPU allowing cheap unaligned memory reads.
+ * arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2}
+ *
+ * Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits.
+ */
+
+static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
+					   const u8 addr2[6+2])
+{
+	return !compare_ether_addr_64bits(addr1, addr2);
+}
+
+/**
  * is_etherdev_addr - Tell if given Ethernet address belongs to the device.
  * @dev: Pointer to a device structure
  * @addr: Pointer to a six-byte array containing the Ethernet address
Signature · 1 line
1.7.8.111.gad25c.dirty
maintainer Applied
#12 lore raw

Re: [PATCH 2/3] etherdevice.h: Add ether_addr_equal_64bits

From: Joe Perches <[email protected]>
Date: Wed, 9 May 2012 20:04:03 -0700

Quoted 8 lines

Add an optimized boolean function to check if
2 ethernet addresses are the same.

This is to avoid any confusion about compare_ether_addr_64bits returning an unsigned, and not being able to use the compare_ether_addr_64bits function for sorting ala memcmp.

Applied.

#13 lore raw

PATCH 3/3 net,drivers/net: Convert compare_ether_addr_64bits to ether_addr_equal_64bits

In reply to Joe Perches

Use the new bool function ether_addr_equal_64bits to add some clarity and reduce the likelihood for misuse of compare_ether_addr_64bits for sorting.

Done via cocci script:

$ cat compare_ether_addr_64bits.cocci
@@
expression a,b;
@@
-	!compare_ether_addr_64bits(a, b)
+	ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- compare_ether_addr_64bits(a, b)
+ !ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- !ether_addr_equal_64bits(a, b) == 0
+ ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- !ether_addr_equal_64bits(a, b) != 0
+ !ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- ether_addr_equal_64bits(a, b) == 0
+ !ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- ether_addr_equal_64bits(a, b) != 0
+ ether_addr_equal_64bits(a, b)

@@
expression a,b;
@@
- !!ether_addr_equal_64bits(a, b)
+ ether_addr_equal_64bits(a, b)

---
 drivers/net/bonding/bond_alb.c |   58 ++++++++++++++++++++--------------------
 drivers/net/macvlan.c          |    7 ++---
 net/ethernet/eth.c             |    5 ++-
 3 files changed, 35 insertions(+), 35 deletions(-)
drivers/net/bonding/bond_alb.c +29 -29
index 9abfde4..b4f1b4a 100644
@@ -332,7 +332,7 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
 	if ((client_info->assigned) &&
 	    (client_info->ip_src == arp->ip_dst) &&
 	    (client_info->ip_dst == arp->ip_src) &&
-	    (compare_ether_addr_64bits(client_info->mac_dst, arp->mac_src))) {
+	    (!ether_addr_equal_64bits(client_info->mac_dst, arp->mac_src))) {
 		/* update the clients MAC address */
 		memcpy(client_info->mac_dst, arp->mac_src, ETH_ALEN);
 		client_info->ntt = 1;
@@ -448,8 +448,8 @@ static void rlb_clear_slave(struct bonding *bond, struct slave *slave)
 
 			if (assigned_slave) {
 				rx_hash_table[index].slave = assigned_slave;
-				if (compare_ether_addr_64bits(rx_hash_table[index].mac_dst,
-							      mac_bcast)) {
+				if (!ether_addr_equal_64bits(rx_hash_table[index].mac_dst,
+							     mac_bcast)) {
 					bond_info->rx_hashtbl[index].ntt = 1;
 					bond_info->rx_ntt = 1;
 					/* A slave has been removed from the
@@ -561,7 +561,7 @@ static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *sla
 		client_info = &(bond_info->rx_hashtbl[hash_index]);
 
 		if ((client_info->slave == slave) &&
-		    compare_ether_addr_64bits(client_info->mac_dst, mac_bcast)) {
+		    !ether_addr_equal_64bits(client_info->mac_dst, mac_bcast)) {
 			client_info->ntt = 1;
 			ntt = 1;
 		}
@@ -600,9 +600,9 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, __be32 src_ip)
 		 * unicast mac address.
 		 */
 		if ((client_info->ip_src == src_ip) &&
-		    compare_ether_addr_64bits(client_info->slave->dev->dev_addr,
-			   bond->dev->dev_addr) &&
-		    compare_ether_addr_64bits(client_info->mac_dst, mac_bcast)) {
+		    !ether_addr_equal_64bits(client_info->slave->dev->dev_addr,
+					     bond->dev->dev_addr) &&
+		    !ether_addr_equal_64bits(client_info->mac_dst, mac_bcast)) {
 			client_info->ntt = 1;
 			bond_info->rx_ntt = 1;
 		}
@@ -629,7 +629,7 @@ static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bon
 		if ((client_info->ip_src == arp->ip_src) &&
 		    (client_info->ip_dst == arp->ip_dst)) {
 			/* the entry is already assigned to this client */
-			if (compare_ether_addr_64bits(arp->mac_dst, mac_bcast)) {
+			if (!ether_addr_equal_64bits(arp->mac_dst, mac_bcast)) {
 				/* update mac address from arp */
 				memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN);
 			}
@@ -664,7 +664,7 @@ static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bon
 		memcpy(client_info->mac_dst, arp->mac_dst, ETH_ALEN);
 		client_info->slave = assigned_slave;
 
-		if (compare_ether_addr_64bits(client_info->mac_dst, mac_bcast)) {
+		if (!ether_addr_equal_64bits(client_info->mac_dst, mac_bcast)) {
 			client_info->ntt = 1;
 			bond->alb_info.rx_ntt = 1;
 		} else {
@@ -1009,18 +1009,18 @@ static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *sla
 	int perm_curr_diff;
 	int perm_bond_diff;
 
-	perm_curr_diff = compare_ether_addr_64bits(slave->perm_hwaddr,
-						   slave->dev->dev_addr);
-	perm_bond_diff = compare_ether_addr_64bits(slave->perm_hwaddr,
-						   bond->dev->dev_addr);
+	perm_curr_diff = !ether_addr_equal_64bits(slave->perm_hwaddr,
+						  slave->dev->dev_addr);
+	perm_bond_diff = !ether_addr_equal_64bits(slave->perm_hwaddr,
+						  bond->dev->dev_addr);
 
 	if (perm_curr_diff && perm_bond_diff) {
 		struct slave *tmp_slave;
 		int i, found = 0;
 
 		bond_for_each_slave(bond, tmp_slave, i) {
-			if (!compare_ether_addr_64bits(slave->perm_hwaddr,
-						       tmp_slave->dev->dev_addr)) {
+			if (ether_addr_equal_64bits(slave->perm_hwaddr,
+						    tmp_slave->dev->dev_addr)) {
 				found = 1;
 				break;
 			}
@@ -1074,10 +1074,10 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
 	 * check uniqueness of slave's mac address against the other
 	 * slaves in the bond.
 	 */
-	if (compare_ether_addr_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) {
+	if (!ether_addr_equal_64bits(slave->perm_hwaddr, bond->dev->dev_addr)) {
 		bond_for_each_slave(bond, tmp_slave1, i) {
-			if (!compare_ether_addr_64bits(tmp_slave1->dev->dev_addr,
-						       slave->dev->dev_addr)) {
+			if (ether_addr_equal_64bits(tmp_slave1->dev->dev_addr,
+						    slave->dev->dev_addr)) {
 				found = 1;
 				break;
 			}
@@ -1099,8 +1099,8 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
 	bond_for_each_slave(bond, tmp_slave1, i) {
 		found = 0;
 		bond_for_each_slave(bond, tmp_slave2, j) {
-			if (!compare_ether_addr_64bits(tmp_slave1->perm_hwaddr,
-						       tmp_slave2->dev->dev_addr)) {
+			if (ether_addr_equal_64bits(tmp_slave1->perm_hwaddr,
+						    tmp_slave2->dev->dev_addr)) {
 				found = 1;
 				break;
 			}
@@ -1115,8 +1115,8 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
 		}
 
 		if (!has_bond_addr) {
-			if (!compare_ether_addr_64bits(tmp_slave1->dev->dev_addr,
-						       bond->dev->dev_addr)) {
+			if (ether_addr_equal_64bits(tmp_slave1->dev->dev_addr,
+						    bond->dev->dev_addr)) {
 
 				has_bond_addr = tmp_slave1;
 			}
@@ -1257,7 +1257,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
 	case ETH_P_IP: {
 		const struct iphdr *iph = ip_hdr(skb);
 
-		if (!compare_ether_addr_64bits(eth_data->h_dest, mac_bcast) ||
+		if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast) ||
 		    (iph->daddr == ip_bcast) ||
 		    (iph->protocol == IPPROTO_IGMP)) {
 			do_tx_balance = 0;
@@ -1271,7 +1271,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
 		/* IPv6 doesn't really use broadcast mac address, but leave
 		 * that here just in case.
 		 */
-		if (!compare_ether_addr_64bits(eth_data->h_dest, mac_bcast)) {
+		if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast)) {
 			do_tx_balance = 0;
 			break;
 		}
@@ -1279,7 +1279,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
 		/* IPv6 uses all-nodes multicast as an equivalent to
 		 * broadcasts in IPv4.
 		 */
-		if (!compare_ether_addr_64bits(eth_data->h_dest, mac_v6_allmcast)) {
+		if (ether_addr_equal_64bits(eth_data->h_dest, mac_v6_allmcast)) {
 			do_tx_balance = 0;
 			break;
 		}
@@ -1603,8 +1603,8 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
 		struct slave *tmp_slave;
 		/* find slave that is holding the bond's mac address */
 		bond_for_each_slave(bond, tmp_slave, i) {
-			if (!compare_ether_addr_64bits(tmp_slave->dev->dev_addr,
-						       bond->dev->dev_addr)) {
+			if (ether_addr_equal_64bits(tmp_slave->dev->dev_addr,
+						    bond->dev->dev_addr)) {
 				swap_slave = tmp_slave;
 				break;
 			}
@@ -1681,8 +1681,8 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
 	swap_slave = NULL;
 
 	bond_for_each_slave(bond, slave, i) {
-		if (!compare_ether_addr_64bits(slave->dev->dev_addr,
-					       bond_dev->dev_addr)) {
+		if (ether_addr_equal_64bits(slave->dev->dev_addr,
+					    bond_dev->dev_addr)) {
 			swap_slave = slave;
 			break;
 		}
drivers/net/macvlan.c +3 -4
index 9653ed6..ebacec1 100644
@@ -57,7 +57,7 @@ static struct macvlan_dev *macvlan_hash_lookup(const struct macvlan_port *port,
 	struct hlist_node *n;
 
 	hlist_for_each_entry_rcu(vlan, n, &port->vlan_hash[addr[5]], hlist) {
-		if (!compare_ether_addr_64bits(vlan->dev->dev_addr, addr))
+		if (ether_addr_equal_64bits(vlan->dev->dev_addr, addr))
 			return vlan;
 	}
 	return NULL;
@@ -96,7 +96,7 @@ static int macvlan_addr_busy(const struct macvlan_port *port,
 	 * currently in use by the underlying device or
 	 * another macvlan.
 	 */
-	if (!compare_ether_addr_64bits(port->dev->dev_addr, addr))
+	if (ether_addr_equal_64bits(port->dev->dev_addr, addr))
 		return 1;
 
 	if (macvlan_hash_lookup(port, addr))
@@ -118,8 +118,7 @@ static int macvlan_broadcast_one(struct sk_buff *skb,
 		return vlan->forward(dev, skb);
 
 	skb->dev = dev;
-	if (!compare_ether_addr_64bits(eth->h_dest,
-				       dev->broadcast))
+	if (ether_addr_equal_64bits(eth->h_dest, dev->broadcast))
 		skb->pkt_type = PACKET_BROADCAST;
 	else
 		skb->pkt_type = PACKET_MULTICAST;
net/ethernet/eth.c +3 -2
index 5889a6c..36e5880 100644
@@ -164,7 +164,7 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
 	eth = eth_hdr(skb);
 
 	if (unlikely(is_multicast_ether_addr(eth->h_dest))) {
-		if (!compare_ether_addr_64bits(eth->h_dest, dev->broadcast))
+		if (ether_addr_equal_64bits(eth->h_dest, dev->broadcast))
 			skb->pkt_type = PACKET_BROADCAST;
 		else
 			skb->pkt_type = PACKET_MULTICAST;
@@ -179,7 +179,8 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
 	 */
 
 	else if (1 /*dev->flags&IFF_PROMISC */ ) {
-		if (unlikely(compare_ether_addr_64bits(eth->h_dest, dev->dev_addr)))
+		if (unlikely(!ether_addr_equal_64bits(eth->h_dest,
+						      dev->dev_addr)))
 			skb->pkt_type = PACKET_OTHERHOST;
 	}
 
Signature · 1 line
1.7.8.111.gad25c.dirty
maintainer Applied
#14 lore raw

Re: [PATCH 3/3] net,drivers/net: Convert compare_ether_addr_64bits to ether_addr_equal_64bits

From: Joe Perches <[email protected]>
Date: Wed, 9 May 2012 20:04:04 -0700

Quoted 5 lines

Use the new bool function ether_addr_equal_64bits to add some clarity and reduce the likelihood for misuse of compare_ether_addr_64bits for sorting.

Done via cocci script:

...

Quoted 1 line

Applied.

#15 lore raw

PATCH 1/1 etherdevice: Remove now unused compare_ether_addr_64bits

Move and invert the logic from the otherwise unused compare_ether_addr_64bits to ether_addr_equal_64bits.

Neaten the logic in is_etherdev_addr.

---
 include/linux/etherdevice.h |   46 ++++++++++++------------------------------
 1 files changed, 13 insertions(+), 33 deletions(-)
include/linux/etherdevice.h +13 -33
index afacf85..dc85c1d 100644
@@ -193,12 +193,12 @@ static inline unsigned long zap_last_2bytes(unsigned long value)
 }
 
 /**
- * compare_ether_addr_64bits - Compare two Ethernet addresses
+ * ether_addr_equal_64bits - Compare two Ethernet addresses
  * @addr1: Pointer to an array of 8 bytes
  * @addr2: Pointer to an other array of 8 bytes
  *
- * Compare two ethernet addresses, returns 0 if equal, non-zero otherwise.
- * Unlike memcmp(), it doesn't return a value suitable for sorting.
+ * Compare two ethernet addresses, returns true if equal, false otherwise.
+ *
  * The function doesn't need any conditional branches and possibly uses
  * word memory accesses on CPU allowing cheap unaligned memory reads.
  * arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2}
@@ -206,45 +206,25 @@ static inline unsigned long zap_last_2bytes(unsigned long value)
  * Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits.
  */
 
-static inline unsigned compare_ether_addr_64bits(const u8 addr1[6+2],
-						 const u8 addr2[6+2])
+static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
+					   const u8 addr2[6+2])
 {
 #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
 	unsigned long fold = ((*(unsigned long *)addr1) ^
 			      (*(unsigned long *)addr2));
 
 	if (sizeof(fold) == 8)
-		return zap_last_2bytes(fold) != 0;
+		return zap_last_2bytes(fold) == 0;
 
 	fold |= zap_last_2bytes((*(unsigned long *)(addr1 + 4)) ^
 				(*(unsigned long *)(addr2 + 4)));
-	return fold != 0;
+	return fold == 0;
 #else
-	return compare_ether_addr(addr1, addr2);
+	return ether_addr_equal(addr1, addr2);
 #endif
 }
 
 /**
- * ether_addr_equal_64bits - Compare two Ethernet addresses
- * @addr1: Pointer to an array of 8 bytes
- * @addr2: Pointer to an other array of 8 bytes
- *
- * Compare two ethernet addresses, returns true if equal, false otherwise.
- *
- * The function doesn't need any conditional branches and possibly uses
- * word memory accesses on CPU allowing cheap unaligned memory reads.
- * arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2}
- *
- * Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits.
- */
-
-static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
-					   const u8 addr2[6+2])
-{
-	return !compare_ether_addr_64bits(addr1, addr2);
-}
-
-/**
  * is_etherdev_addr - Tell if given Ethernet address belongs to the device.
  * @dev: Pointer to a device structure
  * @addr: Pointer to a six-byte array containing the Ethernet address
@@ -252,23 +232,23 @@ static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
  * Compare passed address with all addresses of the device. Return true if the
  * address if one of the device addresses.
  *
- * Note that this function calls compare_ether_addr_64bits() so take care of
+ * Note that this function calls ether_addr_equal_64bits() so take care of
  * the right padding.
  */
 static inline bool is_etherdev_addr(const struct net_device *dev,
 				    const u8 addr[6 + 2])
 {
 	struct netdev_hw_addr *ha;
-	int res = 1;
+	bool res = false;
 
 	rcu_read_lock();
 	for_each_dev_addr(dev, ha) {
-		res = compare_ether_addr_64bits(addr, ha->addr);
-		if (!res)
+		res = ether_addr_equal_64bits(addr, ha->addr);
+		if (res)
 			break;
 	}
 	rcu_read_unlock();
-	return !res;
+	return res;
 }
 #endif	/* __KERNEL__ */
 
maintainer Applied
#16 lore raw

Re: [PATCH net-next] etherdevice: Remove now unused compare_ether_addr_64bits

From: Joe Perches <[email protected]>
Date: Fri, 11 May 2012 15:21:06 -0700

Quoted 6 lines

Move and invert the logic from the otherwise unused compare_ether_addr_64bits to ether_addr_equal_64bits.

Neaten the logic in is_etherdev_addr.

Applied, thanks Joe.