aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorWeilong Chen <chenweilong@huawei.com>2014-01-16 04:24:31 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-19 23:02:02 -0500
commit82ef3d5d5f3ffd757c960693c4fe7a0051211849 (patch)
tree2494c00a2fc1d9153734672cfbe7e96e215aa14a /net/core
parent671314a5abb7abb8346cd3f16f75c1e55ed7667b (diff)
net: fix "queues" uevent between network namespaces
When I create a new namespace with 'ip netns add net0', or add/remove new links in a namespace with 'ip link add/delete type veth', rx/tx queues events can be got in all namespaces. That is because rx/tx queue ktypes do not have namespace support, and their kobj parents are setted to NULL. This patch is to fix it. Reported-by: Libo Chen <chenlibo@huawei.com> Signed-off-by: Libo Chen <chenlibo@huawei.com> Signed-off-by: Weilong Chen <chenweilong@huawei.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/net-sysfs.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 7eeadeecc5a2..93886246a0b4 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -744,10 +744,23 @@ static void rx_queue_release(struct kobject *kobj)
744 dev_put(queue->dev); 744 dev_put(queue->dev);
745} 745}
746 746
747static const void *rx_queue_namespace(struct kobject *kobj)
748{
749 struct netdev_rx_queue *queue = to_rx_queue(kobj);
750 struct device *dev = &queue->dev->dev;
751 const void *ns = NULL;
752
753 if (dev->class && dev->class->ns_type)
754 ns = dev->class->namespace(dev);
755
756 return ns;
757}
758
747static struct kobj_type rx_queue_ktype = { 759static struct kobj_type rx_queue_ktype = {
748 .sysfs_ops = &rx_queue_sysfs_ops, 760 .sysfs_ops = &rx_queue_sysfs_ops,
749 .release = rx_queue_release, 761 .release = rx_queue_release,
750 .default_attrs = rx_queue_default_attrs, 762 .default_attrs = rx_queue_default_attrs,
763 .namespace = rx_queue_namespace
751}; 764};
752 765
753static int rx_queue_add_kobject(struct net_device *net, int index) 766static int rx_queue_add_kobject(struct net_device *net, int index)
@@ -1093,10 +1106,23 @@ static void netdev_queue_release(struct kobject *kobj)
1093 dev_put(queue->dev); 1106 dev_put(queue->dev);
1094} 1107}
1095 1108
1109static const void *netdev_queue_namespace(struct kobject *kobj)
1110{
1111 struct netdev_queue *queue = to_netdev_queue(kobj);
1112 struct device *dev = &queue->dev->dev;
1113 const void *ns = NULL;
1114
1115 if (dev->class && dev->class->ns_type)
1116 ns = dev->class->namespace(dev);
1117
1118 return ns;
1119}
1120
1096static struct kobj_type netdev_queue_ktype = { 1121static struct kobj_type netdev_queue_ktype = {
1097 .sysfs_ops = &netdev_queue_sysfs_ops, 1122 .sysfs_ops = &netdev_queue_sysfs_ops,
1098 .release = netdev_queue_release, 1123 .release = netdev_queue_release,
1099 .default_attrs = netdev_queue_default_attrs, 1124 .default_attrs = netdev_queue_default_attrs,
1125 .namespace = netdev_queue_namespace,
1100}; 1126};
1101 1127
1102static int netdev_queue_add_kobject(struct net_device *net, int index) 1128static int netdev_queue_add_kobject(struct net_device *net, int index)