From: Julius Niedworok <julius.n@gmx.net>
To: netdev@vger.kernel.org
Cc: julius.n@gmx.net, ga58taw@mytum.de,
"David S. Miller" <davem@davemloft.net>,
Alexander Duyck <alexander.h.duyck@intel.com>,
Tyler Hicks <tyhicks@canonical.com>,
Amritha Nambiar <amritha.nambiar@intel.com>,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>,
Petr Machata <petrm@mellanox.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH RFC] net-sysfs: consistent behavior between ioctl and sysfs
Date: Mon, 18 Feb 2019 19:02:49 +0100 [thread overview]
Message-ID: <20190218180255.15822-1-julius.n@gmx.net> (raw)
The flags of a network interface can be read either from
/sys/class/net/<dev>/flags or from the ioctl SIOCGIFFLAGS. When the ioctl
is used, dev_get_flags is called to extract the flags. However, reads on
the sysfs file return the plain content of the flags integer and do not
call dev_get_flags.
In order to fix this inconsistent behavior, replace the NETDEVICE_SHOW_RW
macro by the functions format_flags and flags_show. These functions extract
the flags by calling dev_get_flags and return them formatted for the user.
This makes the behavior between calling the SIOCGIFFLAGS ioctl and reading
/sys/class/net/<dev>/flags consistent.
Co-developed-by: Charlie Groh <ga58taw@mytum.de>
Signed-off-by: Charlie Groh <ga58taw@mytum.de>
Signed-off-by: Julius Niedworok <julius.n@gmx.net>
---
net/core/net-sysfs.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index ff9fd2b..8ae8be5 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -345,7 +345,19 @@ static ssize_t flags_store(struct device *dev, struct device_attribute *attr,
{
return netdev_store(dev, attr, buf, len, change_flags);
}
-NETDEVICE_SHOW_RW(flags, fmt_hex);
+
+static ssize_t format_flags(const struct net_device *dev, char *buf)
+{
+ return sprintf(buf, fmt_hex, dev_get_flags(dev));
+}
+
+static ssize_t flags_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return netdev_show(dev, attr, buf, format_flags);
+}
+static DEVICE_ATTR_RW(flags);
static ssize_t tx_queue_len_store(struct device *dev,
struct device_attribute *attr,
--
2.10.1 (Apple Git-78)
reply other threads:[~2019-02-18 18:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190218180255.15822-1-julius.n@gmx.net \
--to=julius.n@gmx.net \
--cc=alexander.h.duyck@intel.com \
--cc=amritha.nambiar@intel.com \
--cc=davem@davemloft.net \
--cc=dmitry.torokhov@gmail.com \
--cc=ga58taw@mytum.de \
--cc=jeffrey.t.kirsher@intel.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=petrm@mellanox.com \
--cc=tyhicks@canonical.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox