Skip to content

Commit

Permalink
net: add sysfs entry for device group
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vlad Dogaru authored and David S. Miller committed Jan 25, 2011
1 parent 84c49d8 commit a512b92
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
{}
};

Expand Down

0 comments on commit a512b92

Please sign in to comment.