ofproto: Fix potential leak during flow mods.
[sliver-openvswitch.git] / vtep / vtep-ctl.c
index 7b904f6..0b9463a 100644 (file)
@@ -31,6 +31,7 @@
 #include "compiler.h"
 #include "dirs.h"
 #include "dynamic-string.h"
+#include "fatal-signal.h"
 #include "hash.h"
 #include "json.h"
 #include "ovsdb-data.h"
@@ -114,9 +115,6 @@ static int timeout;
 /* 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. */
@@ -154,6 +152,7 @@ static bool is_condition_satisfied(const struct vtep_ctl_table_class *,
 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[])
@@ -167,7 +166,7 @@ main(int argc, char *argv[])
     char *args;
 
     set_program_name(argv[0]);
-    signal(SIGPIPE, SIG_IGN);
+    fatal_ignore_sigpipe();
     vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
     vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_WARN);
     vteprec_init();
@@ -284,7 +283,7 @@ parse_options(int argc, char *argv[], struct shash *local_options)
     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;
@@ -369,6 +368,7 @@ parse_options(int argc, char *argv[], struct shash *local_options)
 
         case 'V':
             ovs_print_version(0, 0);
+            printf("DB Schema %s\n", vteprec_get_db_version());
             exit(EXIT_SUCCESS);
 
         case 't':
@@ -542,7 +542,7 @@ find_command(const 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);
         }
     }
@@ -3324,7 +3324,7 @@ post_create(struct vtep_ctl_context *ctx)
     struct uuid dummy;
 
     if (!uuid_from_string(&dummy, ds_cstr(&ctx->output))) {
-        NOT_REACHED();
+        OVS_NOT_REACHED();
     }
     real = ovsdb_idl_txn_get_insert_uuid(ctx->txn, &dummy);
     if (real) {
@@ -3441,7 +3441,7 @@ evaluate_relop(const struct ovsdb_datum *a, const struct ovsdb_datum *b,
         return ovsdb_datum_includes_all(b, a, type);
 
     default:
-        NOT_REACHED();
+        OVS_NOT_REACHED();
     }
 }
 
@@ -3739,7 +3739,7 @@ do_vtep_ctl(const char *args, struct vtep_ctl_command *commands,
     switch (status) {
     case TXN_UNCOMMITTED:
     case TXN_INCOMPLETE:
-        NOT_REACHED();
+        OVS_NOT_REACHED();
 
     case TXN_ABORTED:
         /* Should not happen--we never call ovsdb_idl_txn_abort(). */
@@ -3760,7 +3760,7 @@ do_vtep_ctl(const char *args, struct vtep_ctl_command *commands,
         vtep_ctl_fatal("database not locked");
 
     default:
-        NOT_REACHED();
+        OVS_NOT_REACHED();
     }
     free(error);
 
@@ -3888,3 +3888,8 @@ static const struct vtep_ctl_command_syntax all_commands[] = {
     {NULL, 0, 0, NULL, NULL, NULL, NULL, RO},
 };
 
+static const struct vtep_ctl_command_syntax *
+get_all_commands(void)
+{
+    return all_commands;
+}