linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net-sysfs: Add entry for nl80211 interface type
@ 2013-04-17 22:06 Bing Zhao
  2013-04-17 22:09 ` Johannes Berg
  2013-04-17 22:54 ` Marcel Holtmann
  0 siblings, 2 replies; 12+ messages in thread
From: Bing Zhao @ 2013-04-17 22:06 UTC (permalink / raw)
  To: linux-netdev, linux-wireless, linux-kernel; +Cc: Paul Stewart, Bing Zhao

Add a "wireless/nl80211_iftype" entry in the net device sysfs
file structure to indicate the mode of the wireless device so
it can be discovered easily from userspace.

Signed-off-by: Paul Stewart <pstew@chromium.org>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
 net/core/net-sysfs.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 7427ab5..454bd7f 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -17,6 +17,7 @@
 #include <linux/nsproxy.h>
 #include <net/sock.h>
 #include <net/net_namespace.h>
+#include <net/cfg80211.h>
 #include <linux/rtnetlink.h>
 #include <linux/vmalloc.h>
 #include <linux/export.h>
@@ -448,7 +449,24 @@ static struct attribute_group netstat_group = {
 };
 
 #if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211)
+static ssize_t show_nl80211_iftype(struct device *dev,
+				   struct device_attribute *attr, char *buf)
+{
+	const struct net_device *netdev = to_net_dev(dev);
+	ssize_t ret = 0;
+
+	if (!rtnl_trylock())
+		return restart_syscall();
+	if (netdev->ieee80211_ptr)
+		ret = sprintf(buf, "%d\n", netdev->ieee80211_ptr->iftype);
+	rtnl_unlock();
+
+	return ret;
+}
+static DEVICE_ATTR(nl80211_iftype, S_IRUGO, show_nl80211_iftype, NULL);
+
 static struct attribute *wireless_attrs[] = {
+	&dev_attr_nl80211_iftype.attr,
 	NULL
 };
 
-- 
1.7.0.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-17 22:06 [PATCH] net-sysfs: Add entry for nl80211 interface type Bing Zhao
@ 2013-04-17 22:09 ` Johannes Berg
  2013-04-18  6:14   ` Nicolas Cavallari
       [not found]   ` <CAMcMvsjh4y=84hM+dCcFvb1xxSq5c3HqTBg6VyaCZkh5s=E5yA@mail.gmail.com>
  2013-04-17 22:54 ` Marcel Holtmann
  1 sibling, 2 replies; 12+ messages in thread
From: Johannes Berg @ 2013-04-17 22:09 UTC (permalink / raw)
  To: Bing Zhao; +Cc: linux-netdev, linux-wireless, linux-kernel, Paul Stewart

On Wed, 2013-04-17 at 15:06 -0700, Bing Zhao wrote:
> Add a "wireless/nl80211_iftype" entry in the net device sysfs
> file structure to indicate the mode of the wireless device so
> it can be discovered easily from userspace.

What's wrong with "iw dev", i.e. netlink/nl80211?

johannes


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-17 22:06 [PATCH] net-sysfs: Add entry for nl80211 interface type Bing Zhao
  2013-04-17 22:09 ` Johannes Berg
@ 2013-04-17 22:54 ` Marcel Holtmann
  2013-04-18 19:03   ` Bing Zhao
  1 sibling, 1 reply; 12+ messages in thread
From: Marcel Holtmann @ 2013-04-17 22:54 UTC (permalink / raw)
  To: Bing Zhao; +Cc: linux-netdev, linux-wireless, linux-kernel, Paul Stewart

Hi Bing,

> Add a "wireless/nl80211_iftype" entry in the net device sysfs
> file structure to indicate the mode of the wireless device so
> it can be discovered easily from userspace.

I do question a little bit the usefulness for this one. It would only work on netdev and on wdev devices. Using nl80211 to discover this information seems a lot better approach.

Regards

Marcel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-17 22:09 ` Johannes Berg
@ 2013-04-18  6:14   ` Nicolas Cavallari
  2013-04-18  6:43     ` Marcel Holtmann
       [not found]   ` <CAMcMvsjh4y=84hM+dCcFvb1xxSq5c3HqTBg6VyaCZkh5s=E5yA@mail.gmail.com>
  1 sibling, 1 reply; 12+ messages in thread
From: Nicolas Cavallari @ 2013-04-18  6:14 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Bing Zhao, linux-netdev, linux-wireless, linux-kernel,
	Paul Stewart

On 18/04/2013 00:09, Johannes Berg wrote:
> On Wed, 2013-04-17 at 15:06 -0700, Bing Zhao wrote:
>> Add a "wireless/nl80211_iftype" entry in the net device sysfs
>> file structure to indicate the mode of the wireless device so
>> it can be discovered easily from userspace.
> 
> What's wrong with "iw dev", i.e. netlink/nl80211?

"Do NOT screenscrape this tool, we don't consider its output stable."

So if you are in a shell script, you're basically screwed.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-18  6:14   ` Nicolas Cavallari
@ 2013-04-18  6:43     ` Marcel Holtmann
  2013-04-18  7:03       ` Paul Stewart
  0 siblings, 1 reply; 12+ messages in thread
