datapath: Use call_rcu() when deleting a datapath.
[openvswitch] / datapath / vport.c
index ee806453676ebc471deec2f856e5bd1c05da7f5e..a3244a3ec6a053e46b25765117888b6909bfde1b 100644 (file)
@@ -577,8 +577,9 @@ void vport_free(struct vport *vport)
  *
  * @parms: Information about new vport.
  *
- * Creates a new vport with the specified configuration (which is dependent
- * on device type).  Both RTNL and vport locks must be held.
+ * Creates a new vport with the specified configuration (which is dependent on
+ * device type) and attaches it to a datapath.  Both RTNL and vport locks must
+ * be held.
  */
 struct vport *vport_add(const struct vport_parms *parms)
 {
@@ -633,9 +634,8 @@ int vport_mod(struct vport *vport, struct odp_port *port)
  *
  * @vport: vport to delete.
  *
- * Deletes the specified device.  The device must not be currently attached to
- * a datapath.  It is possible to fail for reasons such as lack of memory.
- * Both RTNL and vport locks must be held.
+ * Detaches @vport from its datapath and destroys it.  It is possible to fail
+ * for reasons such as lack of memory.  Both RTNL and vport locks must be held.
  */
 int vport_del(struct vport *vport)
 {
@@ -647,42 +647,6 @@ int vport_del(struct vport *vport)
        return vport->ops->destroy(vport);
 }
 
-/**
- *     vport_attach - notify a vport that it has been attached to a datapath
- *
- * @vport: vport to attach.
- *
- * Performs vport-specific actions so that packets may be exchanged.  RTNL lock
- * and the appropriate DP mutex must be held.
- */
-int vport_attach(struct vport *vport)
-{
-       ASSERT_RTNL();
-
-       if (vport->ops->attach)
-               return vport->ops->attach(vport);
-
-       return 0;
-}
-
-/**
- *     vport_detach - detach a vport from a datapath
- *
- * @vport: vport to detach.
- *
- * Performs vport-specific actions before a vport is detached from a datapath.
- * May fail for a variety of reasons, including lack of memory.  RTNL lock and
- * the appropriate DP mutex must be held.
- */
-int vport_detach(struct vport *vport)
-{
-       ASSERT_RTNL();
-
-       if (vport->ops->detach)
-               return vport->ops->detach(vport);
-       return 0;
-}
-
 /**
  *     vport_set_mtu - set device MTU (for kernel callers)
  *
@@ -964,19 +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
+ * 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(vport->dp->ports[ODPP_LOCAL]);
+       else
+               return 0;
 }
 
 /**
@@ -1013,6 +975,22 @@ int vport_get_mtu(const struct vport *vport)
        return vport->ops->get_mtu(vport);
 }
 
+/**
+ *     vport_get_config - retrieve device configuration
+ *
+ * @vport: vport from which to retrieve the configuration.
+ * @config: buffer to store config, which must be at least the length
+ *          of VPORT_CONFIG_SIZE.
+ *
+ * Retrieves the configuration of the given device.  Either RTNL lock or
+ * rcu_read_lock must be held.
+ */
+void vport_get_config(const struct vport *vport, void *config)
+{
+       if (vport->ops->get_config)
+               vport->ops->get_config(vport, config);
+}
+
 /**
  *     vport_receive - pass up received packet to the datapath for processing
  *