[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130401115315.1f8e4213@nehalam.linuxnetplumber.net>
Date: Mon, 1 Apr 2013 11:53:15 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: David Miller <davem@...emloft.net>
Cc: netdev@...r.kernel.org
Subject: [PATCH] net-sysfs: make flags symmetrical
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@...workplumber.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)
{
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists