Skip to contentSkip to conversation

Tun device encapsulation

PATCH In review Stephen Hemminger 4 participants 4 messages Jun 4, 2003 – Jun 5, 2003 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#2 lore raw

PATCH 1/1 Tun device encapsulation

In reply to a message not in the archive

Tun device was encapsulating the net_device in a private structure then doing:

	unregister_netdev(&tun->dev);
	kfree(tun);
	rtnl_unlock();

This breaks with the delayed cleanup now in the network core. Moving the kfree outside of the rtnl_unlock will fix it.

Builds, but not sure how to use TUN to test it.

As part of later refcounting changes, I do have a more complex change that uses the same encapsulation as ethernet and other devices. Will save it for later.

drivers/net/tun.c +3 -1
diff -Nru a/drivers/net/tun.c b/drivers/net/tun.c
@@ -551,10 +551,12 @@
 	if (!(tun->flags & TUN_PERSIST)) {
 		dev_close(&tun->dev);
 		unregister_netdevice(&tun->dev);
-		kfree(tun);
 	}
 
 	rtnl_unlock();
+
+	if (!(tun->flags & TUN_PERSIST)) 
+		kfree(tun);
 	return 0;
 }
 
#3 lore raw

I'll be happy to test it out later -

Thanks,

Joe

Quoted 34 lines · Stephen Hemminger

Tun device was encapsulating the net_device in a private structure then doing:

	unregister_netdev(&tun->dev);
	kfree(tun);
	rtnl_unlock();

This breaks with the delayed cleanup now in the network core. Moving the kfree outside of the rtnl_unlock will fix it.

Builds, but not sure how to use TUN to test it.

As part of later refcounting changes, I do have a more complex change that uses the same encapsulation as ethernet and other devices. Will save it for later.

diff -Nru a/drivers/net/tun.c b/drivers/net/tun.c

drivers/net/tun.c +3 -1
@@ -551,10 +551,12 @@
 	if (!(tun->flags & TUN_PERSIST)) {
 		dev_close(&tun->dev);
 		unregister_netdevice(&tun->dev);
-		kfree(tun);
 	}
 
 	rtnl_unlock();
+
+	if (!(tun->flags & TUN_PERSIST)) 
+		kfree(tun);
 	return 0;
 }
 
#4 lore raw
In reply to Stephen Hemminger

This fixes the tun problem nicely here -

Joe

Quoted 35 lines · Stephen Hemminger

Tun device was encapsulating the net_device in a private structure then doing:

	unregister_netdev(&tun->dev);
	kfree(tun);
	rtnl_unlock();

This breaks with the delayed cleanup now in the network core. Moving the kfree outside of the rtnl_unlock will fix it.

Builds, but not sure how to use TUN to test it.

As part of later refcounting changes, I do have a more complex change that uses the same encapsulation as ethernet and other devices. Will save it for later.

diff -Nru a/drivers/net/tun.c b/drivers/net/tun.c

drivers/net/tun.c +3 -1
@@ -551,10 +551,12 @@
 	if (!(tun->flags & TUN_PERSIST)) {
 		dev_close(&tun->dev);
 		unregister_netdevice(&tun->dev);
-		kfree(tun);
 	}
 
 	rtnl_unlock();
+
+	if (!(tun->flags & TUN_PERSIST)) 
+		kfree(tun);
 	return 0;
 }
 
#5 lore raw
In reply to Stephen Hemminger

From: Stephen Hemminger <[email protected]>
Date: Wed, 4 Jun 2003 15:40:22 -0700

Tun device was encapsulating the net_device in a private structure then doing:

   	unregister_netdev(&tun->dev);
   	kfree(tun);
   	rtnl_unlock();

This breaks with the delayed cleanup now in the network core. Moving the kfree outside of the rtnl_unlock will fix it.

Builds, but not sure how to use TUN to test it.

This seems to indeed fix the problem for people, applied thanks.