Skip to contentSkip to conversation

nl80211: don't require netdev UP for wdev

RFC In review Thomas Pedersen 3 participants 10 messages Apr 26, 2012 – May 10, 2012 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

RFC 1/1 nl80211: don't require netdev UP for wdev

It seems as long as we have a netdev, a wdev is available as well. Remove the restriction that netdev must be up before a wdev can be obtained in nl80211, or changing channels in cfg80211.

---
Hi list,

This was encountered while implementing an interface for setting BSSBasicRateSet in mesh. The wdev->channel is needed in nl80211.c for rate verification, but prior to this patch not available. This doesn't seem right since the following sequence of commands would fail:

iw wlan0 set type mp
iw wlan0 set channel n
ip link set wlan0 up
iw wlan0 mesh join meshid basic-rate 1,2

Also, 'iw set channel' is met with an -EBUSY if doing this after the link is up for fixed channel modes (mesh) anyway.

Comments? Any idea why this was required initially?

Thanks,
Thomas

 net/wireless/chan.c    |    6 +-----
 net/wireless/nl80211.c |    3 +--
 2 files changed, 2 insertions(+), 7 deletions(-)
net/wireless/chan.c +1 -5
index 2fcfe09..2ae6019 100644
@@ -88,13 +88,9 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
 	if (wdev && wdev->iftype == NL80211_IFTYPE_MONITOR)
 		wdev = NULL;
 
-	if (wdev) {
+	if (wdev)
 		ASSERT_WDEV_LOCK(wdev);
 
-		if (!netif_running(wdev->netdev))
-			return -ENETDOWN;
-	}
-
 	if (!rdev->ops->set_channel)
 		return -EOPNOTSUPP;
 
net/wireless/nl80211.c +1 -2
index 140c1d2..29e5703 100644
@@ -1257,8 +1257,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 		result = 0;
 
 		mutex_lock(&rdev->mtx);
-	} else if (netif_running(netdev) &&
-		   nl80211_can_set_dev_channel(netdev->ieee80211_ptr))
+	} else if (nl80211_can_set_dev_channel(netdev->ieee80211_ptr))
 		wdev = netdev->ieee80211_ptr;
 	else
 		wdev = NULL;
Signature · 1 line
1.7.5.4
maintainer
#1 lore raw
Quoted 19 lines · Thomas Pedersen

It seems as long as we have a netdev, a wdev is available as well. Remove the restriction that netdev must be up before a wdev can be obtained in nl80211, or changing channels in cfg80211.

---
Hi list,

This was encountered while implementing an interface for setting BSSBasicRateSet in mesh. The wdev->channel is needed in nl80211.c for rate verification, but prior to this patch not available. This doesn't seem right since the following sequence of commands would fail:

iw wlan0 set type mp
iw wlan0 set channel n
ip link set wlan0 up
iw wlan0 mesh join meshid basic-rate 1,2

Quoted 4 lines

Also, 'iw set channel' is met with an -EBUSY if doing this after the link is up for fixed channel modes (mesh) anyway.

Comments? Any idea why this was required initially?

I don't think this patch is correct -- mac80211 will get updated even if the device isn't even started which will likely cause trouble. Even if not though, this all doesn't match any kind of multi-channel concept. We treat the channel as part of the temporary setup, e.g. part of the association. AP and mesh are the only ones that are different today I think.

Overall, I don't think setting the channel & doing mesh setup separately is really a good API.

Quoted 1 line

From mac80211's (and other drivers if they existed) POV the channel

should be given with the mesh_join command, like for IBSS.

Now, obviously, requiring userspace to do that would be an API change. We probably don't want that, so I would suggest to change cfg80211 to track the channel and then pass it to join_mesh as one of the mesh parameters. This could be made work even when somebody attempts to set the channel before the interface is up, but we'd have to be careful about interface type changes.

We should do the same for AP mode as well, since the channel really becomes relevant only upon start_ap(), before that there's no real concept of a channel since you don't use it yet anyway.

johannes

#2 lore raw
Quoted 12 lines · Johannes Berg
Quoted 9 lines · Thomas Pedersen

iw wlan0 set type mp
iw wlan0 set channel n
ip link set wlan0 up
iw wlan0 mesh join meshid basic-rate 1,2

Also, 'iw set channel' is met with an -EBUSY if doing this after the link is up for fixed channel modes (mesh) anyway.

Comments? Any idea why this was required initially?

Quoted 6 lines

