linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] iwlwifi: mvm: allow monitor mode capture in STA mode
@ 2017-09-14  8:50 gavinli
  2017-09-14  8:54 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: gavinli @ 2017-09-14  8:50 UTC (permalink / raw)
  To: Johannes Berg, Emmanuel Grumbach, Luca Coelho, Intel Linux Wireless
  Cc: linux-wireless, Gavin Li

From: Gavin Li <git@thegavinli.com>

Open up the filter if there is a monitor interface configured; this
allows all packets on the channel to be captured even if the device is
in STA mode and associated to a BSS.

Signed-off-by: Gavin Li <git@thegavinli.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c |  6 ++++++
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index a2bf530eeae4..38b933dc8545 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -654,6 +654,12 @@ static void iwl_mvm_mac_ctxt_cmd_common(struct iwl_mvm *mvm,
 
 	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP);
 
+	if (mvm->hw->conf.flags & IEEE80211_CONF_MONITOR)
+		cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROMISC |
+						 MAC_FILTER_IN_CONTROL_AND_MGMT |
+						 MAC_FILTER_IN_BEACON |
+						 MAC_FILTER_IN_PROBE_REQUEST);
+
 	for (i = 0; i < IEEE80211_NUM_ACS; i++) {
 		u8 txf = iwl_mvm_mac_ac_to_tx_fifo(mvm, i);
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 15f2d826bb4b..c529fb8228df 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -1530,8 +1530,23 @@ static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw,
 	mutex_unlock(&mvm->mutex);
 }
 
+static void iwl_mvm_monitor_changed_iterator(void *_mvm, u8 *mac, struct ieee80211_vif *vif)
+{
+	struct iwl_mvm *mvm = _mvm;
+	iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
+}
+
 static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed)
 {
+	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
+
+	if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
+		mutex_lock(&mvm->mutex);
+		ieee80211_iterate_active_interfaces(hw, IEEE80211_IFACE_ITER_NORMAL,
+				iwl_mvm_monitor_changed_iterator, mvm);
+		mutex_unlock(&mvm->mutex);
+	}
+
 	return 0;
 }
 
-- 
2.14.1

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

* Re: [PATCH v1] iwlwifi: mvm: allow monitor mode capture in STA mode
  2017-09-14  8:50 [PATCH v1] iwlwifi: mvm: allow monitor mode capture in STA mode gavinli
@ 2017-09-14  8:54 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2017-09-14  8:54 UTC (permalink / raw)
  To: gavinli, Emmanuel Grumbach, Luca Coelho, Intel Linux Wireless
  Cc: linux-wireless, Gavin Li

On Thu, 2017-09-14 at 01:50 -0700, gavinli@thegavinli.com wrote:
> 
>  	cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP);
>  
> +	if (mvm->hw->conf.flags & IEEE80211_CONF_MONITOR)
> +		cmd->filter_flags |=
> cpu_to_le32(MAC_FILTER_IN_PROMISC |
> +						 MAC_FILTER_IN_CONTR
> OL_AND_MGMT |
> +						 MAC_FILTER_IN_BEACO
> N |
> +						 MAC_FILTER_IN_PROBE
> _REQUEST);

[...]

> +	if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
> +		mutex_lock(&mvm->mutex);
> +		ieee80211_iterate_active_interfaces(hw,
> IEEE80211_IFACE_ITER_NORMAL,
> +				iwl_mvm_monitor_changed_iterator,
> mvm);
> +		mutex_unlock(&mvm->mutex);
> +	}

This isn't right from a mac80211 perspective - at the very least it
should follow the monitor flags; checking CONF_CHANGE_MONITOR is always
a bad idea.

johannes

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

end of thread, other threads:[~2017-09-14  8:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-14  8:50 [PATCH v1] iwlwifi: mvm: allow monitor mode capture in STA mode gavinli
2017-09-14  8:54 ` 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).