/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2014, 2015, 2016 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2014, 2015, 2016, 2017 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "openvswitch/json.h"
#include "ovsdb-data.h"
#include "ovsdb-idl.h"
-#include "poll-loop.h"
+#include "openvswitch/poll-loop.h"
#include "process.h"
#include "stream.h"
#include "stream-ssl.h"
static void parse_options(int argc, char *argv[], struct shash *local_options);
static void run_prerequisites(struct ctl_command[], size_t n_commands,
struct ovsdb_idl *);
-static void do_vtep_ctl(const char *args, struct ctl_command *, size_t n,
+static bool do_vtep_ctl(const char *args, struct ctl_command *, size_t n,
struct ovsdb_idl *);
static struct vtep_ctl_lswitch *find_lswitch(struct vtep_ctl_context *,
const char *name,
struct shash local_options;
unsigned int seqno;
size_t n_commands;
- char *args;
set_program_name(argv[0]);
fatal_ignore_sigpipe();
vtep_ctl_cmd_init();
- /* Log our arguments. This is often valuable for debugging systems. */
- args = process_escape_args(argv);
- VLOG(ctl_might_write_to_db(argv) ? VLL_INFO : VLL_DBG, "Called as %s", args);
-
/* Parse command line. */
+ char *args = process_escape_args(argv);
shash_init(&local_options);
parse_options(argc, argv, &local_options);
commands = ctl_parse_commands(argc - optind, argv + optind, &local_options,
&n_commands);
+ VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG,
+ "Called as %s", args);
if (timeout) {
time_alarm(timeout);
if (seqno != ovsdb_idl_get_seqno(idl)) {
seqno = ovsdb_idl_get_seqno(idl);
- do_vtep_ctl(args, commands, n_commands, idl);
+ if (do_vtep_ctl(args, commands, n_commands, idl)) {
+ free(args);
+ exit(EXIT_SUCCESS);
+ }
}
if (seqno == ovsdb_idl_get_seqno(idl)) {
Manager commands:\n\
get-manager print the managers\n\
del-manager delete the managers\n\
+ [--inactivity-probe=MSECS]\n\
set-manager TARGET... set the list of managers to TARGET...\n\
\n\
Physical Switch commands:\n\
list-remote-macs LS list remote mac entries\n\
\n\
%s\
+%s\
\n\
Options:\n\
--db=DATABASE connect to DATABASE\n\
-t, --timeout=SECS wait at most SECS seconds\n\
--dry-run do not commit changes to database\n\
--oneline print exactly one line of output per command\n",
- program_name, program_name, ctl_get_db_cmd_usage(), ctl_default_db());
+ program_name, program_name, ctl_get_db_cmd_usage(),
+ ctl_list_db_tables_usage(), ctl_default_db());
+ table_usage();
vlog_usage();
printf("\
--no-syslog equivalent to --verbose=vtep_ctl:syslog:warn\n");
ovs_list_remove(&port->ports_node);
shash_find_and_delete(&vtepctl_ctx->ports, cache_name);
vteprec_physical_port_delete(port->port_cfg);
+ shash_destroy(&port->bindings);
free(cache_name);
free(port);
}
port = add_port_to_cache(vtepctl_ctx, ps, port_cfg);
for (k = 0; k < port_cfg->n_vlan_bindings; k++) {
- struct vteprec_logical_switch *ls_cfg;
struct vtep_ctl_lswitch *ls;
char *vlan;
{
ovsdb_idl_add_column(ctx->idl, &vteprec_global_col_managers);
ovsdb_idl_add_column(ctx->idl, &vteprec_manager_col_target);
+ ovsdb_idl_add_column(ctx->idl, &vteprec_manager_col_inactivity_probe);
}
static void
}
static void
-insert_managers(struct vtep_ctl_context *vtepctl_ctx, char *targets[], size_t n)
+insert_managers(struct vtep_ctl_context *vtepctl_ctx, char *targets[],
+ size_t n, struct shash *options)
{
struct vteprec_manager **managers;
size_t i;
+ const char *inactivity_probe = shash_find_data(options,
+ "--inactivity-probe");
/* Insert each manager in a new row in Manager table. */
managers = xmalloc(n * sizeof *managers);
}
managers[i] = vteprec_manager_insert(vtepctl_ctx->base.txn);
vteprec_manager_set_target(managers[i], targets[i]);
+ if (inactivity_probe) {
+ int64_t msecs = atoll(inactivity_probe);
+ vteprec_manager_set_inactivity_probe(managers[i], &msecs, 1);
+ }
}
/* Store uuids of new Manager rows in 'managers' column. */
verify_managers(vtepctl_ctx->vtep_global);
delete_managers(vtepctl_ctx);
- insert_managers(vtepctl_ctx, &ctx->argv[1], n);
+ insert_managers(vtepctl_ctx, &ctx->argv[1], n, &ctx->options);
}
/* Parameter commands. */
-static const struct ctl_table_class tables[] = {
- {&vteprec_table_global,
- {{&vteprec_table_global, NULL, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_logical_binding_stats,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_logical_switch,
- {{&vteprec_table_logical_switch, &vteprec_logical_switch_col_name, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_ucast_macs_local,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_ucast_macs_remote,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_mcast_macs_local,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_mcast_macs_remote,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
+static const struct ctl_table_class tables[VTEPREC_N_TABLES] = {
+ [VTEPREC_TABLE_LOGICAL_SWITCH].row_ids[0]
+ = {&vteprec_logical_switch_col_name, NULL, NULL},
- {&vteprec_table_manager,
- {{&vteprec_table_manager, &vteprec_manager_col_target, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_physical_locator,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_physical_locator_set,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_physical_port,
- {{&vteprec_table_physical_port, &vteprec_physical_port_col_name, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_physical_switch,
- {{&vteprec_table_physical_switch, &vteprec_physical_switch_col_name, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_tunnel,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
-
- {&vteprec_table_logical_router,
- {{&vteprec_table_logical_router, &vteprec_logical_router_col_name, NULL},
- {NULL, NULL, NULL}}},
+ [VTEPREC_TABLE_MANAGER].row_ids[0]
+ = {&vteprec_manager_col_target, NULL, NULL},
- {&vteprec_table_arp_sources_local,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
+ [VTEPREC_TABLE_PHYSICAL_PORT].row_ids[0]
+ = {&vteprec_physical_port_col_name, NULL, NULL},
- {&vteprec_table_arp_sources_remote,
- {{NULL, NULL, NULL},
- {NULL, NULL, NULL}}},
+ [VTEPREC_TABLE_PHYSICAL_SWITCH].row_ids[0]
+ = {&vteprec_physical_switch_col_name, NULL, NULL},
- {NULL, {{NULL, NULL, NULL}, {NULL, NULL, NULL}}}
+ [VTEPREC_TABLE_LOGICAL_ROUTER].row_ids[0]
+ = {&vteprec_logical_router_col_name, NULL, NULL},
};
\f
}
}
-static void
+static bool
do_vtep_ctl(const char *args, struct ctl_command *commands,
size_t n_commands, struct ovsdb_idl *idl)
{
ovsdb_idl_destroy(idl);
- exit(EXIT_SUCCESS);
+ return true;
try_again:
/* Our transaction needs to be rerun, or a prerequisite was not met. Free
free(c->table);
}
free(error);
+ return false;
}
static const struct ctl_command_syntax vtep_commands[] = {
/* Manager commands. */
{"get-manager", 0, 0, NULL, pre_manager, cmd_get_manager, NULL, "", RO},
{"del-manager", 0, 0, NULL, pre_manager, cmd_del_manager, NULL, "", RW},
- {"set-manager", 1, INT_MAX, NULL, pre_manager, cmd_set_manager, NULL, "",
- RW},
+ {"set-manager", 1, INT_MAX, NULL, pre_manager, cmd_set_manager, NULL,
+ "--inactivity-probe=", RW},
{NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, RO},
};
static void
vtep_ctl_cmd_init(void)
{
- ctl_init(tables, cmd_show_tables, vtep_ctl_exit);
+ ctl_init(&vteprec_idl_class, vteprec_table_classes, tables,
+ cmd_show_tables, vtep_ctl_exit);
ctl_register_commands(vtep_commands);
}