/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
int
main(int argc, char *argv[])
{
- extern struct vlog_module VLM_reconnect;
struct ovsdb_idl *idl;
struct ctl_command *commands;
struct shash local_options;
set_program_name(argv[0]);
fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
- vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_WARN);
+ vlog_set_levels_from_string_assert("reconnect:warn");
ovsrec_init();
vsctl_cmd_init();
OPT_NO_SYSLOG,
OPT_NO_WAIT,
OPT_DRY_RUN,
+ OPT_BOOTSTRAP_CA_CERT,
OPT_PEER_CA_CERT,
OPT_LOCAL,
OPT_RETRY,
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},
};
break;
case OPT_NO_SYSLOG:
- vlog_set_levels(&VLM_vsctl, VLF_SYSLOG, VLL_WARN);
+ vlog_set_levels(&this_module, VLF_SYSLOG, VLL_WARN);
break;
case OPT_NO_WAIT:
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);
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)
{
{
}
-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
/* 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);
}
}
}
+static char *
+vsctl_parent_process_info(void)
+{
+#ifdef __linux__
+ pid_t parent_pid;
+ char *procfile;
+ struct ds s;
+ FILE *f;
+
+ parent_pid = getppid();
+ procfile = xasprintf("/proc/%d/cmdline", parent_pid);
+
+ f = fopen(procfile, "r");
+ if (!f) {
+ VLOG_WARN("%s: open failed (%s)", procfile, ovs_strerror(errno));
+ free(procfile);
+ return NULL;
+ }
+ free(procfile);
+
+ ds_init(&s);
+ for (;;) {
+ int c = getc(f);
+ if (!c || c == EOF) {
+ break;
+ }
+ ds_put_char(&s, c);
+ }
+ fclose(f);
+
+ ds_put_format(&s, " (pid %d)", parent_pid);
+
+ return ds_steal_cstr(&s);
+#else
+ return NULL;
+#endif
+}
+
static void
do_vsctl(const char *args, struct ctl_command *commands, size_t n_commands,
struct ovsdb_idl *idl)
struct shash_node *node;
int64_t next_cfg = 0;
char *error = NULL;
+ char *ppid_info = NULL;
txn = the_idl_txn = ovsdb_idl_txn_create(idl);
if (dry_run) {
ovsdb_idl_txn_set_dry_run(txn);
}
- ovsdb_idl_txn_add_comment(txn, "ovs-vsctl: %s", args);
+ ppid_info = vsctl_parent_process_info();
+ if (ppid_info) {
+ ovsdb_idl_txn_add_comment(txn, "ovs-vsctl (invoked by %s): %s",
+ ppid_info, args);
+ free(ppid_info);
+ } else {
+ ovsdb_idl_txn_add_comment(txn, "ovs-vsctl: %s", args);
+ }
ovs = ovsrec_open_vswitch_first(idl);
if (!ovs) {
static void
vsctl_cmd_init(void)
{
- ctl_init(tables, vsctl_exit);
+ ctl_init(tables, cmd_show_tables, vsctl_exit);
ctl_register_commands(vsctl_commands);
}