[ovs-dev] [PATCH 08/10] datapath: Use RCU dereference in vport_get_ifindex().

Jesse Gross jesse at nicira.com
Wed Dec 29 04:50:46 UTC 2010


If we don't have an ifindex for a device (because it is a virtual
port), we fall back to using the ifindex of the local port.
However, we weren't properly dereferencing the vport from the ports
array, so this adds that.  This isn't a real problem though, because
the local port always exists and never changes as long as the
datapath exists.

Found with sparse.

Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/vport.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/datapath/vport.c b/datapath/vport.c
index 9e847e5..6c053ac 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -928,10 +928,10 @@ unsigned char vport_get_operstate(const struct vport *vport)
  *
  * @vport: vport from which to retrieve index
  *
- * Retrieves the system interface index of the given device.  Not all devices
- * will have system indexes, in which case the index of the datapath local
- * port is returned.  Returns a negative index on error.  Either RTNL lock or
- * rcu_read_lock must be held.
+ * Retrieves the system interface index of the given device.  Not all
+ * devices will have system indexes, in which case the index of the
+ * datapath local port is returned.  Returns a negative index on error.
+ * Either RTNL lock or rcu_read_lock must be held.
  */
 int vport_get_ifindex(const struct vport *vport)
 {
@@ -940,7 +940,8 @@ int vport_get_ifindex(const struct vport *vport)
 
 	/* If we don't actually have an ifindex, use the local port's.
 	 * Userspace doesn't check it anyways. */
-	return vport_get_ifindex(vport->dp->ports[ODPP_LOCAL]);
+	return vport_get_ifindex(rcu_dereference_rtnl(vport->dp->
+						ports[ODPP_LOCAL]));
 }
 
 /**
-- 
1.7.1





More information about the dev mailing list