From: Marcel Holtmann @ 2013-04-18  6:43 UTC (permalink / raw)
  To: Nicolas Cavallari
  Cc: Johannes Berg, Bing Zhao, linux-netdev, linux-wireless,
	linux-kernel, Paul Stewart

Hi Nicolas,

>>> Add a "wireless/nl80211_iftype" entry in the net device sysfs
>>> file structure to indicate the mode of the wireless device so
>>> it can be discovered easily from userspace.
>> 
>> What's wrong with "iw dev", i.e. netlink/nl80211?
> 
> "Do NOT screenscrape this tool, we don't consider its output stable."
> 
> So if you are in a shell script, you're basically screwed.

if you are in a shell script, you are screwed no matter what. So what is your point?

Regards

Marcel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-18  6:43     ` Marcel Holtmann
@ 2013-04-18  7:03       ` Paul Stewart
  2013-04-18 15:46         ` Marcel Holtmann
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Stewart @ 2013-04-18  7:03 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Nicolas Cavallari, Johannes Berg, Bing Zhao, linux-netdev,
	linux-wireless, LKML

The original reason to request this change was simple: to figure out
what type of interface we are looking at, since now some wireless
drivers can simultaneously create managed, p2p and ap interfaces.
Knowing that, from a simple front-end (let's even say a shell script)
we can decide what arguments to use with wpa_supplicant (or indeed if
we want to start it on this interface).  wpa_supplicant, of course,
knows how to manipulate the device further using nl80211.  I thought
it was a bit onerous to force userspace all the way through nl80211
just to get this trivial piece of information, but apparently this
doesn't seem to be the common point of view.

--
Paul

On Wed, Apr 17, 2013 at 11:43 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Nicolas,
>
>>>> Add a "wireless/nl80211_iftype" entry in the net device sysfs
>>>> file structure to indicate the mode of the wireless device so
>>>> it can be discovered easily from userspace.
>>>
>>> What's wrong with "iw dev", i.e. netlink/nl80211?
>>
>> "Do NOT screenscrape this tool, we don't consider its output stable."
>>
>> So if you are in a shell script, you're basically screwed.
>
> if you are in a shell script, you are screwed no matter what. So what is your point?
>
> Regards
>
> Marcel
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-18  7:03       ` Paul Stewart
@ 2013-04-18 15:46         ` Marcel Holtmann
  0 siblings, 0 replies; 12+ messages in thread
From: Marcel Holtmann @ 2013-04-18 15:46 UTC (permalink / raw)
  To: Paul Stewart
  Cc: Nicolas Cavallari, Johannes Berg, Bing Zhao, linux-netdev,
	linux-wireless, LKML

Hi Paul,

> The original reason to request this change was simple: to figure out
> what type of interface we are looking at, since now some wireless
> drivers can simultaneously create managed, p2p and ap interfaces.
> Knowing that, from a simple front-end (let's even say a shell script)
> we can decide what arguments to use with wpa_supplicant (or indeed if
> we want to start it on this interface).  wpa_supplicant, of course,
> knows how to manipulate the device further using nl80211.  I thought
> it was a bit onerous to force userspace all the way through nl80211
> just to get this trivial piece of information, but apparently this
> doesn't seem to be the common point of view.

quite frankly this is a design issue with wpa_supplicant since it refuses to manage the wireless devices and interfaces. If you would have a real daemon that manages the wireless device via nl80211, then you would never ever have this problem. All the information are available via nl80211.

However my point is that you can not just base this around netdev exposed interfaces. The netdev interface might not even be present. Especially when talking about P2P you might not have a netdev in the first place. You only have a wdev.

Regards

Marcel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-17 22:54 ` Marcel Holtmann
@ 2013-04-18 19:03   ` Bing Zhao
  2013-04-18 19:10     ` Marcel Holtmann
  0 siblings, 1 reply; 12+ messages in thread
From: Bing Zhao @ 2013-04-18 19:03 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: linux-netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org, Paul Stewart

Hi Marcel,

> Hi Bing,
> 
> > Add a "wireless/nl80211_iftype" entry in the net device sysfs
> > file structure to indicate the mode of the wireless device so
> > it can be discovered easily from userspace.
> 
> I do question a little bit the usefulness for this one.
> It would only work on netdev and on wdev devices.

It's true. That's why the new sysfs entry is added in the 'wireless' placeholder.

/sys/class/net/ethX/wireless/

For non-wireless dev, this won't apply.

Thanks,
Bing

