db-ctl-base: do not require client to expose the "tables" variable
authorAndy Zhou <azhou@nicira.com>
Wed, 8 Jul 2015 02:38:42 +0000 (19:38 -0700)
committerAndy Zhou <azhou@nicira.com>
Mon, 13 Jul 2015 07:40:59 +0000 (00:40 -0700)
Instead, client now pass it via the modified ctl_init() API.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
lib/db-ctl-base.c
lib/db-ctl-base.h
utilities/ovs-vsctl.c
vtep/vtep-ctl.c

index 64c01e6..659820b 100644 (file)
@@ -46,6 +46,11 @@ VLOG_DEFINE_THIS_MODULE(db_ctl_base);
 struct ovsdb_idl *the_idl;
 struct ovsdb_idl_txn *the_idl_txn;
 
+/* Represents all tables in the schema.  User must define 'tables'
+ * in implementation and supply via clt_init().  The definition must end
+ * with an all-NULL entry. */
+static const struct ctl_table_class *tables;
+
 static struct shash all_commands = SHASH_INITIALIZER(&all_commands);
 static const struct ctl_table_class *get_table(const char *table_name);
 static void set_column(const struct ctl_table_class *,
@@ -1908,8 +1913,9 @@ ctl_register_commands(const struct ctl_command_syntax *commands)
 
 /* Registers the 'db_ctl_commands' to 'all_commands'. */
 void
-ctl_init(void)
+ctl_init(const struct ctl_table_class tables_[])
 {
+    tables = tables_;
     ctl_register_commands(db_ctl_commands);
     ctl_register_commands(db_ctl_show_command);
 }
index ecb3e80..684de11 100644 (file)
@@ -43,9 +43,6 @@ struct table;
  * - the *ctl command context by inheriting the 'struct ctl_context' for
  *   additional commands implemented by user.  (See 'struct ctl_context' for
  *   more info)
- *
- * - the 'tables[]' for each table in the schema.
- *
 */
 
 /* ctl_fatal() also logs the error, so it is preferred in this file. */
@@ -56,7 +53,8 @@ struct table;
 extern struct ovsdb_idl *the_idl;
 extern struct ovsdb_idl_txn *the_idl_txn;
 
-void ctl_init(void);
+struct ctl_table_class;
+void ctl_init(const struct ctl_table_class *tables);
 char *ctl_default_db(void);
 OVS_NO_RETURN void ctl_exit(int status);
 OVS_NO_RETURN void ctl_fatal(const char *, ...) OVS_PRINTF_FORMAT(1, 2);
@@ -245,11 +243,6 @@ struct ctl_table_class {
     struct ctl_row_id row_ids[2];
 };
 
-/* Represents all tables in the schema.  User must define 'tables'
- * in implementation.  And the definition must end with an all-NULL
- * entry. */
-extern const struct ctl_table_class tables[];
-
 void ctl_set_column(const char *table_name,
                     const struct ovsdb_idl_row *, const char *arg,
                     struct ovsdb_symbol_table *);
index 863bc73..8d62d54 100644 (file)
@@ -2262,7 +2262,7 @@ cmd_get_aa_mapping(struct ctl_context *ctx)
 }
 
 \f
-const struct ctl_table_class tables[] = {
+static const struct ctl_table_class tables[] = {
     {&ovsrec_table_bridge,
      {{&ovsrec_table_bridge, &ovsrec_bridge_col_name, NULL},
       {&ovsrec_table_flow_sample_collector_set, NULL,
@@ -2749,6 +2749,6 @@ static const struct ctl_command_syntax vsctl_commands[] = {
 static void
 vsctl_cmd_init(void)
 {
-    ctl_init();
+    ctl_init(tables);
     ctl_register_commands(vsctl_commands);
 }
index 7f455df..f065fc9 100644 (file)
@@ -1962,7 +1962,7 @@ cmd_set_manager(struct ctl_context *ctx)
 }
 
 /* Parameter commands. */
-const struct ctl_table_class tables[] = {
+static const struct ctl_table_class tables[] = {
     {&vteprec_table_global,
      {{&vteprec_table_global, NULL, NULL},
       {NULL, NULL, NULL}}},
@@ -2310,6 +2310,6 @@ static const struct ctl_command_syntax vtep_commands[] = {
 static void
 vtep_ctl_cmd_init(void)
 {
-    ctl_init();
+    ctl_init(tables);
     ctl_register_commands(vtep_commands);
 }