From: Ben Pfaff <blp@nicira.com>
Date: Mon, 2 Jun 2008 17:16:34 +0000 (-0700)
Subject: Don't try to destroy dp_dev while the local port holds a reference to it.
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0b75446a26c68f2a9f2dd3a9112b34fc81ffc0cb;p=sliver-openvswitch.git

Don't try to destroy dp_dev while the local port holds a reference to it.

Fixes a message output at deldp time:
unregister_netdevice: waiting for of0 to become free. Usage count = 1

Thanks to Murphy and Justin for reporting this bug.
---

diff --git a/datapath/datapath.c b/datapath/datapath.c
index c87fa2416..adc698065 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -408,7 +408,6 @@ static void del_dp(struct datapath *dp)
 {
 	struct net_bridge_port *p;
 
-	dp_dev_destroy(dp);
 	kthread_stop(dp->dp_task);
 
 	/* Drop references to DP. */
@@ -416,6 +415,10 @@ static void del_dp(struct datapath *dp)
 		del_switch_port(p);
 	rcu_assign_pointer(dps[dp->dp_idx], NULL);
 
+	/* Destroy dp->netdev.  (Must follow deleting switch ports since
+	 * dp->local_port has a reference to it.) */
+	dp_dev_destroy(dp);
+
 	/* Wait until no longer in use, then destroy it. */
 	synchronize_rcu();
 	chain_destroy(dp->chain);