* [PATCH] mac80211_hwsim: support any address in userspace
@ 2015-02-23 15:33 Bob Copeland
2015-02-24 10:15 ` Johannes Berg
0 siblings, 1 reply; 2+ messages in thread
From: Bob Copeland @ 2015-02-23 15:33 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, Bob Copeland
Due to the checks in get_hwsim_data_ref_from_addr, wmediumd
was only able to use the second mac address (those starting with
0x42). This is confusing and needlessly limiting, so allow any
configured address.
While at it, use ether_addr_equal since data->addresses and the
address from the netlink payload are aligned(2).
Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
drivers/net/wireless/mac80211_hwsim.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 1204853..be8bb18 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -907,8 +907,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
goto nla_put_failure;
}
- if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER,
- ETH_ALEN, data->addresses[1].addr))
+ if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER, ETH_ALEN, hdr->addr2))
goto nla_put_failure;
/* We get the skb->data */
@@ -2608,14 +2607,18 @@ static struct mac80211_hwsim_data *get_hwsim_data_ref_from_addr(const u8 *addr)
{
struct mac80211_hwsim_data *data;
bool _found = false;
+ int i;
spin_lock_bh(&hwsim_radio_lock);
list_for_each_entry(data, &hwsim_radios, list) {
- if (memcmp(data->addresses[1].addr, addr, ETH_ALEN) == 0) {
- _found = true;
- break;
+ for (i = 0; i < ARRAY_SIZE(data->addresses); i++) {
+ if (ether_addr_equal(data->addresses[i].addr, addr)) {
+ _found = true;
+ goto end_loop;
+ }
}
}
+end_loop:
spin_unlock_bh(&hwsim_radio_lock);
if (!_found)
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mac80211_hwsim: support any address in userspace
2015-02-23 15:33 [PATCH] mac80211_hwsim: support any address in userspace Bob Copeland
@ 2015-02-24 10:15 ` Johannes Berg
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2015-02-24 10:15 UTC (permalink / raw)
To: Bob Copeland; +Cc: linux-wireless
On Mon, 2015-02-23 at 10:33 -0500, Bob Copeland wrote:
> Due to the checks in get_hwsim_data_ref_from_addr, wmediumd
> was only able to use the second mac address (those starting with
> 0x42). This is confusing and needlessly limiting, so allow any
> configured address.
>
> While at it, use ether_addr_equal since data->addresses and the
> address from the netlink payload are aligned(2).
As I mentioned on IRC, I think you should iterate the interfaces to
identify the currently live MAC addresses instead of the fake "hw
addresses" we assign to each hwsim radio.
johannes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-24 10:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-23 15:33 [PATCH] mac80211_hwsim: support any address in userspace Bob Copeland
2015-02-24 10:15 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).