Skip to contentSkip to conversation

mac80211: Fill in skb->protocol information for injected frames

PATCH Superseded Helmut Schaa 5 participants 13 messages Jul 29, 2011 – Jul 31, 2011 mac80211

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mac80211: Fill in skb->protocol information for injected frames

Some drivers (ath9k for example) are using skb->protocol to treat EAPOL frames somehow special (disallow aggregation for example).

When running in AP mode hostapd injects the EAPOL frames through a monitor interface and thus skb->protocol isn't set at all. Hence, if the injected frame is a data frame and carries a rfc1042 headaer update the skb->protocol field accordingly.

---
 net/mac80211/tx.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
net/mac80211/tx.c +20 -0
index b83de4e..939c3f0 100644
@@ -1631,7 +1631,9 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
 	struct ieee80211_radiotap_header *prthdr =
 		(struct ieee80211_radiotap_header *)skb->data;
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+	struct ieee80211_hdr *hdr;
 	u16 len_rthdr;
+	u8 *payload;
 
 	/*
 	 * Frame injection is not allowed if beaconing is not allowed
@@ -1682,6 +1684,24 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
 	skb_set_network_header(skb, len_rthdr);
 	skb_set_transport_header(skb, len_rthdr);
 
+	/*
+	 * Initialize skb->protocol if the injected frame is a data frame
+	 * carrying a rfc1042 header
+	 */
+	if (skb->len > len_rthdr + 2) {
+		hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr);
+		if (ieee80211_is_data(hdr->frame_control) &&
+		    skb->len >= len_rthdr +
+				ieee80211_hdrlen(hdr->frame_control) +
+				sizeof(rfc1042_header) + 2) {
+			payload = (u8 *)hdr +
+				  ieee80211_hdrlen(hdr->frame_control);
+			if (compare_ether_addr(payload, rfc1042_header) == 0)
+				skb->protocol = ntohs((payload[6] << 8) |
+						       payload[7]);
+		}
+	}
+
 	memset(info, 0, sizeof(*info));
 
 	info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 2/2 mac80211: Always send EAPOL frames at lowest rate

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

---
 net/mac80211/rate.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
net/mac80211/rate.c +9 -1
index 3d5a2cb..c307b7b 100644
@@ -199,6 +199,13 @@ static void rate_control_release(struct kref *kref)
 	kfree(ctrl_ref);
 }
 
