* [PATCH] net: add sysfs entry for device group
@ 2011-01-24 13:37 Vlad Dogaru
2011-01-25 4:41 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Vlad Dogaru @ 2011-01-24 13:37 UTC (permalink / raw)
To: netdev; +Cc: Vlad Dogaru, Stephen Hemminger
The group of a network device can be queried or changed from userspace
using sysfs.
For example, considering sysfs mounted in /sys, one can change the group
that interface lo belongs to:
echo 1 > /sys/class/net/lo/group
Signed-off-by: Vlad Dogaru <ddvlad@rosedu.org>
---
net/core/net-sysfs.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index e23c01b..b726131 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -295,6 +295,20 @@ static ssize_t show_ifalias(struct device *dev,
return ret;
}
+NETDEVICE_SHOW(group, fmt_dec);
+
+static int change_group(struct net_device *net, unsigned long new_group)
+{
+ dev_set_group(net, (int) new_group);
+ return 0;
+}
+
+static ssize_t store_group(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ return netdev_store(dev, attr, buf, len, change_group);
+}
+
static struct device_attribute net_class_attributes[] = {
__ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL),
__ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
@@ -316,6 +330,7 @@ static struct device_attribute net_class_attributes[] = {
__ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags),
__ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len,
store_tx_queue_len),
+ __ATTR(group, S_IRUGO | S_IWUSR, show_group, store_group),
{}
};
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: add sysfs entry for device group
2011-01-24 13:37 [PATCH] net: add sysfs entry for device group Vlad Dogaru
@ 2011-01-25 4:41 ` Stephen Hemminger
2011-01-25 7:23 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2011-01-25 4:41 UTC (permalink / raw)
To: Vlad Dogaru; +Cc: netdev
On Mon, 24 Jan 2011 15:37:29 +0200
Vlad Dogaru <ddvlad@rosedu.org> wrote:
> The group of a network device can be queried or changed from userspace
> using sysfs.
>
> For example, considering sysfs mounted in /sys, one can change the group
> that interface lo belongs to:
> echo 1 > /sys/class/net/lo/group
>
> Signed-off-by: Vlad Dogaru <ddvlad@rosedu.org>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: add sysfs entry for device group
2011-01-25 4:41 ` Stephen Hemminger
@ 2011-01-25 7:23 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-01-25 7:23 UTC (permalink / raw)
To: shemminger; +Cc: ddvlad, netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Tue, 25 Jan 2011 14:41:06 +1000
> On Mon, 24 Jan 2011 15:37:29 +0200
> Vlad Dogaru <ddvlad@rosedu.org> wrote:
>
>> The group of a network device can be queried or changed from userspace
>> using sysfs.
>>
>> For example, considering sysfs mounted in /sys, one can change the group
>> that interface lo belongs to:
>> echo 1 > /sys/class/net/lo/group
>>
>> Signed-off-by: Vlad Dogaru <ddvlad@rosedu.org>
>
> Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Applied to net-next-2.6, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-25 7:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-24 13:37 [PATCH] net: add sysfs entry for device group Vlad Dogaru
2011-01-25 4:41 ` Stephen Hemminger
2011-01-25 7:23 ` David Miller
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).