I don't think this patch is correct -- mac80211 will get updated even if the device isn't even started which will likely cause trouble. Even if not though, this all doesn't match any kind of multi-channel concept. We treat the channel as part of the temporary setup, e.g. part of the association. AP and mesh are the only ones that are different today I think.

What about monitor mode?

Quoted 13 lines

Overall, I don't think setting the channel& doing mesh setup separately is really a good API.

From mac80211's (and other drivers if they existed) POV the channel
should be given with the mesh_join command, like for IBSS.

Now, obviously, requiring userspace to do that would be an API change. We probably don't want that, so I would suggest to change cfg80211 to track the channel and then pass it to join_mesh as one of the mesh parameters. This could be made work even when somebody attempts to set the channel before the interface is up, but we'd have to be careful about interface type changes.

Quoted 3 lines

We should do the same for AP mode as well, since the channel really becomes relevant only upon start_ap(), before that there's no real concept of a channel since you don't use it yet anyway.

Maybe we should do the same with monitor interface type, i.e. introduce start_monitor() and have it pass the channel.

But then I'm thinking we shouldn't really be changing interface types explicitly, since they would be set implicitly by start_ap() and such. We could then use the NL80211_IFTYPE_UNSPECIFIED when we're not associated.

Signature · 1 line
Pozdrawiam / Best regards, Michal Kazior.
maintainer
#3 lore raw
Quoted 10 lines · Michal Kazior
Quoted 6 lines · Johannes Berg

I don't think this patch is correct -- mac80211 will get updated even if the device isn't even started which will likely cause trouble. Even if not though, this all doesn't match any kind of multi-channel concept. We treat the channel as part of the temporary setup, e.g. part of the association. AP and mesh are the only ones that are different today I think.

What about monitor mode?

It's ... special and confusing, unfortunately.
Basically, it's handled in mac80211 today, it rejects monitor channel setting unless it's otherwise idle, and overrides it freely if other requests come in.

Quoted 6 lines
Quoted 3 lines

We should do the same for AP mode as well, since the channel really becomes relevant only upon start_ap(), before that there's no real concept of a channel since you don't use it yet anyway.

Maybe we should do the same with monitor interface type, i.e. introduce start_monitor() and have it pass the channel.

No, that's the special case that doesn't work that way -- monitor mode interfaces are also great for debugging when they're just concurrently running with other interfaces and don't have their own channel setting.

Quoted 5 lines

But then I'm thinking we shouldn't really be changing interface types explicitly, since they would be set implicitly by start_ap() and such. We could then use the NL80211_IFTYPE_UNSPECIFIED when we're not associated.

From some point of view, it should work that way, yes.

Given how entrenched interface types are we definitely can't get rid of them though, and they're still needed to do concurrency management etc. But changing everything to have explicit start/stop operations makes on-the-fly interface type changes much easier.

johannes

#4 lore raw
Quoted 10 lines · Johannes Berg
Quoted 6 lines
Quoted 3 lines

We should do the same for AP mode as well, since the channel really becomes relevant only upon start_ap(), before that there's no real concept of a channel since you don't use it yet anyway.

Maybe we should do the same with monitor interface type, i.e. introduce start_monitor() and have it pass the channel.

No, that's the special case that doesn't work that way -- monitor mode interfaces are also great for debugging when they're just concurrently running with other interfaces and don't have their own channel setting.

We can make monitor interface to be a slave to other non-monitor interface by passing an extra parameter in start_monitor(). We could then have such a monitor interface follow channel changes of a given non-monitor interface (or rather it wouldn't be using a channel on it's own).

Quoted 8 lines
Quoted 3 lines

But then I'm thinking we shouldn't really be changing interface types explicitly, since they would be set implicitly by start_ap() and such. We could then use the NL80211_IFTYPE_UNSPECIFIED when we're not associated.

From some point of view, it should work that way, yes.

Given how entrenched interface types are we definitely can't get rid of them though, and they're still needed to do concurrency management etc.

Well, I don't think we can get completely rid of them, too. Or do you mean something else?

Signature · 1 line
Pozdrawiam / Best regards, Michal Kazior.
maintainer
#5 lore raw
Quoted 9 lines · Michal Kazior
Quoted 3 lines

No, that's the special case that doesn't work that way -- monitor mode interfaces are also great for debugging when they're just concurrently running with other interfaces and don't have their own channel setting.

We can make monitor interface to be a slave to other non-monitor interface by passing an extra parameter in start_monitor(). We could then have such a monitor interface follow channel changes of a given non-monitor interface (or rather it wouldn't be using a channel on it's own).

