These utilities logged the command very early, before parsing the options or the command. This meant that logging options (like --log-file or -vsyslog:off) weren't considered for the purpose of logging the command. This fixes the problem.
Signed-off-by: Ben Pfaff <[email protected]> --- lib/db-ctl-base.c | 8 +++----- lib/db-ctl-base.h | 2 +- ovn/utilities/ovn-nbctl.c | 9 +++------ ovn/utilities/ovn-sbctl.c | 8 +++----- utilities/ovs-vsctl.c | 8 +++----- vtep/vtep-ctl.c | 8 +++----- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index bfd7a54a8b5a..4e31e9a0a358 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -2046,12 +2046,10 @@ ctl_default_db(void) * database, otherwise false. (Not very smart, so it's prone to false * positives.) */ bool -ctl_might_write_to_db(char **argv) +ctl_might_write_to_db(const struct ctl_command *commands, size_t n) { - for (; *argv; argv++) { - const struct ctl_command_syntax *p = shash_find_data(&all_commands, - *argv); - if (p && p->mode == RW) { + for (size_t i = 0; i < n; i++) { + if (commands[i].syntax->mode == RW) { return true; } } diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h index d8c4db2c6b3c..f246505325a4 100644 --- a/lib/db-ctl-base.h +++ b/lib/db-ctl-base.h @@ -155,7 +155,7 @@ struct ctl_command { struct table *table; }; -bool ctl_might_write_to_db(char **argv); +bool ctl_might_write_to_db(const struct ctl_command *, size_t n); const char *ctl_get_db_cmd_usage(void); const char *ctl_list_db_tables_usage(void); diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 6f133772d222..10ead0fc5ffd 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -97,7 +97,6 @@ main(int argc, char *argv[]) struct shash local_options; unsigned int seqno; size_t n_commands; - char *args; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -106,16 +105,14 @@ main(int argc, char *argv[]) nbctl_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); diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c index 9576119445bc..cfbe57313df9 100644 --- a/ovn/utilities/ovn-sbctl.c +++ b/ovn/utilities/ovn-sbctl.c @@ -100,7 +100,6 @@ main(int argc, char *argv[]) struct shash local_options; unsigned int seqno; size_t n_commands; - char *args; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -109,15 +108,14 @@ main(int argc, char *argv[]) sbctl_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); diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 6933266c5a39..3dd74a186ae0 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -136,7 +136,6 @@ main(int argc, char *argv[]) struct shash local_options; unsigned int seqno; size_t n_commands; - char *args; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -145,15 +144,14 @@ main(int argc, char *argv[]) vsctl_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); diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c index 0ae7d4621e60..c89ec503453c 100644 --- a/vtep/vtep-ctl.c +++ b/vtep/vtep-ctl.c @@ -99,7 +99,6 @@ main(int argc, char *argv[]) struct shash local_options; unsigned int seqno; size_t n_commands; - char *args; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -108,15 +107,14 @@ main(int argc, char *argv[]) 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); -- 2.16.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
