2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-09 13:49:05 +00:00

dpif-netdev: enumerate dpif belonging to the right class

Since dpif_netdev_enumerate() is used for "netdev" and "dummy" class, it
incorrectly lists dpif-netdevs as "dummy" and vice versa.
This patches address the issue by changing the dpif-provider interface: a
dpif_class parameter is passed to the 'enumerate' call to match the right class.

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Daniele Di Proietto
2014-06-12 16:37:33 -07:00
committed by Ben Pfaff
parent 277876e9c1
commit 2240af2576
4 changed files with 18 additions and 7 deletions

View File

@@ -195,7 +195,8 @@ dpif_linux_cast(const struct dpif *dpif)
}
static int
dpif_linux_enumerate(struct sset *all_dps)
dpif_linux_enumerate(struct sset *all_dps,
const struct dpif_class *dpif_class OVS_UNUSED)
{
struct nl_dump dump;
uint64_t reply_stub[NL_DUMP_BUFSIZE / 8];

View File

@@ -360,12 +360,19 @@ get_dp_netdev(const struct dpif *dpif)
}
static int
dpif_netdev_enumerate(struct sset *all_dps)
dpif_netdev_enumerate(struct sset *all_dps,
const struct dpif_class *dpif_class)
{
struct shash_node *node;
ovs_mutex_lock(&dp_netdev_mutex);
SHASH_FOR_EACH(node, &dp_netdevs) {
struct dp_netdev *dp = node->data;
if (dpif_class != dp->class) {
/* 'dp_netdevs' contains both "netdev" and "dummy" dpifs.
* If the class doesn't match, skip this dpif. */
continue;
}
sset_add(all_dps, node->name);
}
ovs_mutex_unlock(&dp_netdev_mutex);

View File

@@ -89,16 +89,17 @@ struct dpif_class {
* the type assumed if no type is specified when opening a dpif. */
const char *type;
/* Enumerates the names of all known created datapaths, if possible, into
* 'all_dps'. The caller has already initialized 'all_dps' and other dpif
* classes might already have added names to it.
/* Enumerates the names of all known created datapaths (of class
* 'dpif_class'), if possible, into 'all_dps'. The caller has already
* initialized 'all_dps' and other dpif classes might already have added
* names to it.
*
* This is used by the vswitch at startup, so that it can delete any
* datapaths that are not configured.
*
* Some kinds of datapaths might not be practically enumerable, in which
* case this function may be a null pointer. */
int (*enumerate)(struct sset *all_dps);
int (*enumerate)(struct sset *all_dps, const struct dpif_class *dpif_class);
/* Returns the type to pass to netdev_open() when a dpif of class
* 'dpif_class' has a port of type 'type', for a few special cases

View File

@@ -272,7 +272,9 @@ dp_enumerate_names(const char *type, struct sset *names)
}
dpif_class = registered_class->dpif_class;
error = dpif_class->enumerate ? dpif_class->enumerate(names) : 0;
error = (dpif_class->enumerate
? dpif_class->enumerate(names, dpif_class)
: 0);
if (error) {
VLOG_WARN("failed to enumerate %s datapaths: %s", dpif_class->type,
ovs_strerror(error));