Skip to contentSkip to conversation

iw: Fix bitrate output when no rate info found

PATCH Superseded Masashi Honma 2 participants 8 messages Feb 14, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iw: Fix bitrate output when no rate info found

Previously, bitrate showed uninitialized buffer when no rate info found. This patch fixes the issue.

---
 station.c | 4 ++++
 1 file changed, 4 insertions(+)
station.c +4 -0
index f3e3da8..9d3eb4d 100644
@@ -151,6 +151,10 @@ void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen)
 	if (rate > 0)
 		pos += snprintf(pos, buflen - (pos - buf),
 				"%d.%d MBit/s", rate / 10, rate % 10);
+	else {
+		snprintf(buf, buflen, "No rate info found!");
+		return;
+	}
 
 	if (rinfo[NL80211_RATE_INFO_MCS])
 		pos += snprintf(pos, buflen - (pos - buf),
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Masashi Honma

Previously, bitrate showed uninitialized buffer when no rate info found. This patch fixes the issue.

This is the screen shot.

Masashi Honma.

#2 lore raw
In reply to Masashi Honma
Quoted 2 lines · Masashi Honma

Previously, bitrate showed uninitialized buffer when no rate info found.

When would this happen?

I'm not really sure this is right - perhaps we don't have RATE_INFO_BITRATE(32), but still have the MCS data?

How about we just add "(unknown)" or so and not return here?

johannes

#3 lore raw
Quoted 5 lines · Johannes Berg
Quoted 2 lines · Masashi Honma

Previously, bitrate showed uninitialized buffer when no rate info found.

When would this happen?

I could see in mesh STA connection with 11n and legacy mixed. STA A has disable_ht=1.
STA B has disable_ht=0.

Quoted 2 lines

I'm not really sure this is right - perhaps we don't have RATE_INFO_BITRATE(32), but still have the MCS data?

I recognized there was a issue on such a case. I will send a patch to wpa_supplicant. Anyway, showing string message is better than showing raw binary data.

Quoted 1 line

How about we just add "(unknown)" or so and not return here?

Yes. First time, I supposed to use "unknown". But in the function parse_bitrate(), nla_parse_nested() returns message "failed to parse nested rate attributes!". This explains why the bitrate is unknown. So I used explaining message. We could see the message like this.

tx bitrate: No rate info found!
rx bitrate: 48.0 MBit/s

Masashi Honma.

#4 lore raw
Quoted 10 lines · Masashi Honma
Quoted 5 lines · Johannes Berg
Quoted 2 lines · Masashi Honma

Previously, bitrate showed uninitialized buffer when no rate info found.

When would this happen?

I could see in mesh STA connection with 11n and legacy mixed. STA A has disable_ht=1.
STA B has disable_ht=0.

Interesting, ok.

Quoted 10 lines

 > I'm not really sure this is right - perhaps we don't have > RATE_INFO_BITRATE(32), but still have the MCS data?

I recognized there was a issue on such a case. I will send a patch to wpa_supplicant. Anyway, showing string message is better than showing raw binary data.

Quoted 1 line

How about we just add "(unknown)" or so and not return here?

Yes. First time, I supposed to use "unknown".

Ok.

Quoted 3 lines

But in the function
parse_bitrate(), nla_parse_nested() returns message "failed to parse nested rate attributes!". This explains why the bitrate is unknown.

Yes, this is bad! But if you saw that, why did you ever get to the below code that checked for the BITRATE(32) attributes?

Quoted 4 lines

So I used explaining message. We could see the message like this.

tx bitrate: No rate info found!
rx bitrate: 48.0 MBit/s

Yeah I was just thinking we could also see

tx bitrate: (unknown)

and then if there was MCS anyway you'd see

tx bitrate: (unknown) MCS 7

or something like that?

johannes

#5 lore raw
Quoted 10 lines · Johannes Berg

Yes, this is bad! But if you saw that, why did you ever get to the below code that checked for the BITRATE(32) attributes?

Quoted 4 lines

So I used explaining message. We could see the message like this.

tx bitrate: No rate info found!
rx bitrate: 48.0 MBit/s

Yeah I was just thinking we could also see

Quoted 7 lines

tx bitrate: (unknown)

and then if there was MCS anyway you'd see

tx bitrate: (unknown) MCS 7

or something like that?

Yes, showing information as far as possible looks good.

I will modify this patch.

Masashi Honma.

#6 lore raw

PATCH v2 1/1 iw: Fix bitrate output when no rate info found

In reply to Masashi Honma

Previously, bitrate showed uninitialized buffer when no rate info found. This patch fixes the issue.

---
 station.c | 2 ++
 1 file changed, 2 insertions(+)
station.c +2 -0
index f3e3da8..4885dc0 100644
@@ -151,6 +151,8 @@ void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen)
 	if (rate > 0)
 		pos += snprintf(pos, buflen - (pos - buf),
 				"%d.%d MBit/s", rate / 10, rate % 10);
+	else
+		pos += snprintf(pos, buflen - (pos - buf), "(unknown)");
 
 	if (rinfo[NL80211_RATE_INFO_MCS])
 		pos += snprintf(pos, buflen - (pos - buf),
Signature · 1 line
2.7.4
#7 lore raw
Quoted 4 lines · Masashi Honma

Previously, bitrate showed uninitialized buffer when no rate info found.
This patch fixes the issue.

Applied, thanks.

johannes