[ovs-dev] [PATCH] datapath: Wait for grace period before deleting a datapath.

Jesse Gross jesse at nicira.com
Wed Jan 5 16:33:58 UTC 2011


When deleting a datapath, we remove all of the vports and then immediately
free the datapath data structures.  Since the vports are allowed to use
call_rcu() to free their data, it's possible for them to return immediately
while packet processing is still taking place.  This adds an explicit
synchronize_rcu() call to wait for a grace period after all references
have been dropped.

This race cannot actually occur in practice since the last port to be
deleted is an internal device, which uses synchronize_rcu() itself
(implicitly through unregister_netdevice()).  However, there is no
requirement that it must do this nor should there be.

Reported-by: Ben Pfaff <blp at nicira.com>
Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/datapath.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 01b3025..62b4617 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -332,8 +332,10 @@ static int destroy_dp(int dp_idx)
 	dp_sysfs_del_dp(dp);
 
 	rcu_assign_pointer(dps[dp->dp_idx], NULL);
-
 	dp_detach_port(get_vport_protected(dp, ODPP_LOCAL));
+
+	synchronize_rcu();
+
 	tbl_destroy(get_table_protected(dp), flow_free_tbl);
 
 	for (i = 0; i < DP_N_QUEUES; i++)
-- 
1.7.1





More information about the dev mailing list