That's not how it works though, a monitor interface will simply report all frames mac80211 receives, globally.

Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

But then I'm thinking we shouldn't really be changing interface types explicitly, since they would be set implicitly by start_ap() and such. We could then use the NL80211_IFTYPE_UNSPECIFIED when we're not associated.

From some point of view, it should work that way, yes.

Given how entrenched interface types are we definitely can't get rid of them though, and they're still needed to do concurrency management etc.

Well, I don't think we can get completely rid of them, too. Or do you mean something else?

We can't even implicitly change them due to concurrency management etc.

johannes

#6 lore raw
In reply to Johannes Berg

Hi Johannes,

Thanks for reviewing.

Quoted 39 lines · Johannes Berg
Quoted 19 lines · Thomas Pedersen

It seems as long as we have a netdev, a wdev is available as well. Remove the restriction that netdev must be up before a wdev can be obtained in nl80211, or changing channels in cfg80211.

---
Hi list,

This was encountered while implementing an interface for setting BSSBasicRateSet in mesh. The wdev->channel is needed in nl80211.c for rate verification, but prior to this patch not available.  This doesn't seem right since the following sequence of commands would fail:

iw wlan0 set type mp
iw wlan0 set channel n
ip link set wlan0 up
iw wlan0 mesh join meshid basic-rate 1,2

Quoted 4 lines

Also, 'iw set channel' is met with an -EBUSY if doing this after the link is up for fixed channel modes (mesh) anyway.

Comments? Any idea why this was required initially?

I don't think this patch is correct -- mac80211 will get updated even if the device isn't even started which will likely cause trouble. Even if not though, this all doesn't match any kind of multi-channel concept. We treat the channel as part of the temporary setup, e.g. part of the association. AP and mesh are the only ones that are different today I think.

Overall, I don't think setting the channel & doing mesh setup separately is really a good API.

From mac80211's (and other drivers if they existed) POV the channel should be given with the mesh_join command, like for IBSS.

Quoted 6 lines

Now, obviously, requiring userspace to do that would be an API change. We probably don't want that, so I would suggest to change cfg80211 to track the channel and then pass it to join_mesh as one of the mesh parameters. This could be made work even when somebody attempts to set the channel before the interface is up, but we'd have to be careful about interface type changes.

Unfortunately, when __nl80211_set_channel() is called we may or may not have a wdev, so there is nowhere to store the interface-specific channel and type.
We could shove these into a cfg80211_registered_device, but now just "last channel for this wiphy" is tracked, and that doesn't seem to help your multi-channel operation.

If the above is correct, how about we leave the existing API as-is and simply extend join_mesh to take a channel attribute?

Also, with IBSS the desired channel is pushed to the driver along with the setup parameters. What do you think about calling __nl80211_set_channel() directly instead of relying on the cfg80211 driver to handle this?

Quoted 3 lines

We should do the same for AP mode as well, since the channel really becomes relevant only upon start_ap(), before that there's no real concept of a channel since you don't use it yet anyway.

Thanks,
Thomas

maintainer
#7 lore raw

Hi Thomas,

Quoted 20 lines
Quoted 13 lines

I don't think this patch is correct -- mac80211 will get updated even if the device isn't even started which will likely cause trouble. Even if not though, this all doesn't match any kind of multi-channel concept. We treat the channel as part of the temporary setup, e.g. part of the association. AP and mesh are the only ones that are different today I think.

Overall, I don't think setting the channel & doing mesh setup separately is really a good API.

From mac80211's (and other drivers if they existed) POV the channel should be given with the mesh_join command, like for IBSS.

Quoted 6 lines

Now, obviously, requiring userspace to do that would be an API change. We probably don't want that, so I would suggest to change cfg80211 to track the channel and then pass it to join_mesh as one of the mesh parameters. This could be made work even when somebody attempts to set the channel before the interface is up, but we'd have to be careful about interface type changes.

Quoted 3 lines

Unfortunately, when __nl80211_set_channel() is called we may or may not have a wdev, so there is nowhere to store the interface-specific channel and type.

Well, but if you don't have a wdev, is the setting relevant at all? Or does it take effect later? This all isn't very well-defined I guess.

Quoted 3 lines

We could shove these into a cfg80211_registered_device, but now just "last channel for this wiphy" is tracked, and that doesn't seem to help your multi-channel operation.

So you'd want to allow setting the channel on the phy, and have it take effect for mesh? Is that really something we need to support? I'd think almost everyone would set the channel on the netdev?

