aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index be196e89ab6c..3ff8cd7bf74d 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1565,6 +1565,17 @@ static DEVICE_ATTR(tun_flags, 0444, tun_show_flags, NULL);
1565static DEVICE_ATTR(owner, 0444, tun_show_owner, NULL); 1565static DEVICE_ATTR(owner, 0444, tun_show_owner, NULL);
1566static DEVICE_ATTR(group, 0444, tun_show_group, NULL); 1566static DEVICE_ATTR(group, 0444, tun_show_group, NULL);
1567 1567
1568static struct attribute *tun_dev_attrs[] = {
1569 &dev_attr_tun_flags.attr,
1570 &dev_attr_owner.attr,
1571 &dev_attr_group.attr,
1572 NULL
1573};
1574
1575static const struct attribute_group tun_attr_group = {
1576 .attrs = tun_dev_attrs
1577};
1578
1568static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) 1579static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1569{ 1580{
1570 struct tun_struct *tun; 1581 struct tun_struct *tun;
@@ -1645,6 +1656,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1645 dev_net_set(dev, net); 1656 dev_net_set(dev, net);
1646 dev->rtnl_link_ops = &tun_link_ops; 1657 dev->rtnl_link_ops = &tun_link_ops;
1647 dev->ifindex = tfile->ifindex; 1658 dev->ifindex = tfile->ifindex;
1659 dev->sysfs_groups[0] = &tun_attr_group;
1648 1660
1649 tun = netdev_priv(dev); 1661 tun = netdev_priv(dev);
1650 tun->dev = dev; 1662 tun->dev = dev;
@@ -1680,11 +1692,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1680 err = register_netdevice(tun->dev); 1692 err = register_netdevice(tun->dev);
1681 if (err < 0) 1693 if (err < 0)
1682 goto err_detach; 1694 goto err_detach;
1683
1684 if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
1685 device_create_file(&tun->dev->dev, &dev_attr_owner) ||
1686 device_create_file(&tun->dev->dev, &dev_attr_group))
1687 pr_err("Failed to create tun sysfs files\n");
1688 } 1695 }
1689 1696
1690 netif_carrier_on(tun->dev); 1697 netif_carrier_on(tun->dev);