All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: wireless: Add module_param(mac_prefix) to mac80211_hwsim
@ 2020-03-02 23:49 rkir
  2020-03-03  6:35 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: rkir @ 2020-03-02 23:49 UTC (permalink / raw
  To: johannes; +Cc: linux-wireless, lfy, Roman Kiryanov

From: Roman Kiryanov <rkir@google.com>

By default mac80211_hwsim creates N radios with
MAC addresses like '02:00:00:nn:nn:00' where nnnn
is incremented.

We (Android Studio Emulator) need a way to have unique
MAC addresses. Currently in mac80211_hwsim this can
be done by sending HWSIM_CMD_DEL_RADIO and
HWSIM_CMD_NEW_RADIO commands.

The 'mac_prefix' parameter provides an easier way to
make MAC address unique by specifying two octets in
MAC address, i.e. '02:pp:pp:nn:nn:00'.

Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 drivers/net/wireless/mac80211_hwsim.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 03738107fd10..1519435ecc76 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -62,6 +62,10 @@ static bool support_p2p_device = true;
 module_param(support_p2p_device, bool, 0444);
 MODULE_PARM_DESC(support_p2p_device, "Support P2P-Device interface type");
 
+static ushort mac_prefix;
+module_param(mac_prefix, ushort, 0444);
+MODULE_PARM_DESC(mac_prefix, "Second and third most significant octets in MAC");
+
 /**
  * enum hwsim_regtest - the type of regulatory tests we offer
  *
@@ -2811,6 +2815,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
 	if (!param->perm_addr) {
 		eth_zero_addr(addr);
 		addr[0] = 0x02;
+		addr[1] = (mac_prefix >> 8) & 0xFF;
+		addr[2] = mac_prefix & 0xFF;
 		addr[3] = idx >> 8;
 		addr[4] = idx;
 		memcpy(data->addresses[0].addr, addr, ETH_ALEN);
-- 
2.25.0.265.gbab2e86ba0-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: wireless: Add module_param(mac_prefix) to mac80211_hwsim
  2020-03-02 23:49 [PATCH] net: wireless: Add module_param(mac_prefix) to mac80211_hwsim rkir
@ 2020-03-03  6:35 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2020-03-03  6:35 UTC (permalink / raw
  To: rkir; +Cc: Johannes Berg, linux-wireless, lfy

Hi Roman,

> By default mac80211_hwsim creates N radios with
> MAC addresses like '02:00:00:nn:nn:00' where nnnn
> is incremented.
> 
> We (Android Studio Emulator) need a way to have unique
> MAC addresses. Currently in mac80211_hwsim this can
> be done by sending HWSIM_CMD_DEL_RADIO and
> HWSIM_CMD_NEW_RADIO commands.
> 
> The 'mac_prefix' parameter provides an easier way to
> make MAC address unique by specifying two octets in
> MAC address, i.e. '02:pp:pp:nn:nn:00'.

since we have an API for creating radios, wouldn’t it be better to add a kernel option to allow setting the default number of radios on module load to 0 and then let userspace create them on demand. I for example always set my testing kernel to load 0 radios.

Regards

Marcel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-03  6:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-02 23:49 [PATCH] net: wireless: Add module_param(mac_prefix) to mac80211_hwsim rkir
2020-03-03  6:35 ` Marcel Holtmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.