From: Ben Pfaff Date: Tue, 1 Mar 2011 21:11:56 +0000 (-0800) Subject: ovsdb-data: Expose guts of ovsdb_symbol_table() to clients. X-Git-Tag: v1.1.0~163 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0dc66db95bdceeaac2e32b581d2494fd773b17ae;hp=e9387de4a2601ed2768baaa9bc92a3ef27f1145a;p=sliver-openvswitch.git ovsdb-data: Expose guts of ovsdb_symbol_table() to clients. ovs-vsctl will, in upcoming commits, want to more closely examine its ovsdb_symbol_table structures. This could be done by providing a more complete API, but it doesn't seem worth it to me. This commit instead goes the other way, exposing the internals to clients. This commit also eliminates the ovsdb_symbol_table_find_uncreated() function, which ovs-vsctl can now implement itself. --- diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index c141e86ea..ac9486413 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -1795,10 +1795,6 @@ ovsdb_datum_subtract(struct ovsdb_datum *a, const struct ovsdb_type *a_type, } } -struct ovsdb_symbol_table { - struct shash sh; -}; - struct ovsdb_symbol_table * ovsdb_symbol_table_create(void) { @@ -1852,21 +1848,6 @@ ovsdb_symbol_table_insert(struct ovsdb_symbol_table *symtab, } return symbol; } - -const char * -ovsdb_symbol_table_find_uncreated(const struct ovsdb_symbol_table *symtab) -{ - struct shash_node *node; - - SHASH_FOR_EACH (node, &symtab->sh) { - struct ovsdb_symbol *symbol = node->data; - if (!symbol->created) { - return node->name; - } - } - - return NULL; -} /* Extracts a token from the beginning of 's' and returns a pointer just after * the token. Stores the token itself into '*outp', which the caller is diff --git a/lib/ovsdb-data.h b/lib/ovsdb-data.h index fe279bcfd..fe71f9084 100644 --- a/lib/ovsdb-data.h +++ b/lib/ovsdb-data.h @@ -19,10 +19,10 @@ #include #include "compiler.h" #include "ovsdb-types.h" +#include "shash.h" struct ds; struct ovsdb_symbol_table; -struct shash; /* One value of an atomic type (given by enum ovs_atomic_type). */ union ovsdb_atom { @@ -229,6 +229,10 @@ ovsdb_datum_conforms_to_type(const struct ovsdb_datum *datum, /* A table mapping from names to data items. Currently the data items are * always UUIDs; perhaps this will be expanded in the future. */ +struct ovsdb_symbol_table { + struct shash sh; /* Maps from name to struct ovsdb_symbol *. */ +}; + struct ovsdb_symbol { struct uuid uuid; /* The UUID that the symbol represents. */ bool created; /* Already used to create row? */ @@ -243,8 +247,6 @@ struct ovsdb_symbol *ovsdb_symbol_table_put(struct ovsdb_symbol_table *, const struct uuid *, bool used); struct ovsdb_symbol *ovsdb_symbol_table_insert(struct ovsdb_symbol_table *, const char *name); -const char *ovsdb_symbol_table_find_uncreated( - const struct ovsdb_symbol_table *); /* Tokenization * diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 2818a38f7..e5e03f738 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -3354,8 +3354,8 @@ do_vsctl(const char *args, struct vsctl_command *commands, size_t n_commands, const struct ovsrec_open_vswitch *ovs; enum ovsdb_idl_txn_status status; struct ovsdb_symbol_table *symtab; - const char *uncreated; struct vsctl_command *c; + struct shash_node *node; int64_t next_cfg = 0; char *error = NULL; @@ -3395,10 +3395,13 @@ do_vsctl(const char *args, struct vsctl_command *commands, size_t n_commands, } } - uncreated = ovsdb_symbol_table_find_uncreated(symtab); - if (uncreated) { - vsctl_fatal("row id \"%s\" is referenced but never created (e.g. " - "with \"-- --id=%s create ...\")", uncreated, uncreated); + SHASH_FOR_EACH (node, &symtab->sh) { + struct ovsdb_symbol *symbol = node->data; + if (!symbol->created) { + vsctl_fatal("row id \"%s\" is referenced but never created (e.g. " + "with \"-- --id=%s create ...\")", + node->name, node->name); + } } status = ovsdb_idl_txn_commit_block(txn);