Skip to contentSkip to conversation

mac80211: fix legacy and invalid rx-rate rpt

PATCH Applied [email protected] 2 participants 2 messages Dec 14, 2016 – Dec 15, 2016 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mac80211: fix legacy and invalid rx-rate rpt

From: Ben Greear <[email protected]>

This fixes obtaining the rate info via sta_set_sinfo when the rx rate is invalid (for instance, on IBSS interface that has received no frames from one of its peers).

This also fixes a more general issue with rinfo->flags not being properly initialized for legacy rates.

---

Patch is against 4.7

 net/mac80211/sta_info.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
net/mac80211/sta_info.c +9 -7
index 01868f9..6d27813e 100644
@@ -2057,6 +2057,7 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u16 rate,
 		u16 brate;
 		unsigned int shift;
 
+		rinfo->flags = 0;
 		sband = local->hw.wiphy->bands[(rate >> 4) & 0xf];
 		brate = sband->bitrates[rate & 0xf].bitrate;
 		if (rinfo->bw == RATE_INFO_BW_5)
@@ -2072,14 +2073,15 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u16 rate,
 		rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
 }
 
-static void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
+static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
 {
 	u16 rate = ACCESS_ONCE(sta_get_last_rx_stats(sta)->last_rate);
-
-	if (rate == STA_STATS_RATE_INVALID)
-		rinfo->flags = 0;
-	else
+	if (rate == STA_STATS_RATE_INVALID) {
+		return -EINVAL;
+	} else {
 		sta_stats_decode_rate(sta->local, rate, rinfo);
+		return 0;
+	}
 }
 
 static void sta_set_tidstats(struct sta_info *sta,
@@ -2284,8 +2286,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
 	}
 
 	if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE))) {
-		sta_set_rate_info_rx(sta, &sinfo->rxrate);
-		sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE);
+		if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0)
+			sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE);
 	}
 
 	sinfo->filled |= BIT(NL80211_STA_INFO_TID_STATS);
Signature · 1 line
2.4.11
maintainer Applied
#1 lore raw
Quoted 9 lines · On Wed, 2016-12-14 at 11:30 -0800, [email protected] wrote:

From: Ben Greear <[email protected]>

This fixes obtaining the rate info via sta_set_sinfo when the rx rate is invalid (for instance, on IBSS interface that has received no frames from one of its peers).

This also fixes a more general issue with rinfo->flags not being properly initialized for legacy rates.

I'd say this is a bug in the ethtool code - everything assumes (and everything else makes sure) the whole sinfo struct is initialized to 0 before getting passed to this function.

Quoted 13 lines

+static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
 {
  u16 rate = ACCESS_ONCE(sta_get_last_rx_stats(sta)-

Quoted 1 line

last_rate);

net/mac80211/sta_info.c +3 -4
-
-	if (rate == STA_STATS_RATE_INVALID)
-		rinfo->flags = 0;
-	else
+	if (rate == STA_STATS_RATE_INVALID) {
+		return -EINVAL;
+	} else {

  sta_stats_decode_rate(sta->local, rate, rinfo);

net/mac80211/sta_info.c static void sta_stats_decode_rate(struct ieee80211_local *local, u16 rate, · line 2084

Quoted 2 lines
net/mac80211/sta_info.c +2 -0
+		return 0;
+	}

That's weird, I'll fix it.

Applied, with some fixupse.

johannes