+static bool rc_is_port_control(struct ieee80211_sta *pubsta,
+			       struct ieee80211_tx_rate_control *txrc)
+{
+	struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
+	return sta->sdata->control_port_protocol == txrc->skb->protocol;
+}
+
 static bool rc_no_data_or_no_ack(struct ieee80211_tx_rate_control *txrc)
 {
 	struct sk_buff *skb = txrc->skb;
@@ -241,7 +248,8 @@ bool rate_control_send_low(struct ieee80211_sta *sta,
 	struct ieee80211_supported_band *sband = txrc->sband;
 	int mcast_rate;
 
-	if (!sta || !priv_sta || rc_no_data_or_no_ack(txrc)) {
+	if (!sta || !priv_sta || rc_no_data_or_no_ack(txrc) ||
+	    rc_is_port_control(sta, txrc)) {
 		info->control.rates[0].idx = rate_lowest_index(txrc->sband, sta);
 		info->control.rates[0].count =
 			(info->flags & IEEE80211_TX_CTL_NO_ACK) ?
Signature · 1 line
1.7.3.4
#2 lore raw

Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

Quoted 8 lines · Helmut Schaa

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

Have you tried preventing minstrel_ht from using EAPOL frames for probing different rates instead of forcing it to use the lowest rate?

- Felix

#3 lore raw

Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

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

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

Quoted 5 lines
Quoted 2 lines

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

Have you tried preventing minstrel_ht from using EAPOL frames for probing different rates instead of forcing it to use the lowest rate?

Nope. I'll give it a try soon.

Thanks,
Helmut

#4 lore raw

Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

Quoted 9 lines · Helmut Schaa
Quoted 8 lines · Felix Fietkau
Quoted 7 lines · Helmut Schaa

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

Have you tried preventing minstrel_ht from using EAPOL frames for probing different rates instead of forcing it to use the lowest rate?

Nope. I'll give it a try soon.

Felix, what rate is used by minstrel_ht if there are no statistics yet? MCS0?

#5 lore raw

Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

Quoted 14 lines · Helmut Schaa
Quoted 12 lines · Helmut Schaa
Quoted 11 lines · Felix Fietkau
Quoted 9 lines · Helmut Schaa

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Have you tried preventing minstrel_ht from using EAPOL frames for probing different rates instead of forcing it to use the lowest rate?

Nope. I'll give it a try soon.

Felix, what rate is used by minstrel_ht if there are no statistics yet? MCS0?

Yes, rates default to lowest until better ones are available.

- Felix

#6 lore raw

Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

Quoted 23 lines · Felix Fietkau
Quoted 22 lines · Helmut Schaa
Quoted 19 lines · Helmut Schaa
Quoted 16 lines · Felix Fietkau
Quoted 10 lines · Helmut Schaa

 Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for
 example) for the 4-way handshake and under low signal conditions the handshake may time out.

 To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

 Have you tried preventing minstrel_ht from using EAPOL frames for probing
 different rates instead of forcing it to use the lowest rate?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

 Nope. I'll give it a try soon.

Felix, what rate is used by minstrel_ht if there are no statistics yet? MCS0?

Yes, rates default to lowest until better ones are available.

Ok, I'll try if forbidding rate probing for EAPOL frames in minstrel_ht solves this problem.

#7 lore raw

Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

In reply to Helmut Schaa
Quoted 8 lines · Helmut Schaa

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

I don't think that this should be applied for the reasons given (and alternative mechanisms proposed) in the discussion.

Signature · 1 line
Jouni Malinen                                            PGP id EFC895FA
#8 lore raw

Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

Quoted 7 lines · Jouni Malinen
Quoted 6 lines · Helmut Schaa

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

Quoted 5 lines
Quoted 2 lines

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

I don't think that this should be applied for the reasons given (and alternative mechanisms proposed) in the discussion.

I tested it with AP (rt2860) (with STA rt3572sta) under load and couldn't see any improvement. The first PTK-rekeying didn't work as usual. Or should it be applied to STA?

Andreas

#9 lore raw

Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

Quoted 11 lines · On Saturday 30 July 2011 22:03:34 Andreas Hartmann wrote:
Quoted 10 lines · Jouni Malinen
Quoted 8 lines · Helmut Schaa

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

Quoted 6 lines
Quoted 2 lines

I don't think that this should be applied for the reasons given (and alternative mechanisms proposed) in the discussion.

I tested it with AP (rt2860) (with STA rt3572sta) under load and couldn't see any improvement. The first PTK-rekeying didn't work as usual. Or should it be applied to STA?

might be a shot into the dark. But who's assigning a proper frame sequence to each eapol? Hostapd certainly can't because it doesn't know what's the current sequence at the moment... and mac80211 won't assign one because the frame is injected by a monitor interface. So when the receiver gets the EAPOL it might drops it because the empty sequence might be not in the BA window anymore. Does this sound reasonable, or did I miss something?

Regards,
Chr

#10 lore raw

Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

Quoted 19 lines · Christian Lamparter
Quoted 11 lines · On Saturday 30 July 2011 22:03:34 Andreas Hartmann wrote:
Quoted 10 lines · Jouni Malinen
Quoted 8 lines · Helmut Schaa

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

Quoted 6 lines
Quoted 2 lines

I don't think that this should be applied for the reasons given (and alternative mechanisms proposed) in the discussion.

I tested it with AP (rt2860) (with STA rt3572sta) under load and couldn't see any improvement. The first PTK-rekeying didn't work as usual. Or should it be applied to STA?

Quoted 6 lines

might be a shot into the dark. But who's assigning a proper frame sequence to each eapol? Hostapd certainly can't because it doesn't know what's the current sequence at the moment... and mac80211 won't assign one because the frame is injected by a monitor interface. So when the receiver gets the EAPOL it might drops it because the empty sequence might be not in the BA window anymore. Does this sound reasonable, or did I miss something?

Meanwhile I tested with the patch on both sides, AP (rt2800pci / rt2860) and STA (ath9k / ar9582) and compat-wireless-2011-07-28. The result is unchanged the same: the first ptk rekeying (4 way handshake) just didn't work.

Another thing: I don't think, that the wireless modules are the reason of the problem. If I'm using the following test setup, I get no problem at all:

AP: (rt2800pci / rt2860 - without patch)
STA: (rt3572 / rt3572sta - used without wpa_supplicant, but just rt3572sta stack - rt3572sta ships with an own WPA2-PSK-stack)

-> Why is it working without any problems, if wpa_supplicant isn't used at all?

Andreas

#11 lore raw

Re: Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

In reply to Andreas Hartmann

Am Samstag, 30. Juli 2011, 22:03:34 schrieb Andreas Hartmann:

Quoted 8 lines
Quoted 7 lines · Jouni Malinen
Quoted 6 lines · Helmut Schaa

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

I don't think that this should be applied for the reasons given (and alternative mechanisms proposed) in the discussion.

I tested it with AP (rt2860) (with STA rt3572sta) under load and couldn't see any improvement.

Because the patch never intended to tackle the problem you've reported :)

However, I've got some reports of clients timing out during the 4-way handshake if they are "far" away from the AP while auth and assoc work just fine.

Helmut

#12 lore raw

Re: Re: [PATCH 2/2] mac80211: Always send EAPOL frames at lowest rate

In reply to Jouni Malinen

Am Samstag, 30. Juli 2011, 21:28:10 schrieb Jouni Malinen:

Quoted 7 lines · Helmut Schaa
Quoted 6 lines

Since EAPOL frames are normal data frames they are treated by the rate control algorithm as such. Thus it can happen that the rate control algorithm chooses an inappropriate rate (minstrel_ht uses MCS rates for example) for the 4-way handshake and under low signal conditions the handshake may time out.

Quoted 5 lines
Quoted 2 lines

To fix this issue always treat EAPOL frames the same as management frames and send them with the lowest available rate.

I don't think that this should be applied for the reasons given (and alternative mechanisms proposed) in the discussion.

Agreed, I'll do some more tests with Felix suggestion to prevent minstrel_ht from rate sampling on EAPOL frames.

John, please drop this one.

Thanks,
Helmut