* [PATCH] net-sysfs: make flags symmetrical
@ 2013-04-01 18:53 Stephen Hemminger
2013-04-01 20:16 ` Ben Greear
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2013-04-01 18:53 UTC (permalink / raw)
To: David Miller; +Cc: netdev
The flags reported by sysfs are the raw kernel flags, not the version
exported to user space. This leads to the unsymmetrical behaviour that
read != write. An example of this is when a device is part of a
bridge. The PROMISC flag returned from sysfs will not be the same as
other API's.
The reason this patch deserves wider discussion is someone might be
depending on sysfs to read raw kernel flags.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
--- a/net/core/net-sysfs.c 2013-03-21 14:17:08.740354291 -0700
+++ b/net/core/net-sysfs.c 2013-04-01 11:47:46.949728288 -0700
@@ -252,7 +252,19 @@ static ssize_t store_mtu(struct device *
return netdev_store(dev, attr, buf, len, change_mtu);
}
-NETDEVICE_SHOW(flags, fmt_hex);
+static ssize_t show_flags(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct net_device *ndev = to_net_dev(dev);
+ ssize_t ret = -EINVAL;
+
+ read_lock(&dev_base_lock);
+ if (dev_isalive(ndev))
+ ret = sprintf(buf, fmt_hex, dev_get_flags(ndev));
+ read_unlock(&dev_base_lock);
+
+ return ret;
+}
static int change_flags(struct net_device *net, unsigned long new_flags)
{
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net-sysfs: make flags symmetrical
2013-04-01 18:53 [PATCH] net-sysfs: make flags symmetrical Stephen Hemminger
@ 2013-04-01 20:16 ` Ben Greear
2013-04-01 21:18 ` David Miller
2013-04-01 22:04 ` Stephen Hemminger
0 siblings, 2 replies; 6+ messages in thread
From: Ben Greear @ 2013-04-01 20:16 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
On 04/01/2013 11:53 AM, Stephen Hemminger wrote:
> The flags reported by sysfs are the raw kernel flags, not the version
> exported to user space. This leads to the unsymmetrical behaviour that
> read != write. An example of this is when a device is part of a
> bridge. The PROMISC flag returned from sysfs will not be the same as
> other API's.
>
> The reason this patch deserves wider discussion is someone might be
> depending on sysfs to read raw kernel flags.
I am depending on this feature. There is no other way I know
of to determine if an interface is actually currently acting
PROMISC or not.
Please don't 'fix' this.
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net-sysfs: make flags symmetrical
2013-04-01 20:16 ` Ben Greear
@ 2013-04-01 21:18 ` David Miller
2013-04-01 21:32 ` Ben Greear
2013-04-01 22:04 ` Stephen Hemminger
1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2013-04-01 21:18 UTC (permalink / raw)
To: greearb; +Cc: stephen, netdev
From: Ben Greear <greearb@candelatech.com>
Date: Mon, 01 Apr 2013 13:16:43 -0700
> I am depending on this feature. There is no other way I know
> of to determine if an interface is actually currently acting
> PROMISC or not.
Netlink interface dump, SIOGIFCONF, etc. should provide this
information in one form or another.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net-sysfs: make flags symmetrical
2013-04-01 21:18 ` David Miller
@ 2013-04-01 21:32 ` Ben Greear
0 siblings, 0 replies; 6+ messages in thread
From: Ben Greear @ 2013-04-01 21:32 UTC (permalink / raw)
To: David Miller; +Cc: stephen, netdev
On 04/01/2013 02:18 PM, David Miller wrote:
> From: Ben Greear <greearb@candelatech.com>
> Date: Mon, 01 Apr 2013 13:16:43 -0700
>
>> I am depending on this feature. There is no other way I know
>> of to determine if an interface is actually currently acting
>> PROMISC or not.
>
> Netlink interface dump, SIOGIFCONF, etc. should provide this
> information in one form or another.
From looking elsewhere in my code, I think you are right, at least
about netlink.
The IFLA_PROMISCUITY field seems to give good results, but if you try
to parse the ifinfomsg->ifi_flags method, it may lie to you
and tell you the netdev is not PROMISSC when it really is PROMISC.
I haven't tried SIOGIFCONF...
Either way, I'd prefer the sysfs flags stay as is...while I have
the netlink interface coded up in my app, it is not exactly light
programming and other tools may find it much easier to use
the sysfs flags. And, since I've been using the sysfs flags
to double-check netlink in some cases, I'll have to add yet more
hacks if this compatibility is broken in newer kernels...
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net-sysfs: make flags symmetrical
2013-04-01 20:16 ` Ben Greear
2013-04-01 21:18 ` David Miller
@ 2013-04-01 22:04 ` Stephen Hemminger
2013-04-01 22:26 ` Ben Greear
1 sibling, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2013-04-01 22:04 UTC (permalink / raw)
To: Ben Greear; +Cc: David Miller, netdev
On Mon, 01 Apr 2013 13:16:43 -0700
Ben Greear <greearb@candelatech.com> wrote:
> On 04/01/2013 11:53 AM, Stephen Hemminger wrote:
> > The flags reported by sysfs are the raw kernel flags, not the version
> > exported to user space. This leads to the unsymmetrical behaviour that
> > read != write. An example of this is when a device is part of a
> > bridge. The PROMISC flag returned from sysfs will not be the same as
> > other API's.
> >
> > The reason this patch deserves wider discussion is someone might be
> > depending on sysfs to read raw kernel flags.
>
> I am depending on this feature. There is no other way I know
> of to determine if an interface is actually currently acting
> PROMISC or not.
>
> Please don't 'fix' this.
>
> Thanks,
> Ben
>
The real problem is there isn't a netlink attribute that encodes
the real flags (there should be), and when device changes state a notification
should be sent.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net-sysfs: make flags symmetrical
2013-04-01 22:04 ` Stephen Hemminger
@ 2013-04-01 22:26 ` Ben Greear
0 siblings, 0 replies; 6+ messages in thread
From: Ben Greear @ 2013-04-01 22:26 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
On 04/01/2013 03:04 PM, Stephen Hemminger wrote:
> On Mon, 01 Apr 2013 13:16:43 -0700
> Ben Greear <greearb@candelatech.com> wrote:
>
>> On 04/01/2013 11:53 AM, Stephen Hemminger wrote:
>>> The flags reported by sysfs are the raw kernel flags, not the version
>>> exported to user space. This leads to the unsymmetrical behaviour that
>>> read != write. An example of this is when a device is part of a
>>> bridge. The PROMISC flag returned from sysfs will not be the same as
>>> other API's.
>>>
>>> The reason this patch deserves wider discussion is someone might be
>>> depending on sysfs to read raw kernel flags.
>>
>> I am depending on this feature. There is no other way I know
>> of to determine if an interface is actually currently acting
>> PROMISC or not.
>>
>> Please don't 'fix' this.
>>
>> Thanks,
>> Ben
>>
>
> The real problem is there isn't a netlink attribute that encodes
> the real flags (there should be), and when device changes state a notification
> should be sent.
Ok, that sounds great to me...but plz don't remove the work-around
in sysfs in the meantime :)
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-04-01 22:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-01 18:53 [PATCH] net-sysfs: make flags symmetrical Stephen Hemminger
2013-04-01 20:16 ` Ben Greear
2013-04-01 21:18 ` David Miller
2013-04-01 21:32 ` Ben Greear
2013-04-01 22:04 ` Stephen Hemminger
2013-04-01 22:26 ` Ben Greear
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).