Quoted 2 lines

If the above is correct, how about we leave the existing API as-is and simply extend join_mesh to take a channel attribute?

We could, but that'd mean that it can be NULL if the user doesn't set it, which seems a bit odd to me too and then the driver again would have to sort it out. I'd prefer if we could sort it out in cfg80211 so the driver (mac80211) is simpler.

Quoted 4 lines

Also, with IBSS the desired channel is pushed to the driver along with the setup parameters. What do you think about calling __nl80211_set_channel() directly instead of relying on the cfg80211 driver to handle this?

No, that's certainly not possible. In IBSS the channel is just the default channel if we don't find an IBSS. And in any case I'd rather call set_channel less than more.

johannes

#8 lore raw
Quoted 30 lines · Johannes Berg

Hi Thomas,

Quoted 20 lines
Quoted 13 lines

I don't think this patch is correct -- mac80211 will get updated even if the device isn't even started which will likely cause trouble. Even if not though, this all doesn't match any kind of multi-channel concept. We treat the channel as part of the temporary setup, e.g. part of the association. AP and mesh are the only ones that are different today I think.

Overall, I don't think setting the channel & doing mesh setup separately is really a good API.

From mac80211's (and other drivers if they existed) POV the channel should be given with the mesh_join command, like for IBSS.

Quoted 6 lines

Now, obviously, requiring userspace to do that would be an API change. We probably don't want that, so I would suggest to change cfg80211 to track the channel and then pass it to join_mesh as one of the mesh parameters. This could be made work even when somebody attempts to set the channel before the interface is up, but we'd have to be careful about interface type changes.

Quoted 3 lines

Unfortunately, when __nl80211_set_channel() is called we may or may not have a wdev, so there is nowhere to store the interface-specific channel and type.

Well, but if you don't have a wdev, is the setting relevant at all? Or does it take effect later? This all isn't very well-defined I guess.

Quoted 7 lines
Quoted 3 lines

We could shove these into a cfg80211_registered_device, but now just "last channel for this wiphy" is tracked, and that doesn't seem to help your multi-channel operation.

So you'd want to allow setting the channel on the phy, and have it take effect for mesh? Is that really something we need to support? I'd think almost everyone would set the channel on the netdev?

No :) Thanks for clearing that up.

Quoted 7 lines
Quoted 2 lines

If the above is correct, how about we leave the existing API as-is and simply extend join_mesh to take a channel attribute?

We could, but that'd mean that it can be NULL if the user doesn't set it, which seems a bit odd to me too and then the driver again would have to sort it out. I'd prefer if we could sort it out in cfg80211 so the driver (mac80211) is simpler.

For this, we can store a default channel and type in the default mesh config.

Quoted 8 lines
Quoted 4 lines

Also, with IBSS the desired channel is pushed to the driver along with the setup parameters. What do you think about calling __nl80211_set_channel() directly instead of relying on the cfg80211 driver to handle this?

No, that's certainly not possible. In IBSS the channel is just the default channel if we don't find an IBSS. And in any case I'd rather call set_channel less than more.

So cfg80211_set_freq() from cfg80211_join_mesh() is out, too?

maintainer
#9 lore raw
Quoted 6 lines · Thomas Pedersen
Quoted 4 lines

We could, but that'd mean that it can be NULL if the user doesn't set it, which seems a bit odd to me too and then the driver again would have to sort it out. I'd prefer if we could sort it out in cfg80211 so the driver (mac80211) is simpler.

For this, we can store a default channel and type in the default mesh config.

That would still break older userspace though, it would get the default channel instead of the channel it set before, right?

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

Also, with IBSS the desired channel is pushed to the driver along with the setup parameters. What do you think about calling __nl80211_set_channel() directly instead of relying on the cfg80211 driver to handle this?

No, that's certainly not possible. In IBSS the channel is just the default channel if we don't find an IBSS. And in any case I'd rather call set_channel less than more.

So cfg80211_set_freq() from cfg80211_join_mesh() is out, too?

I think we should just pass the channel to the join_mesh callback.

I just did this a bit for AP mode. Now, in AP mode we have one
advantage: we can rely on userspace setting the channel because hostapd/wpa_s always does that. For mesh, we may not have that luxury?

For AP, it looks roughly like this:
http://p.sipsolutions.net/35913f571ea5bd43.txt

Maybe we can do something similar for mesh and mostly get rid of setting the channel directly.

johannes