Skip to contentSkip to conversation

mac80211: Parse legacy and HT rate in injected frames

PATCH Superseded Sven Eckelmann 2 participants 3 messages Jan 25, 2016 – Jan 26, 2016

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mac80211: Parse legacy and HT rate in injected frames

Drivers/devices without their own rate control algorithm can get the information what rates they should use from either the radiotap header of injected frames or from the rate control algorithm. But the parsing of the legacy rate information from the radiotap header was removed in commit e6a9854b05c1 ("mac80211/drivers: rewrite the rate control API").

The removal of this feature heavily reduced the usefulness of frame injection when wanting to simulate specific transmission behavior. Having rate parsing together with MCS rates and retry support allows a fine grained selection of the tx behavior of injected frames for these kind of tests.

Cc Simon Wunderlich <[email protected]>

---
v2:
- resent RFC as v2 because first patch was not correctly marked as RFC
- removed check from ieee80211_xmit_fast because this one is never called for injected frames

 Documentation/networking/mac80211-injection.txt | 17 ++++++
 include/net/mac80211.h                          |  2 +
 net/mac80211/tx.c                               | 73 ++++++++++++++++++++++++-
 3 files changed, 89 insertions(+), 3 deletions(-)
Documentation/networking/mac80211-injection.txt +17 -0
index 3a93007..ec8f934 100644
@@ -28,6 +28,23 @@ radiotap headers and used to control injection:
    IEEE80211_RADIOTAP_F_TX_NOACK: frame should be sent without waiting for
 				  an ACK even if it is a unicast frame
 
+ * IEEE80211_RADIOTAP_RATE
+
+   legacy rate for the transmission (only for devices without own rate control)
+
+ * IEEE80211_RADIOTAP_MCS
+
+   HT rate for the transmission (only for devices without own rate control).
+   Also some flags are parsed
+
+   IEEE80211_TX_RC_SHORT_GI: use short guard interval
+   IEEE80211_TX_RC_40_MHZ_WIDTH: send in HT40 mode
+
+ * IEEE80211_RADIOTAP_DATA_RETRIES
+
+   number of retries when either IEEE80211_RADIOTAP_RATE or
+   IEEE80211_RADIOTAP_MCS was used
+
 The injection code can also skip all other currently defined radiotap fields
 facilitating replay of captured radiotap headers directly.
 
include/net/mac80211.h +2 -0
index 566df20..3c3c1f3 100644
@@ -708,12 +708,14 @@ enum mac80211_tx_info_flags {
  *	protocol frame (e.g. EAP)
  * @IEEE80211_TX_CTRL_PS_RESPONSE: This frame is a response to a poll
  *	frame (PS-Poll or uAPSD).
+ * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information
  *
  * These flags are used in tx_info->control.flags.
  */
 enum mac80211_tx_control_flags {
 	IEEE80211_TX_CTRL_PORT_CTRL_PROTO	= BIT(0),
 	IEEE80211_TX_CTRL_PS_RESPONSE		= BIT(1),
+	IEEE80211_TX_CTRL_RATE_INJECT		= BIT(2),
 };
 
 /*
net/mac80211/tx.c +70 -3

111 lines not on this page · raw message

maintainer
#1 lore raw

Hi,

Quoted 5 lines

  CALL_TXH(ieee80211_tx_h_select_key);

net/mac80211/tx.c +2 -1
-	if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))
+	if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) &&
+	    !(info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT))

  CALL_TXH(ieee80211_tx_h_rate_ctrl);

This seems a bit problematic. ieee80211_tx_h_rate_ctrl() also sets up some protection, e.g.

        info->control.use_rts = txrc.rts; info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot;

and preamble settings

        info->control.short_preamble = txrc.short_preamble;

Are you sure you want to skip that entirely?

Review

Quoted 7 lines
net/mac80211/tx.c +3 -0
+		info->control.rates[0].flags = rate_flags;
+		if (rate_retries + 1 > local->hw.max_rate_tries)
+			info->control.rates[0].count = local-
Quoted 1 line

hw.max_rate_tries;

(quoted diff) +3 -0
+		else
+			info->control.rates[0].count = rate_retries
+ 1;

max() or max_t()?

Quoted 4 lines

  /* process and remove the injection radiotap header */

net/mac80211/tx.c +1 -1
-	if (!ieee80211_parse_tx_radiotap(skb))
+	if (!ieee80211_parse_tx_radiotap(skb, local))

  goto fail;

I'd prefer adding "local" as the first argument since that's far more commonly done in mac80211.

johannes

#2 lore raw
Quoted 10 lines · On Tuesday 26 January 2016 14:27:20 Johannes Berg wrote:

Hi,

net/mac80211/tx.c static int invoke_tx_handlers(struct ieee80211_tx_data *tx) · line 1481

Quoted 5 lines
net/mac80211/tx.c +2 -1
 	CALL_TXH(ieee80211_tx_h_select_key);
-	if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))
+	if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) &&
+	    !(info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT))
 		CALL_TXH(ieee80211_tx_h_rate_ctrl);

This seems a bit problematic. ieee80211_tx_h_rate_ctrl() also sets up some protection, e.g.

Quoted 8 lines
        info->control.use_rts = txrc.rts;
        info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot;

and preamble settings

        info->control.short_preamble = txrc.short_preamble;

Are you sure you want to skip that entirely?

You are correct, these should be set but rate_control_get_rate should be skipped.

Quoted 10 lines

Review

Quoted 8 lines
net/mac80211/tx.c +3 -0
+		info->control.rates[0].flags = rate_flags;
+		if (rate_retries + 1 > local->hw.max_rate_tries)
+			info->control.rates[0].count = local-
Quoted 1 line

hw.max_rate_tries;

(quoted diff) +3 -0
+		else
+			info->control.rates[0].count = rate_retries
+ 1;

max() or max_t()?

min_t - but yes, you are right.

Btw. we can also change it when you prefer that by default injected frames with rates but without DATA_RETRIES should get local->hw.max_rate_tries as retries.

Quoted 8 lines

net/mac80211/tx.c netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, · line 1890

Quoted 5 lines
net/mac80211/tx.c +1 -1
 	/* process and remove the injection radiotap header */
-	if (!ieee80211_parse_tx_radiotap(skb))
+	if (!ieee80211_parse_tx_radiotap(skb, local))
 		goto fail;

I'd prefer adding "local" as the first argument since that's far more commonly done in mac80211.

Ok, will be changed.

Kind regards,
Sven