/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2014 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 "smap.h"
#include "sset.h"
#include "svec.h"
-#include "lib/vtep-idl.h"
+#include "vtep/vtep-idl.h"
#include "table.h"
#include "timeval.h"
#include "util.h"
-#include "vconn.h"
-#include "vlog.h"
+#include "openvswitch/vconn.h"
+#include "openvswitch/vlog.h"
VLOG_DEFINE_THIS_MODULE(vtep_ctl);
/* Format for table output. */
static struct table_style table_style = TABLE_STYLE_DEFAULT;
-/* All supported commands. */
-static const struct vtep_ctl_command_syntax all_commands[];
-
/* The IDL we're using and the current transaction, if any.
* This is for use by vtep_ctl_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;
-static void vtep_ctl_exit(int status) NO_RETURN;
-static void vtep_ctl_fatal(const char *, ...) PRINTF_FORMAT(1, 2) NO_RETURN;
+OVS_NO_RETURN static void vtep_ctl_exit(int status);
+OVS_NO_RETURN static void vtep_ctl_fatal(const char *, ...) OVS_PRINTF_FORMAT(1, 2);
static char *default_db(void);
-static void usage(void) NO_RETURN;
+OVS_NO_RETURN static void usage(void);
static void parse_options(int argc, char *argv[], struct shash *local_options);
static bool might_write_to_db(char **argv);
static struct vtep_ctl_lswitch *find_lswitch(struct vtep_ctl_context *,
const char *name,
bool must_exist);
+static const struct vtep_ctl_command_syntax *get_all_commands(void);
int
main(int argc, char *argv[])
set_program_name(argv[0]);
fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
- vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_WARN);
+ vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_WARN);
vteprec_init();
/* Log our arguments. This is often valuable for debugging systems. */
size_t n_options;
size_t i;
- tmp = long_options_to_short_options(global_long_options);
+ tmp = ovs_cmdl_long_options_to_short_options(global_long_options);
short_options = xasprintf("+%s", tmp);
free(tmp);
options = xmemdup(global_long_options, sizeof global_long_options);
allocated_options = ARRAY_SIZE(global_long_options);
n_options = n_global_long_options;
- for (p = all_commands; p->name; p++) {
+ for (p = get_all_commands(); p->name; p++) {
if (p->options[0]) {
char *save_ptr = NULL;
char *name;
if (shash_is_empty(&commands)) {
const struct vtep_ctl_command_syntax *p;
- for (p = all_commands; p->name; p++) {
+ for (p = get_all_commands(); p->name; p++) {
shash_add_assert(&commands, p->name, p);
}
}
struct vtep_ctl_pswitch {
const struct vteprec_physical_switch *ps_cfg;
char *name;
- struct list ports; /* Contains "struct vteprec_physical_port"s. */
+ struct ovs_list ports; /* Contains "struct vteprec_physical_port"s. */
};
struct vtep_ctl_port {
- struct list ports_node; /* In struct vtep_ctl_pswitch's 'ports' list. */
+ struct ovs_list ports_node; /* In struct vtep_ctl_pswitch's 'ports' list. */
const struct vteprec_physical_port *port_cfg;
struct vtep_ctl_pswitch *ps;
struct shash bindings; /* Maps from vlan to vtep_ctl_lswitch. */
const struct vteprec_mcast_macs_remote *remote_cfg;
const struct vteprec_physical_locator_set *ploc_set_cfg;
- struct list locators; /* Contains 'vtep_ctl_ploc's. */
+ struct ovs_list locators; /* Contains 'vtep_ctl_ploc's. */
};
struct vtep_ctl_ploc {
- struct list locators_node; /* In struct vtep_ctl_ploc_set's 'locators'
- list. */
+ struct ovs_list locators_node; /* In struct vtep_ctl_ploc_set's 'locators'
+ list. */
const struct vteprec_physical_locator *ploc_cfg;
};
ovsdb_idl_add_column(ctx->idl, &vteprec_physical_switch_col_name);
ovsdb_idl_add_column(ctx->idl, &vteprec_physical_switch_col_ports);
+ ovsdb_idl_add_column(ctx->idl, &vteprec_physical_switch_col_tunnels);
ovsdb_idl_add_column(ctx->idl, &vteprec_physical_port_col_name);
ovsdb_idl_add_column(ctx->idl, &vteprec_physical_port_col_vlan_bindings);
&vteprec_physical_locator_col_dst_ip);
ovsdb_idl_add_column(ctx->idl,
&vteprec_physical_locator_col_encapsulation_type);
+
+ ovsdb_idl_add_column(ctx->idl, &vteprec_tunnel_col_local);
+ ovsdb_idl_add_column(ctx->idl, &vteprec_tunnel_col_remote);
}
static void
const struct vteprec_ucast_macs_remote *ucast_remote_cfg;
const struct vteprec_mcast_macs_local *mcast_local_cfg;
const struct vteprec_mcast_macs_remote *mcast_remote_cfg;
+ const struct vteprec_tunnel *tunnel_cfg;
struct sset pswitches, ports, lswitches;
size_t i;
mcast_mac->remote_cfg = mcast_remote_cfg;
}
+ VTEPREC_TUNNEL_FOR_EACH (tunnel_cfg, ctx->idl) {
+ if (tunnel_cfg->local) {
+ add_ploc_to_cache(ctx, tunnel_cfg->local);
+ }
+ if (tunnel_cfg->remote) {
+ add_ploc_to_cache(ctx, tunnel_cfg->remote);
+ }
+ }
+
sset_init(&pswitches);
for (i = 0; i < vtep_global->n_switches; i++) {
struct vteprec_physical_switch *ps_cfg = vtep_global->switches[i];
{{&vteprec_table_physical_switch, &vteprec_physical_switch_col_name, NULL},
{NULL, NULL, NULL}}},
+ {&vteprec_table_tunnel,
+ {{NULL, NULL, NULL},
+ {NULL, NULL, NULL}}},
+
{NULL, {{NULL, NULL, NULL}, {NULL, NULL, NULL}}}
};
*
* On success, returns NULL. On failure, returned a malloc()'d string error
* message and stores NULL into all of the nonnull output arguments. */
-static char * WARN_UNUSED_RESULT
+static char * OVS_WARN_UNUSED_RESULT
parse_column_key_value(const char *arg,
const struct vtep_ctl_table_class *table,
const struct ovsdb_idl_column **columnp, char **keyp,
error = ovsdb_datum_from_string(&rm, &rm_type,
ctx->argv[i], ctx->symtab);
if (error && ovsdb_type_is_map(&rm_type)) {
- free(error);
rm_type.value.type = OVSDB_TYPE_VOID;
die_if_error(ovsdb_datum_from_string(&rm, &rm_type,
ctx->argv[i], ctx->symtab));
}
+ free(error);
ovsdb_datum_subtract(&old, type, &rm, &rm_type);
ovsdb_datum_destroy(&rm, &rm_type);
}
{NULL, 0, 0, NULL, NULL, NULL, NULL, RO},
};
+static const struct vtep_ctl_command_syntax *
+get_all_commands(void)
+{
+ return all_commands;
+}