On Mon, Aug 15, 2016 at 06:47:29PM +0000, Ryan Moats wrote: > ovs-dpctl and ovs-ofctl lack a read-only option to prevent > running of commands that perform read-write operations. Add > it and the necessary scaffolding to each. > > Signed-off-by: Ryan Moats <rmo...@us.ibm.com>
I folded in a few changes, see below, and applied this to master. --8<--------------------------cut here-------------------------->8-- diff --git a/lib/command-line.c b/lib/command-line.c index 92ce888..8128331 100644 --- a/lib/command-line.c +++ b/lib/command-line.c @@ -87,11 +87,10 @@ ovs_cmdl_print_options(const struct option options[]) ds_destroy(&ds); } -/* Whether to commit changes or not. */ -static bool read_only; - static void -_ovs_cmdl_run_command(struct ovs_cmdl_context *ctx, const struct ovs_cmdl_command commands[]) +ovs_cmdl_run_command__(struct ovs_cmdl_context *ctx, + const struct ovs_cmdl_command commands[], + bool read_only) { const struct ovs_cmdl_command *p; @@ -144,16 +143,14 @@ void ovs_cmdl_run_command(struct ovs_cmdl_context *ctx, const struct ovs_cmdl_command commands[]) { - read_only = false; - _ovs_cmdl_run_command(ctx, commands); + ovs_cmdl_run_command__(ctx, commands, false); } void ovs_cmdl_run_command_read_only(struct ovs_cmdl_context *ctx, const struct ovs_cmdl_command commands[]) { - read_only = true; - _ovs_cmdl_run_command(ctx, commands); + ovs_cmdl_run_command__(ctx, commands, true); } /* Process title. */ diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c index c123e43..35b70e9 100644 --- a/tests/test-ovsdb.c +++ b/tests/test-ovsdb.c @@ -2720,7 +2720,7 @@ static struct ovs_cmdl_command all_commands[] = { { "log-io", NULL, 2, INT_MAX, do_log_io, OVS_RO }, { "default-atoms", NULL, 0, 0, do_default_atoms, OVS_RO }, { "default-data", NULL, 0, 0, do_default_data, OVS_RO }, - { "diff-data", NULL, 3, INT_MAX, do_diff_data}, + { "diff-data", NULL, 3, INT_MAX, do_diff_data, OVS_RO }, { "parse-atomic-type", NULL, 1, 1, do_parse_atomic_type, OVS_RO }, { "parse-base-type", NULL, 1, 1, do_parse_base_type, OVS_RO }, { "parse-type", NULL, 1, 1, do_parse_type, OVS_RO }, _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev