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

Commit 160e39c9 authored by Weilun Du's avatar Weilun Du Committed by Alistair Delva
Browse files

BACKPORT: mac80211_hwsim: add concurrent channels scanning support over virtio



This fixed the crash when setting channels to 2 or more when
communicating over virtio.

Signed-off-by: default avatarWeilun Du <wdu@google.com>
Link: https://lore.kernel.org/r/20210506180530.3418576-1-wdu@google.com


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>

(cherry picked from commit 626c30f9e77354301ff9162c3bdddaf92d9b5cf3 https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=626c30f9e77354301ff9162c3bdddaf92d9b5cf3

)
Bug: 182576217
Signed-off-by: default avatarWeilun Du <wdu@google.com>
Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
Change-Id: Ia9be6c1d962b941a92f4e1be41e874dbe08024e5
(cherry picked from commit d1e50a709c169e3f090c8bdd23f86547b82b5d55)
parent e30e2652
Loading
Loading
Loading
Loading
+16 −7
Original line number Original line Diff line number Diff line
@@ -1168,7 +1168,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
	if (nla_put_u32(skb, HWSIM_ATTR_FLAGS, hwsim_flags))
	if (nla_put_u32(skb, HWSIM_ATTR_FLAGS, hwsim_flags))
		goto nla_put_failure;
		goto nla_put_failure;


	if (nla_put_u32(skb, HWSIM_ATTR_FREQ, data->channel->center_freq))
	if (nla_put_u32(skb, HWSIM_ATTR_FREQ, channel->center_freq))
		goto nla_put_failure;
		goto nla_put_failure;


	/* We get the tx control (rate and retries) info*/
	/* We get the tx control (rate and retries) info*/
@@ -2355,7 +2355,7 @@ static void mac80211_hwsim_remove_chanctx(struct ieee80211_hw *hw,
	mutex_lock(&hwsim->mutex);
	mutex_lock(&hwsim->mutex);
	hwsim->chanctx = NULL;
	hwsim->chanctx = NULL;
	mutex_unlock(&hwsim->mutex);
	mutex_unlock(&hwsim->mutex);
	wiphy_debug(hw->wiphy,
	wiphy_dbg(hw->wiphy,
		  "remove channel context control: %d MHz/width: %d/cfreqs:%d/%d MHz\n",
		  "remove channel context control: %d MHz/width: %d/cfreqs:%d/%d MHz\n",
		  ctx->def.chan->center_freq, ctx->def.width,
		  ctx->def.chan->center_freq, ctx->def.width,
		  ctx->def.center_freq1, ctx->def.center_freq2);
		  ctx->def.center_freq1, ctx->def.center_freq2);
@@ -3329,6 +3329,17 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
	if (!channel)
	if (!channel)
		goto out;
		goto out;


	if (data2->use_chanctx) {
		if (data2->tmp_chan)
			channel = data2->tmp_chan;
		else if (data2->chanctx)
			channel = data2->chanctx->def.chan;
	} else {
		channel = data2->channel;
	}
	if (!channel)
		goto out;

	if (!hwsim_virtio_enabled) {
	if (!hwsim_virtio_enabled) {
		if (hwsim_net_get_netgroup(genl_info_net(info)) !=
		if (hwsim_net_get_netgroup(genl_info_net(info)) !=
		    data2->netgroup)
		    data2->netgroup)
@@ -3363,8 +3374,6 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
	}
	}


	rx_status.band = channel->band;
	rx_status.band = channel->band;
	rx_status.freq = data2->channel->center_freq;
	rx_status.band = data2->channel->band;
	rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]);
	rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]);
	if (rx_status.rate_idx >= data2->hw->wiphy->bands[rx_status.band]->n_bitrates)
	if (rx_status.rate_idx >= data2->hw->wiphy->bands[rx_status.band]->n_bitrates)
		goto out;
		goto out;