From: Andy Zhou Date: Wed, 8 Jul 2015 02:38:42 +0000 (-0700) Subject: db-ctl-base: do not require client to expose the "tables" variable X-Git-Tag: v2.5.0~942 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=802cb46ebc18fa33b33581e1e2b2ca8c6a53d0df db-ctl-base: do not require client to expose the "tables" variable Instead, client now pass it via the modified ctl_init() API. Signed-off-by: Andy Zhou Acked-by: Alex Wang --- diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 64c01e624..659820b06 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -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); } diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h index ecb3e80bc..684de11c3 100644 --- a/lib/db-ctl-base.h +++ b/lib/db-ctl-base.h @@ -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 *); diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 863bc73cd..8d62d5413 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -2262,7 +2262,7 @@ cmd_get_aa_mapping(struct ctl_context *ctx) } -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); } diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c index 7f455dffe..f065fc9ba 100644 --- a/vtep/vtep-ctl.c +++ b/vtep/vtep-ctl.c @@ -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); }