X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=utilities%2Fovs-vsctl.c;h=36290db79f5905afe3907b5acae6cba6d07499f6;hb=bf66c06797b0b03ec72582472d55d72e854eb435;hp=c71398e52a260ec4a92be02d3ff351f24e427901;hpb=2bb0bea82711750311974c291e98bec6fc0e077f;p=cascardo%2Fovs.git diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index c71398e52..36290db79 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -84,6 +84,14 @@ static bool retry; static struct table_style table_style = TABLE_STYLE_DEFAULT; static void vsctl_cmd_init(void); + +/* The IDL we're using and the current transaction, if any. + * This is for use by vsctl_exit() only, to allow it to clean up. + * Other code should use its context arguments. */ +static struct ovsdb_idl *the_idl; +static struct ovsdb_idl_txn *the_idl_txn; +OVS_NO_RETURN static void vsctl_exit(int status); + OVS_NO_RETURN static void usage(void); static void parse_options(int argc, char *argv[], struct shash *local_options); static void run_prerequisites(struct ctl_command[], size_t n_commands, @@ -193,6 +201,7 @@ parse_options(int argc, char *argv[], struct shash *local_options) OPT_NO_SYSLOG, OPT_NO_WAIT, OPT_DRY_RUN, + OPT_BOOTSTRAP_CA_CERT, OPT_PEER_CA_CERT, OPT_LOCAL, OPT_RETRY, @@ -216,6 +225,7 @@ parse_options(int argc, char *argv[], struct shash *local_options) VLOG_LONG_OPTIONS, TABLE_LONG_OPTIONS, STREAM_SSL_LONG_OPTIONS, + {"bootstrap-ca-cert", required_argument, NULL, OPT_BOOTSTRAP_CA_CERT}, {"peer-ca-cert", required_argument, NULL, OPT_PEER_CA_CERT}, {NULL, 0, NULL, 0}, }; @@ -316,6 +326,10 @@ parse_options(int argc, char *argv[], struct shash *local_options) stream_ssl_set_peer_ca_cert_file(optarg); break; + case OPT_BOOTSTRAP_CA_CERT: + stream_ssl_set_ca_cert_file(optarg, true); + break; + case '?': exit(EXIT_FAILURE); @@ -469,7 +483,7 @@ struct vsctl_iface { struct vsctl_port *port; }; -/* Casts 'base' into 'strcut vsctl_context'. */ +/* Casts 'base' into 'struct vsctl_context'. */ static struct vsctl_context * vsctl_context_cast(struct ctl_context *base) { @@ -967,50 +981,56 @@ cmd_init(struct ctl_context *ctx OVS_UNUSED) { } -struct cmd_show_table cmd_show_tables[] = { +static struct cmd_show_table cmd_show_tables[] = { {&ovsrec_table_open_vswitch, NULL, {&ovsrec_open_vswitch_col_manager_options, &ovsrec_open_vswitch_col_bridges, &ovsrec_open_vswitch_col_ovs_version}, - false}, + {NULL, NULL, NULL} + }, {&ovsrec_table_bridge, &ovsrec_bridge_col_name, {&ovsrec_bridge_col_controller, &ovsrec_bridge_col_fail_mode, &ovsrec_bridge_col_ports}, - false}, + {NULL, NULL, NULL} + }, {&ovsrec_table_port, &ovsrec_port_col_name, {&ovsrec_port_col_tag, &ovsrec_port_col_trunks, &ovsrec_port_col_interfaces}, - false}, + {NULL, NULL, NULL} + }, {&ovsrec_table_interface, &ovsrec_interface_col_name, {&ovsrec_interface_col_type, &ovsrec_interface_col_options, &ovsrec_interface_col_error}, - false}, + {NULL, NULL, NULL} + }, {&ovsrec_table_controller, &ovsrec_controller_col_target, {&ovsrec_controller_col_is_connected, NULL, NULL}, - false}, + {NULL, NULL, NULL} + }, {&ovsrec_table_manager, &ovsrec_manager_col_target, {&ovsrec_manager_col_is_connected, NULL, NULL}, - false}, + {NULL, NULL, NULL} + }, - {NULL, NULL, {NULL, NULL, NULL}, false} + {NULL, NULL, {NULL, NULL, NULL}, {NULL, NULL, NULL}} }; static void @@ -1071,10 +1091,8 @@ cmd_emer_reset(struct ctl_context *ctx) /* We only want to save the "hwaddr" key from other_config. */ hwaddr = smap_get(&br->other_config, "hwaddr"); if (hwaddr) { - struct smap smap = SMAP_INITIALIZER(&smap); - smap_add(&smap, "hwaddr", hwaddr); + const struct smap smap = SMAP_CONST1(&smap, "hwaddr", hwaddr); ovsrec_bridge_set_other_config(br, &smap); - smap_destroy(&smap); } else { ovsrec_bridge_set_other_config(br, NULL); } @@ -1340,7 +1358,7 @@ cmd_br_exists(struct ctl_context *ctx) vsctl_context_populate_cache(ctx); if (!find_bridge(vsctl_ctx, ctx->argv[1], false)) { - ctl_exit(2); + vsctl_exit(2); } } @@ -2645,6 +2663,23 @@ try_again: free(error); } +/* Frees the current transaction and the underlying IDL and then calls + * exit(status). + * + * Freeing the transaction and the IDL is not strictly necessary, but it makes + * for a clean memory leak report from valgrind in the normal case. That makes + * it easier to notice real memory leaks. */ +static void +vsctl_exit(int status) +{ + if (the_idl_txn) { + ovsdb_idl_txn_abort(the_idl_txn); + ovsdb_idl_txn_destroy(the_idl_txn); + } + ovsdb_idl_destroy(the_idl); + exit(status); +} + /* * Developers who add new commands to the 'struct ctl_command_syntax' must * define the 'arguments' member of the struct. The following keywords are @@ -2746,6 +2781,6 @@ static const struct ctl_command_syntax vsctl_commands[] = { static void vsctl_cmd_init(void) { - ctl_init(tables); + ctl_init(tables, cmd_show_tables, vsctl_exit); ctl_register_commands(vsctl_commands); }