dpif_linux_enumerate,
dpif_linux_open,
dpif_linux_close,
- NULL, /* get_all_names */
dpif_linux_destroy,
dpif_linux_get_stats,
dpif_linux_get_drop_frags,
NULL, /* enumerate */
dpif_netdev_open,
dpif_netdev_close,
- NULL, /* get_all_names */
dpif_netdev_destroy,
dpif_netdev_get_stats,
dpif_netdev_get_drop_frags,
/* Closes 'dpif' and frees associated memory. */
void (*close)(struct dpif *dpif);
- /* Enumerates all names that may be used to open 'dpif' into 'all_names'.
- * The Linux datapath, for example, supports opening a datapath both by
- * number, e.g. "dp0", and by the name of the datapath's local port. For
- * some datapaths, this might be an infinite set (e.g. in a file name,
- * slashes may be duplicated any number of times), in which case only the
- * names most likely to be used should be enumerated.
- *
- * The caller has already initialized 'all_names' and might already have
- * added some names to it. This function should not disturb any existing
- * names in 'all_names'.
- *
- * If a datapath class does not support multiple names for a datapath, this
- * function may be a null pointer.
- *
- * This is used by the vswitch at startup, */
- int (*get_all_names)(const struct dpif *dpif, struct svec *all_names);
-
/* Attempts to destroy the dpif underlying 'dpif'.
*
* If successful, 'dpif' will not be used again except as an argument for
return dpif->base_name;
}
-/* Enumerates all names that may be used to open 'dpif' into 'all_names'. The
- * Linux datapath, for example, supports opening a datapath both by number,
- * e.g. "dp0", and by the name of the datapath's local port. For some
- * datapaths, this might be an infinite set (e.g. in a file name, slashes may
- * be duplicated any number of times), in which case only the names most likely
- * to be used will be enumerated.
- *
- * The caller must already have initialized 'all_names'. Any existing names in
- * 'all_names' will not be disturbed. */
-int
-dpif_get_all_names(const struct dpif *dpif, struct svec *all_names)
-{
- if (dpif->dpif_class->get_all_names) {
- int error = dpif->dpif_class->get_all_names(dpif, all_names);
- if (error) {
- VLOG_WARN_RL(&error_rl,
- "failed to retrieve names for datpath %s: %s",
- dpif_name(dpif), strerror(error));
- }
- return error;
- } else {
- svec_add(all_names, dpif_base_name(dpif));
- return 0;
- }
-}
-
-
/* Destroys the datapath that 'dpif' is connected to, first removing all of its
* ports. After calling this function, it does not make sense to pass 'dpif'
* to any functions other than dpif_name() or dpif_close(). */
const char *dpif_name(const struct dpif *);
const char *dpif_base_name(const struct dpif *);
-int dpif_get_all_names(const struct dpif *, struct svec *);
int dpif_delete(struct dpif *);
svec_init(&dpif_types);
dp_enumerate_types(&dpif_types);
for (i = 0; i < dpif_types.n; i++) {
- struct dpif *dpif;
- int retval;
size_t j;
dp_enumerate_names(dpif_types.names[i], &dpif_names);
- /* For each dpif... */
+ /* Delete each dpif whose name is not in 'bridge_names'. */
for (j = 0; j < dpif_names.n; j++) {
- retval = dpif_open(dpif_names.names[j], dpif_types.names[i], &dpif);
- if (!retval) {
- struct svec all_names;
- size_t k;
-
- /* ...check whether any of its names is in 'bridge_names'. */
- svec_init(&all_names);
- dpif_get_all_names(dpif, &all_names);
- for (k = 0; k < all_names.n; k++) {
- if (svec_contains(&bridge_names, all_names.names[k])) {
- goto found;
- }
+ if (!svec_contains(&bridge_names, dpif_names.names[j])) {
+ struct dpif *dpif;
+ int retval;
+
+ retval = dpif_open(dpif_names.names[j], dpif_types.names[i],
+ &dpif);
+ if (!retval) {
+ dpif_delete(dpif);
+ dpif_close(dpif);
}
-
- /* No. Delete the dpif. */
- dpif_delete(dpif);
-
- found:
- svec_destroy(&all_names);
- dpif_close(dpif);
}
}
}