All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] don't touch bridge sysfs in container.
@ 2009-07-08 11:56 Ken-ichirou MATSUZAWA
  2009-07-08 16:33 ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Ken-ichirou MATSUZAWA @ 2009-07-08 11:56 UTC (permalink / raw)
  To: netdev; +Cc: chamas

 Hello,

netns don't have own sysfs. we should not touch sysfs not on init_net?
I am sorry I've lost my own mail, titled

  kernel BUG at fs/sysfs/group.c:65!

below will only fixes this.

Signed-off-by: Ken-ichirou MATSUZAWA
---
 net/bridge/br_if.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 8a96672..7c080a9 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -164,7 +164,9 @@ static void del_br(struct net_bridge *br)
 
 	del_timer_sync(&br->gc_timer);
 
-	br_sysfs_delbr(br->dev);
+        if (dev_net(br->dev) == &init_net)
+                br_sysfs_delbr(br->dev);
+
 	unregister_netdevice(br->dev);
 }
 
@@ -283,6 +285,9 @@ int br_add_bridge(struct net *net, const char *name)
 	if (ret)
 		goto out_free;
 
+        if (dev_net(dev) != &init_net)
+                goto out;
+
 	ret = br_sysfs_addbr(dev);
 	if (ret)
 		unregister_netdevice(dev);
@@ -396,9 +401,11 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 	if (err)
 		goto err1;
 
-	err = br_sysfs_addif(p);
-	if (err)
-		goto err2;
+        if (dev_net(br->dev) == &init_net) {
+                err = br_sysfs_addif(p);
+                if (err)
+                        goto err2;
+        }
 
 	rcu_assign_pointer(dev->br_port, p);
 	dev_disable_lro(dev);
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] don't touch bridge sysfs in container.
  2009-07-08 11:56 [PATCH] don't touch bridge sysfs in container Ken-ichirou MATSUZAWA
@ 2009-07-08 16:33 ` Stephen Hemminger
  2009-07-09 10:41   ` Ken-ichirou MATSUZAWA
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2009-07-08 16:33 UTC (permalink / raw)
  To: Ken-ichirou MATSUZAWA; +Cc: netdev, chamas

On Wed, 08 Jul 2009 20:56:29 +0900
Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> wrote:

>  Hello,
> 
> netns don't have own sysfs. we should not touch sysfs not on init_net?
> I am sorry I've lost my own mail, titled
> 
>   kernel BUG at fs/sysfs/group.c:65!
> 
> below will only fixes this.
> 
> Signed-off-by: Ken-ichirou MATSUZAWA

There is a per netns sysfs interface, it should be changed to use that.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] don't touch bridge sysfs in container.
  2009-07-08 16:33 ` Stephen Hemminger
@ 2009-07-09 10:41   ` Ken-ichirou MATSUZAWA
  2009-07-09 21:23     ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Ken-ichirou MATSUZAWA @ 2009-07-09 10:41 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Ken-ichirou MATSUZAWA, netdev

 Hello,

At Wed, 8 Jul 2009 09:33:20 -0700,
Stephen Hemminger wrote:

> There is a per netns sysfs interface, it should be changed to use that.

Sorry, I can see only:

    - add netns suffix was disagreed
    - tagged sysfs may not be merged
    - registering device through netdev_register_kobject()
      does not call device_add() in case of net is not init_net

Could you give me any hint?

Thanks in advance.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] don't touch bridge sysfs in container.
  2009-07-09 10:41   ` Ken-ichirou MATSUZAWA
@ 2009-07-09 21:23     ` Stephen Hemminger
  2009-07-11  3:59       ` Ken-ichirou MATSUZAWA
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2009-07-09 21:23 UTC (permalink / raw)
  To: Ken-ichirou MATSUZAWA; +Cc: Ken-ichirou MATSUZAWA, netdev

On Thu, 09 Jul 2009 19:41:34 +0900
Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> wrote:

>  Hello,
> 
> At Wed, 8 Jul 2009 09:33:20 -0700,
> Stephen Hemminger wrote:
> 
> > There is a per netns sysfs interface, it should be changed to use that.
> 
> Sorry, I can see only:
> 
>     - add netns suffix was disagreed
>     - tagged sysfs may not be merged

Without tagged sysfs, how could bridge interface work in other containers?


-- 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] don't touch bridge sysfs in container.
  2009-07-09 21:23     ` Stephen Hemminger