> Using nl80211 to discover this information seems a lot better approach.
> 
> Regards
> 
> Marcel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-18 19:03   ` Bing Zhao
@ 2013-04-18 19:10     ` Marcel Holtmann
  2013-04-18 19:18       ` Arend van Spriel
  0 siblings, 1 reply; 12+ messages in thread
From: Marcel Holtmann @ 2013-04-18 19:10 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org, Paul Stewart

Hi Bing,

>>> Add a "wireless/nl80211_iftype" entry in the net device sysfs
>>> file structure to indicate the mode of the wireless device so
>>> it can be discovered easily from userspace.
>> 
>> I do question a little bit the usefulness for this one.
>> It would only work on netdev and on wdev devices.
> 
> It's true. That's why the new sysfs entry is added in the 'wireless' placeholder.
> 
> /sys/class/net/ethX/wireless/
> 
> For non-wireless dev, this won't apply.

I have to correct myself. I meant it does NOT work for wdev. Please just go with nl80211 for this kind of information. It is the right way to handle it. Not some sysfs file.

Regards

Marcel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-18 19:10     ` Marcel Holtmann
@ 2013-04-18 19:18       ` Arend van Spriel
  0 siblings, 0 replies; 12+ messages in thread
From: Arend van Spriel @ 2013-04-18 19:18 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Bing Zhao, linux-netdev@vger.kernel.org,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	Paul Stewart

On 04/18/2013 09:10 PM, Marcel Holtmann wrote:
> Hi Bing,
>
>>>> Add a "wireless/nl80211_iftype" entry in the net device sysfs
>>>> file structure to indicate the mode of the wireless device so
>>>> it can be discovered easily from userspace.
>>>
>>> I do question a little bit the usefulness for this one.
>>> It would only work on netdev and on wdev devices.
>>
>> It's true. That's why the new sysfs entry is added in the 'wireless' placeholder.
>>
>> /sys/class/net/ethX/wireless/
>>
>> For non-wireless dev, this won't apply.
>
> I have to correct myself. I meant it does NOT work for wdev. Please just go with nl80211 for this kind of information. It is the right way to handle it. Not some sysfs file.
>

I wanted to correct you on P2P but that would be diverging from the real 
message. Totally agreeing. Why add another user-space API when the 
nl80211 API can provide the information.

Gr. AvS



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
       [not found]   ` <CAMcMvsjh4y=84hM+dCcFvb1xxSq5c3HqTBg6VyaCZkh5s=E5yA@mail.gmail.com>
@ 2013-04-22 13:29     ` Johannes Berg
  2013-04-22 13:55       ` Paul Stewart
  0 siblings, 1 reply; 12+ messages in thread
From: Johannes Berg @ 2013-04-22 13:29 UTC (permalink / raw)
  To: Paul Stewart; +Cc: Bing Zhao, linux-netdev, linux-wireless, LKML

On Wed, 2013-04-17 at 15:14 -0700, Paul Stewart wrote:
> I believe the documents for "iw" state explicitly that we shouldn't
> screen-scrape it?

Well, you specifically control your system. I'd also be happy to add
some (maybe a bit hidden) commands to print out _just_ the (numeric)
type, to aid scripting? All I'm trying to say with that though is that
you shouldn't rely on specific output formatting, particularly not with
scan results and "iw list" etc.

johannes



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net-sysfs: Add entry for nl80211 interface type
  2013-04-22 13:29     ` Johannes Berg
@ 2013-04-22 13:55       ` Paul Stewart
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Stewart @ 2013-04-22 13:55 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Bing Zhao, linux-netdev, linux-wireless, LKML

On Mon, Apr 22, 2013 at 6:29 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
>
> On Wed, 2013-04-17 at 15:14 -0700, Paul Stewart wrote:
> > I believe the documents for "iw" state explicitly that we shouldn't
> > screen-scrape it?
>
> Well, you specifically control your system. I'd also be happy to add
> some (maybe a bit hidden) commands to print out _just_ the (numeric)
> type, to aid scripting?


No need.  I already made the necessary changes in userspace to switch
to nl80211 to retrieve the iftype.  Both Bing and I are done
proselytizing at this point. :-)

>
> All I'm trying to say with that though is that
> you shouldn't rely on specific output formatting, particularly not with
> scan results and "iw list" etc.
>
> johannes
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-04-22 13:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-17 22:06 [PATCH] net-sysfs: Add entry for nl80211 interface type Bing Zhao
2013-04-17 22:09 ` Johannes Berg
2013-04-18  6:14   ` Nicolas Cavallari
2013-04-18  6:43     ` Marcel Holtmann
2013-04-18  7:03       ` Paul Stewart
2013-04-18 15:46         ` Marcel Holtmann
     [not found]   ` <CAMcMvsjh4y=84hM+dCcFvb1xxSq5c3HqTBg6VyaCZkh5s=E5yA@mail.gmail.com>
2013-04-22 13:29     ` Johannes Berg
2013-04-22 13:55       ` Paul Stewart
2013-04-17 22:54 ` Marcel Holtmann
2013-04-18 19:03   ` Bing Zhao
2013-04-18 19:10     ` Marcel Holtmann
2013-04-18 19:18       ` Arend van Spriel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).