Skip to contentSkip to conversation

Send own beacons to monitor interfaces

RFC In review Helmut Schaa 3 participants 6 messages Sep 1, 2015 mac80211

lore
Share & tools
lore
#0 lore raw

cover Send own beacons to monitor interfaces

Sending as RFC to gather some feedback. It can be quite useful to see own beacons on monitor interfaces for debugging purposes.

However, since there is no tx status for beacons on most drivers this patchset sends a copy of each beacon fetched via ieee80211_beacon_get_tim to the monitor interfaces.

Of course, the beacon won't have proper seq numbers for example as these are filled in in hw/fw.

Still this can be very helpful for debugging.

Helmut Schaa (2):
mac80211: Split sending tx'ed frames to monitor interfaces into its
own function
mac80211: Copy tx'ed beacons to monitor mode

 net/mac80211/ieee80211_i.h |   3 ++
 net/mac80211/status.c      | 108 +++++++++++++++++++++++++--------------------
 net/mac80211/tx.c          |  10 +++++
 3 files changed, 72 insertions(+), 49 deletions(-)
Signature · 1 line
1.8.4.5
#1 lore raw

RFC 1/2 mac80211: Split sending tx'ed frames to monitor interfaces into its own function

This allows ieee80211_tx_monitor to be used directly for sending 802.11 frames to all monitor interfaces.

---
 net/mac80211/ieee80211_i.h |   3 ++
 net/mac80211/status.c      | 108 +++++++++++++++++++++++++--------------------
 2 files changed, 62 insertions(+), 49 deletions(-)
net/mac80211/ieee80211_i.h +3 -0
index 6e52659..36552de 100644
@@ -1641,6 +1641,9 @@ void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
 struct sk_buff *
 ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
 			      struct sk_buff *skb, u32 info_flags);
+void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
+			  struct ieee80211_supported_band *sband,
+			  int retry_count, int shift, bool send_to_cooked);
 
 void ieee80211_check_fast_xmit(struct sta_info *sta);
 void ieee80211_check_fast_xmit_all(struct ieee80211_local *local);
net/mac80211/status.c +59 -49

133 lines not on this page · raw message

Signature · 1 line
1.8.4.5
#2 lore raw

RFC 2/2 mac80211: Copy tx'ed beacons to monitor mode

In reply to Helmut Schaa

When debugging wireless powersave issues on the AP side it's quite helpful to see our own beacons that are transmitted by the hardware/driver. However, this is not that easy since beacons don't pass through the regular TX queues.

Preferably drivers would call ieee80211_tx_status also for tx'ed beacons but that's not always possible. Hence, just send a copy of each beacon generated by ieee80211_beacon_get_tim to monitor devices when they are getting fetched by the driver.

---
 net/mac80211/tx.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
net/mac80211/tx.c +10 -0
index 84e0e8c..f522579 100644
@@ -3512,6 +3512,9 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
 {
 	struct ieee80211_mutable_offsets offs = {};
 	struct sk_buff *bcn = __ieee80211_beacon_get(hw, vif, &offs, false);
+	struct sk_buff *copy;
+	struct ieee80211_supported_band *sband;
+	int shift;
 
 	if (tim_offset)
 		*tim_offset = offs.tim_offset;
@@ -3519,6 +3522,13 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
 	if (tim_length)
 		*tim_length = offs.tim_length;
 
+	/* send a copy to monitor interfaces */
+	if (hw_to_local(hw)->monitors && (copy = skb_copy(bcn, GFP_ATOMIC))) {
+		shift = ieee80211_vif_get_shift(vif);
+		sband = hw->wiphy->bands[ieee80211_get_sdata_band(vif_to_sdata(vif))];
+		ieee80211_tx_monitor(hw_to_local(hw), copy, sband, 1, shift, true);
+	}
+
 	return bcn;
 }
 EXPORT_SYMBOL(ieee80211_beacon_get_tim);
Signature · 1 line
1.8.4.5
#3 lore raw

Re: [RFC 2/2] mac80211: Copy tx'ed beacons to monitor mode

Quoted 8 lines · Helmut Schaa

When debugging wireless powersave issues on the AP side it's quite helpful to see our own beacons that are transmitted by the hardware/driver. However, this is not that easy since beacons don't pass through the regular TX queues.

Preferably drivers would call ieee80211_tx_status also for tx'ed beacons but that's not always possible. Hence, just send a copy of each beacon generated by ieee80211_beacon_get_tim to monitor devices when they are getting fetched by the driver.

How about also adding a hw flag to allow drivers to indicate that they submit tx status for beacons.

- Felix

#4 lore raw

Re: [RFC 2/2] mac80211: Copy tx'ed beacons to monitor mode

Quoted 11 lines · Felix Fietkau
Quoted 8 lines · Helmut Schaa

When debugging wireless powersave issues on the AP side it's quite helpful to see our own beacons that are transmitted by the hardware/driver. However, this is not that easy since beacons don't pass through the regular TX queues.

Preferably drivers would call ieee80211_tx_status also for tx'ed beacons but that's not always possible. Hence, just send a copy of each beacon generated by ieee80211_beacon_get_tim to monitor devices when they are getting fetched by the driver.

How about also adding a hw flag to allow drivers to indicate that they submit tx status for beacons.

Makes sense, yes. Waiting for other comments before resending ... Helmut

maintainer
#5 lore raw

Re: [RFC 2/2] mac80211: Copy tx'ed beacons to monitor mode

In reply to Helmut Schaa
Quoted 8 lines · Helmut Schaa

When debugging wireless powersave issues on the AP side it's quite helpful to see our own beacons that are transmitted by the hardware/driver. However, this is not that easy since beacons don't pass through the regular TX queues.

Preferably drivers would call ieee80211_tx_status also for tx'ed beacons but that's not always possible. Hence, just send a copy of each beacon generated by ieee80211_beacon_get_tim to monitor devices when they are getting fetched by the driver.

Generally looks fine.

Review struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, · line 3530

Quoted 10 lines
(quoted diff) +6 -0
@@ -3519,6 +3522,13 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
 > 	> if (tim_length)
 > 	> 	> *tim_length = offs.tim_length;
 
+> 	> /* send a copy to monitor interfaces */
+> 	> if (hw_to_local(hw)->monitors && (copy = skb_copy(bcn, GFP_ATOMIC))) {
+> 	> 	> shift = ieee80211_vif_get_shift(vif);
+> 	> 	> sband = hw->wiphy->bands[ieee80211_get_sdata_band(vif_to_sdata(vif))];
+> 	> 	> ieee80211_tx_monitor(hw_to_local(hw), copy, sband, 1, shift, true);
+> 	> }

I don't really like the assignment in the if much - you could move the variable declarations into it though.

send_to_cooked should be false, since very old versions of hostapd use that and would really not expect the beacons there

That has me wondering if we can start to think about removing cooked monitor mode - does anyone know if we perhaps broke it accidentally anyway? ;-)

johannes