Skip to contentSkip to conversation

nl80211: Don't touch split_start when split dump is not used

PATCH In review Pontus Fuchs 2 participants 4 messages Jan 16, 2014 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nl80211: Don't touch split_start when split dump is not used

When the netlink skb is exhausted split_start is left set. In the subsequent retry, with a larger buffer, the dump is continued from the failing point instead of from the beginning.

This was causing my rt28xx based USB dongle to now show up when running "iw list" with an old iw version without split dump support.

---
 net/wireless/nl80211.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)
net/wireless/nl80211.c +18 -12
index d0afd82..32745e9 100644
@@ -1184,6 +1184,12 @@ struct nl80211_dump_wiphy_state {
 	bool split;
 };
 
+static void split_start_inc(struct nl80211_dump_wiphy_state *state)
+{
+	if (state->split)
+		state->split_start++;
+}
+
 static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 			      struct sk_buff *msg, u32 portid, u32 seq,
 			      int flags, struct nl80211_dump_wiphy_state *state)
@@ -1255,7 +1261,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 		if ((dev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP) &&
 		    nla_put_flag(msg, NL80211_ATTR_TDLS_EXTERNAL_SETUP))
 			goto nla_put_failure;
-		state->split_start++;
+		split_start_inc(state);
 		if (state->split)
 			break;
 	case 1:
@@ -1300,14 +1306,14 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 			}
 		}
 
-		state->split_start++;
+		split_start_inc(state);
 		if (state->split)
 			break;
 	case 2:
 		if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES,
 					dev->wiphy.interface_modes))
 				goto nla_put_failure;
-		state->split_start++;
+		split_start_inc(state);
 		if (state->split)
 			break;
 	case 3:
@@ -1385,7 +1391,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 
 		/* if bands & channels are done, continue outside */
 		if (state->band_start == 0 && state->chan_start == 0)
-			state->split_start++;
+			split_start_inc(state);
 		if (state->split)
 			break;
 	case 4:
@@ -1479,7 +1485,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 		}
 
 		nla_nest_end(msg, nl_cmds);
-		state->split_start++;
+		split_start_inc(state);
 		if (state->split)
 			break;
 	case 5:
@@ -1496,18 +1502,18 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 
 		if (nl80211_send_mgmt_stypes(msg, mgmt_stypes))
 			goto nla_put_failure;
-		state->split_start++;
+		split_start_inc(state);
 		if (state->split)
 			break;
 	case 6:
 #ifdef CONFIG_PM
 		if (nl80211_send_wowlan(msg, dev, state->split))
 			goto nla_put_failure;
-		state->split_start++;
+		split_start_inc(state);
 		if (state->split)
 			break;
 #else
-		state->split_start++;
+		split_start_inc(state);
 #endif
 	case 7:
 		if (nl80211_put_iftypes(msg, NL80211_ATTR_SOFTWARE_IFTYPES,
@@ -1518,7 +1524,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 						   state->split))
 			goto nla_put_failure;
 
-		state->split_start++;
+		split_start_inc(state);
 		if (state->split)
 			break;
 	case 8:
@@ -1560,7 +1566,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 		 * case we'll continue with more data in the next round,
 		 * but break unconditionally so unsplit data stops here.
 		 */
-		state->split_start++;
+		split_start_inc(state);
 		break;
 	case 9:
 		if (dev->wiphy.extended_capabilities &&
@@ -1578,7 +1584,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 			    dev->wiphy.vht_capa_mod_mask))
 			goto nla_put_failure;
 
-		state->split_start++;
+		split_start_inc(state);
 		break;
 	case 10:
 		if (nl80211_send_coalesce(msg, dev))
@@ -1588,7 +1594,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
 		    (nla_put_flag(msg, NL80211_ATTR_SUPPORT_5_MHZ) ||
 		     nla_put_flag(msg, NL80211_ATTR_SUPPORT_10_MHZ)))
 			goto nla_put_failure;
-		state->split_start++;
+		split_start_inc(state);
 		break;
 	case 11:
 		if (dev->wiphy.n_vendor_commands) {
Signature · 1 line
1.8.3.2
maintainer
#1 lore raw

net/wireless/nl80211.c struct nl80211_dump_wiphy_state { · line 1191

Quoted 9 lines · Pontus Fuchs

When the netlink skb is exhausted split_start is left set. In the subsequent retry, with a larger buffer, the dump is continued from the failing point instead of from the beginning.

net/wireless/nl80211.c +5 -0
+static void split_start_inc(struct nl80211_dump_wiphy_state *state)
+{
+	if (state->split)
+		state->split_start++;
+}

Wouldn't it be easier to just reset it in this case?

johannes

#2 lore raw
Quoted 5 lines · Johannes Berg
Quoted 3 lines · Pontus Fuchs

When the netlink skb is exhausted split_start is left set. In the subsequent retry, with a larger buffer, the dump is continued from the failing point instead of from the beginning.

Quoted 7 lines

net/wireless/nl80211.c struct nl80211_dump_wiphy_state { · line 1191

Quoted 5 lines
net/wireless/nl80211.c +5 -0
+static void split_start_inc(struct nl80211_dump_wiphy_state *state)
+{
+	if (state->split)
+		state->split_start++;
+}

Wouldn't it be easier to just reset it in this case?

Sure. If you prefer that I can do that instead.

//Pontus

maintainer
#3 lore raw
Quoted 14 lines · Pontus Fuchs
Quoted 5 lines · Johannes Berg
Quoted 3 lines · Pontus Fuchs

When the netlink skb is exhausted split_start is left set. In the subsequent retry, with a larger buffer, the dump is continued from the failing point instead of from the beginning.

Quoted 7 lines

net/wireless/nl80211.c struct nl80211_dump_wiphy_state { · line 1191

Quoted 5 lines
net/wireless/nl80211.c +5 -0
+static void split_start_inc(struct nl80211_dump_wiphy_state *state)
+{
+	if (state->split)
+		state->split_start++;
+}

Wouldn't it be easier to just reset it in this case?

Quoted 1 line

Sure. If you prefer that I can do that instead.

Just thinking that it'd be smaller and easier for stable, since it should probably be tagged for there.

johannes