Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7637778 authored by Ben Greear's avatar Ben Greear Committed by Alistair Strachan
Browse files

UPSTREAM: mac80211-hwsim: support destroying radio by name



It is not always convenient to have to know the device-id,
so allow deleting by name as well.

Signed-off-by: default avatarBen Greear <greearb@candelatech.com>
[use wiphy_name() instead of dev_name()]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
(cherry picked from commit 8cdd9e1c37dd888894922b8209d5fc8055cfde52)
Bug: 70214720
Change-Id: I165f6ed6be4c4ecef1ac3b6728b893945748f203
Signed-off-by: default avatarAlistair Strachan <astrachan@google.com>
parent 706dbe5a
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -2475,16 +2475,27 @@ static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info)
static int hwsim_destroy_radio_nl(struct sk_buff *msg, struct genl_info *info)
{
	struct mac80211_hwsim_data *data;
	int idx;
	s64 idx = -1;
	const char *hwname = NULL;

	if (!info->attrs[HWSIM_ATTR_RADIO_ID])
		return -EINVAL;
	if (info->attrs[HWSIM_ATTR_RADIO_ID])
		idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]);
	else if (info->attrs[HWSIM_ATTR_RADIO_NAME])
		hwname = (void *)nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]);
	else
		return -EINVAL;

	spin_lock_bh(&hwsim_radio_lock);
	list_for_each_entry(data, &hwsim_radios, list) {
		if (idx >= 0) {
			if (data->idx != idx)
				continue;
		} else {
			if (hwname &&
			    strcmp(hwname, wiphy_name(data->hw->wiphy)))
				continue;
		}

		list_del(&data->list);
		spin_unlock_bh(&hwsim_radio_lock);
		mac80211_hwsim_destroy_radio(data);
+2 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ enum {
 *	single channel is supported
 * @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_CREATE_RADIO
 *	command to force radio removal when process that created the radio dies
 * @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666
 * @__HWSIM_ATTR_MAX: enum limit
 */

@@ -135,6 +136,7 @@ enum {
	HWSIM_ATTR_SUPPORT_P2P_DEVICE,
	HWSIM_ATTR_USE_CHANCTX,
	HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE,
	HWSIM_ATTR_RADIO_NAME,
	__HWSIM_ATTR_MAX,
};
#define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)