Search Linux Wireless

[RFC 4/4] mac80211_hwsim: add radio idx param to netlink callback of radio creation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since the radio index is already a valid NL attribute, this patch simply
try to read it and create the radio specific to this index by the
previously used scheme.

Since this allows to create radios out of row, we need to search for a
free index for a new radio, when the index is not present as parameter.

Signed-off-by: Benjamin Beichler <benjamin.beichler@xxxxxxxxxxxxxx>
---
 drivers/net/wireless/mac80211_hwsim.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 5dd4be2a8487..faa0e39523aa 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2436,6 +2436,7 @@ struct hwsim_new_radio_params {
 	bool destroy_on_close;
 	const char *hwname;
 	bool no_vif;
+	int idx;
 };
 
 static void hwsim_mcast_config_msg(struct sk_buff *mcast_skb,
@@ -2645,13 +2646,9 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
 	skb_queue_head_init(&data->pending);
 
 	SET_IEEE80211_DEV(hw, data->dev);
-	eth_zero_addr(addr);
-	addr[0] = 0x02;
-	addr[3] = idx >> 8;
-	addr[4] = idx;
-	memcpy(data->addresses[0].addr, addr, ETH_ALEN);
-	memcpy(data->addresses[1].addr, addr, ETH_ALEN);
-	data->addresses[1].addr[0] |= 0x40;
+	memcpy(data->addresses[0].addr, &mac.addr, ETH_ALEN);
+	memcpy(data->addresses[1].addr, &mac.addr, ETH_ALEN);
+	data->addresses[0].addr[0] = 0x02;
 	hw->wiphy->n_addresses = 2;
 	hw->wiphy->addresses = data->addresses;
 
@@ -3304,6 +3301,11 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
 		param.regd = hwsim_world_regdom_custom[idx];
 	}
 
+	if (info->attrs[HWSIM_ATTR_RADIO_ID])
+		param.idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]);
+	else
+		param.idx = -1;
+
 	return mac80211_hwsim_new_radio(info, &param);
 }
 
-- 
2.14.1




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux