#include "rtnetlink-link.h"
#include "shash.h"
#include "sset.h"
-#include "svec.h"
#include "unaligned.h"
#include "util.h"
#include "vlog.h"
}
static int
-dpif_linux_enumerate(struct svec *all_dps)
+dpif_linux_enumerate(struct sset *all_dps)
{
struct nl_dump dump;
struct ofpbuf msg;
struct dpif_linux_dp dp;
if (!dpif_linux_dp_from_ofpbuf(&dp, &msg)) {
- svec_add(all_dps, dp.name);
+ sset_add(all_dps, dp.name);
}
}
return nl_dump_done(&dump);
*
* Some kinds of datapaths might not be practically enumerable, in which
* case this function may be a null pointer. */
- int (*enumerate)(struct svec *all_dps);
+ int (*enumerate)(struct sset *all_dps);
/* Attempts to open an existing dpif called 'name', if 'create' is false,
* or to open an existing dpif or create a new one, if 'create' is true.
#include "packets.h"
#include "poll-loop.h"
#include "shash.h"
-#include "svec.h"
+#include "sset.h"
#include "timeval.h"
#include "util.h"
#include "valgrind.h"
}
/* Clears 'types' and enumerates the types of all currently registered datapath
- * providers into it. The caller must first initialize the svec. */
+ * providers into it. The caller must first initialize the sset. */
void
-dp_enumerate_types(struct svec *types)
+dp_enumerate_types(struct sset *types)
{
struct shash_node *node;
dp_initialize();
- svec_clear(types);
+ sset_clear(types);
SHASH_FOR_EACH(node, &dpif_classes) {
const struct registered_dpif_class *registered_class = node->data;
- svec_add(types, registered_class->dpif_class->type);
+ sset_add(types, registered_class->dpif_class->type);
}
}
/* Clears 'names' and enumerates the names of all known created datapaths with
- * the given 'type'. The caller must first initialize the svec. Returns 0 if
+ * the given 'type'. The caller must first initialize the sset. Returns 0 if
* successful, otherwise a positive errno value.
*
* Some kinds of datapaths might not be practically enumerable. This is not
* considered an error. */
int
-dp_enumerate_names(const char *type, struct svec *names)
+dp_enumerate_names(const char *type, struct sset *names)
{
const struct registered_dpif_class *registered_class;
const struct dpif_class *dpif_class;
int error;
dp_initialize();
- svec_clear(names);
+ sset_clear(names);
registered_class = shash_find_data(&dpif_classes, type);
if (!registered_class) {
struct netdev;
struct nlattr;
struct ofpbuf;
-struct svec;
+struct sset;
struct dpif_class;
void dp_run(void);
int dp_register_provider(const struct dpif_class *);
int dp_unregister_provider(const char *type);
-void dp_enumerate_types(struct svec *types);
+void dp_enumerate_types(struct sset *types);
-int dp_enumerate_names(const char *type, struct svec *names);
+int dp_enumerate_names(const char *type, struct sset *names);
void dp_parse_name(const char *datapath_name, char **name, char **type);
int dpif_open(const char *name, const char *type, struct dpif **);
#include "netdev.h"
#include "odp-util.h"
#include "shash.h"
-#include "svec.h"
+#include "sset.h"
#include "timeval.h"
#include "util.h"
#include "vlog.h"
}
}
} else {
- struct svec types;
+ struct sset types;
const char *type;
- size_t i;
- svec_init(&types);
+ sset_init(&types);
dp_enumerate_types(&types);
- SVEC_FOR_EACH (i, type, &types) {
- struct svec names;
+ SSET_FOR_EACH (type, &types) {
+ struct sset names;
const char *name;
- size_t j;
- svec_init(&names);
+ sset_init(&names);
if (dp_enumerate_names(type, &names)) {
failure = true;
continue;
}
- SVEC_FOR_EACH (j, name, &names) {
+ SSET_FOR_EACH (name, &names) {
struct dpif *dpif;
int error;
failure = true;
}
}
- svec_destroy(&names);
+ sset_destroy(&names);
}
- svec_destroy(&types);
+ sset_destroy(&types);
}
if (failure) {
exit(EXIT_FAILURE);
static void
do_dump_dps(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
{
- struct svec dpif_names, dpif_types;
- unsigned int i;
+ struct sset dpif_names, dpif_types;
+ const char *type;
int error = 0;
- svec_init(&dpif_names);
- svec_init(&dpif_types);
+ sset_init(&dpif_names);
+ sset_init(&dpif_types);
dp_enumerate_types(&dpif_types);
- for (i = 0; i < dpif_types.n; i++) {
- unsigned int j;
+ SSET_FOR_EACH (type, &dpif_types) {
+ const char *name;
int retval;
- retval = dp_enumerate_names(dpif_types.names[i], &dpif_names);
+ retval = dp_enumerate_names(type, &dpif_names);
if (retval) {
error = retval;
}
- for (j = 0; j < dpif_names.n; j++) {
+ SSET_FOR_EACH (name, &dpif_names) {
struct dpif *dpif;
- if (!dpif_open(dpif_names.names[j], dpif_types.names[i], &dpif)) {
+ if (!dpif_open(name, type, &dpif)) {
printf("%s\n", dpif_name(dpif));
dpif_close(dpif);
}
}
}
- svec_destroy(&dpif_names);
- svec_destroy(&dpif_types);
+ sset_destroy(&dpif_names);
+ sset_destroy(&dpif_types);
if (error) {
exit(EXIT_FAILURE);
}
{
static bool already_configured_once;
struct svec bridge_names;
- struct svec dpif_names, dpif_types;
+ struct sset dpif_names, dpif_types;
+ const char *type;
size_t i;
/* Only do this once per ovs-vswitchd run. */
/* Iterate over all system dpifs and delete any of them that do not appear
* in 'cfg'. */
- svec_init(&dpif_names);
- svec_init(&dpif_types);
+ sset_init(&dpif_names);
+ sset_init(&dpif_types);
dp_enumerate_types(&dpif_types);
- for (i = 0; i < dpif_types.n; i++) {
- size_t j;
+ SSET_FOR_EACH (type, &dpif_types) {
+ const char *name;
- dp_enumerate_names(dpif_types.names[i], &dpif_names);
+ dp_enumerate_names(type, &dpif_names);
/* Delete each dpif whose name is not in 'bridge_names'. */
- for (j = 0; j < dpif_names.n; j++) {
- if (!svec_contains(&bridge_names, dpif_names.names[j])) {
+ SSET_FOR_EACH (name, &dpif_names) {
+ if (!svec_contains(&bridge_names, name)) {
struct dpif *dpif;
int retval;
- retval = dpif_open(dpif_names.names[j], dpif_types.names[i],
- &dpif);
+ retval = dpif_open(name, type, &dpif);
if (!retval) {
dpif_delete(dpif);
dpif_close(dpif);
}
}
svec_destroy(&bridge_names);
- svec_destroy(&dpif_names);
- svec_destroy(&dpif_types);
+ sset_destroy(&dpif_names);
+ sset_destroy(&dpif_types);
}
/* Callback for iterate_and_prune_ifaces(). */