@ 2009-07-11  3:59       ` Ken-ichirou MATSUZAWA
  0 siblings, 0 replies; 5+ messages in thread
From: Ken-ichirou MATSUZAWA @ 2009-07-11  3:59 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Ken-ichirou MATSUZAWA, netdev

 Hello,

At Thu, 9 Jul 2009 14:23:17 -0700,
Stephen Hemminger wrote:

> Without tagged sysfs, how could bridge interface work in other containers?

I start thinking I try odd things or I'm not asking right questions.
No one can see what I'm trying in my poor English, please let me explain...

----

base host		terminal A		terminal B
			# ./ns_exec -cn /bin/sh
			# echo $$
			2421
						# ./ns_exec -cn /bin/sh
						# echo $$
						2425
# ip link add type veth
# ip link set veth0 netns 2421
# ip link set veth1 netns 2425
# ip link add type veth
# ip link set veth1 netns 2421
# ip link set veth0 up
			# ip link set veth0 up
			# ip link set veth1 up
			# brctl addbr br0
			# brctl addif br0 veth0
			# brctl addif br0 veth1
			# ip link set br0 up
						# ip link set veth1 up
						# ip addr add 192.168.1.10/24 dev veth1
# ip addr add 192.168.1.1/24 dev veth0
# ping 192.168.1.10

----

I want to play with ebtables, qdisc and something stuff like that in
terminal A. until tagged sysfs merged, we should not try those on present
container system?

Thanks in advance.

Signed-off-by: Ken-ichirou MATSUZAWA

---
 net/bridge/br_if.c |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 8a96672..ea97d2e 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -107,7 +107,8 @@ static void destroy_nbp(struct net_bridge_port *p)
 	p->dev = NULL;
 	dev_put(dev);
 
-	kobject_put(&p->kobj);
+        if (dev_net(dev) == &init_net)
+		kobject_put(&p->kobj);
 }
 
 static void destroy_nbp_rcu(struct rcu_head *head)
@@ -148,7 +149,8 @@ static void del_nbp(struct net_bridge_port *p)
 	rcu_assign_pointer(dev->br_port, NULL);
 
 	kobject_uevent(&p->kobj, KOBJ_REMOVE);
-	kobject_del(&p->kobj);
+        if (dev_net(br->dev) == &init_net)
+		kobject_del(&p->kobj);
 
 	call_rcu(&p->rcu, destroy_nbp_rcu);
 }
@@ -164,7 +166,9 @@ static void del_br(struct net_bridge *br)
 
 	del_timer_sync(&br->gc_timer);
 
-	br_sysfs_delbr(br->dev);
+        if (dev_net(br->dev) == &init_net)
+                br_sysfs_delbr(br->dev);
+
 	unregister_netdevice(br->dev);
 }
 
@@ -283,6 +287,9 @@ int br_add_bridge(struct net *net, const char *name)
 	if (ret)
 		goto out_free;
 
+        if (dev_net(dev) != &init_net)
+                goto out;
+
 	ret = br_sysfs_addbr(dev);
 	if (ret)
 		unregister_netdevice(dev);
@@ -387,18 +394,22 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 	if (err)
 		goto put_back;
 
-	err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj),
-				   SYSFS_BRIDGE_PORT_ATTR);
-	if (err)
-		goto err0;
+        if (dev_net(br->dev) == &init_net) {
+		err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj),
+					   SYSFS_BRIDGE_PORT_ATTR);
+		if (err)
+			goto err0;
+	}
 
 	err = br_fdb_insert(br, p, dev->dev_addr);
 	if (err)
 		goto err1;
 
-	err = br_sysfs_addif(p);
-	if (err)
-		goto err2;
+        if (dev_net(br->dev) == &init_net) {
+                err = br_sysfs_addif(p);
+                if (err)
+                        goto err2;
+        }
 
 	rcu_assign_pointer(dev->br_port, p);
 	dev_disable_lro(dev);
@@ -424,7 +435,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 err2:
 	br_fdb_delete_by_port(br, p, 1);
 err1:
-	kobject_del(&p->kobj);
+        if (dev_net(br->dev) == &init_net)
+		kobject_del(&p->kobj);
 err0:
 	dev_set_promiscuity(dev, -1);
 put_back:
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-11  3:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-08 11:56 [PATCH] don't touch bridge sysfs in container Ken-ichirou MATSUZAWA
2009-07-08 16:33 ` Stephen Hemminger
2009-07-09 10:41   ` Ken-ichirou MATSUZAWA
2009-07-09 21:23     ` Stephen Hemminger
2009-07-11  3:59       ` Ken-ichirou MATSUZAWA

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.