[ovs-dev] [PATCH 6/7] datapath: Report ifindex of 0 if vport doesn't have one.

Jesse Gross jesse at nicira.com
Wed Dec 29 23:41:34 UTC 2010


If a vport is a virtual device then it doesn't have a system ifindex.
We currently return the ifindex of the bridge device in this situation
but that's somewhat misleading, so this replaces it with 0.  Nothing
actually reads the ifindex for devices other than the bridge device,
so this doesn't have a functional change.

Suggested-by: Ben Pfaff <blp at nicira.com>
Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/vport.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/datapath/vport.c b/datapath/vport.c
index 6c053ac..a3244a3 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -928,20 +928,17 @@ 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 or 0 if
+ * the device does not have one (in the case of virtual ports).
+ * Returns a negative index on error. Either RTNL lock or
+ * rcu_read_lock must be held.
  */
 int vport_get_ifindex(const struct vport *vport)
 {
 	if (vport->ops->get_ifindex)
 		return vport->ops->get_ifindex(vport);
-
-	/* If we don't actually have an ifindex, use the local port's.
-	 * Userspace doesn't check it anyways. */
-	return vport_get_ifindex(rcu_dereference_rtnl(vport->dp->
-						ports[ODPP_LOCAL]));
+	else
+		return 0;
 }
 
 /**
-- 
1.7.1





More information about the dev mailing list