summaryrefslogtreecommitdiff
path: root/lib/db-ctl-base.c
Commit message (Collapse)AuthorAgeFilesLines
* ovsdb-idl: Avoid class declaration.Joe Stringer2017-08-151-2/+2
| | | | | | | | | | In C++, 'class' is a keyword. If this is used as the name for a field, then C++ compilers can get confused about the context and fail to compile references to such fields. Rename the field to 'class_' to avoid this issue. Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* Eliminate most shadowing for local variable names.Ben Pfaff2017-08-021-2/+2
| | | | | | | | | | | | | | Shadowing is when a variable with a given name in an inner scope hides a different variable with the same name in a surrounding scope. This is generally undesirable because it can confuse programmers. This commit eliminates most of it. Found with -Wshadow=local in GCC 7. The repo is not really ready to enable this option by default because of a few cases that are harder to fix, and harmless, such as nested use of CMAP_FOR_EACH. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Fix reference-following feature in get_row_by_id().ZhiPeng Lu2017-07-131-0/+2
| | | | | | | | | | | | | | | | | If a particular column is supposed to be reached by following a reference from a UUID column, then that really needs to happen; if there's no reference, then we're probably starting from a row in the wrong table. This fixes an assertion failure in command "ovs-vsctl list netflow br0", if bridge br0 without any netflows. $ovs-vsctl list netflow br0 ovs-vsctl: lib/ovsdb-idl.c:2407: assertion column_idx < class->n_columns failed in ovsdb_idl_read() Aborted Fixes: 3f5b5f7b4115 ("db-ctl-base: Always support all tables in schema.") Signed-off-by: Zhipeng Lu <lu.zhipeng@zte.com.cn> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovn-sbctl: Add --ovs option to "lflow-list", for listing OpenFlow flows.Ben Pfaff2017-05-031-12/+7
| | | | | | | | This is like the --ovs option to ovn-trace, but it applies to every flow dumped, so it has different applications. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovn-sbctl: Get rid of redundant code by using function from db-ctl-base.Ben Pfaff2017-05-031-12/+12
| | | | | | | | | This renames get_row() to ctl_get_row() and makes it public. It's unfortunate that it adds a cast, but getting rid of redundant code seems worth it to me. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Allow abbreviating UUIDs embedded in strings.Ben Pfaff2017-05-031-3/+25
| | | | | | | | This allows commands like "ovn-sbctl lflow-list abcdef" to find a datapath that has external-ids:logical-switch=abcdef12-3456-... Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Add support for identifying a row based on a value in a map.Ben Pfaff2017-05-031-16/+42
| | | | | | | | | This will be used in an upcoming commit to allow Datapath_Binding records in the OVN southbound database to be identified based on external-ids:name and other map values. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Drop redundant 'table' field from struct ctl_row_id.Ben Pfaff2017-05-031-6/+6
| | | | | | | | | | The 'table' field is redundant because the required 'column' field implies the table that the column is a part of. This simplifies the users and makes it harder to get these things wrong. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* uuid: New function uuid_is_partial_match().Ben Pfaff2017-05-031-9/+1
| | | | | | | | This will have another caller in an upcoming commit. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* uuid: Change semantics of uuid_is_partial_string().Ben Pfaff2017-05-031-3/+1
| | | | | | | | | | | | | | | | | | | | Until now, uuid_is_partial_string() returned the number of characters at the beginning of a string that were the beginning of a valid UUID. This is useful, but all of the callers actually wanted to get a value of 0 if the string contained a character that was invalid for a UUID. This makes that change. Examples: "123" previously yielded 3 and still does. "xyzzy" previously yielded 0 and still does. "123xyzzy" previously yielded 3, now yields 0. "e66250bb-9531-491b-b9c3-5385cabb0080" previously yielded 36, still does. "e66250bb-9531-491b-b9c3-5385cabb0080xyzzy" previously yielded 36, now 0. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* db-ctl-base: Allow record UUIDs to be abbreviated.Ben Pfaff2017-04-301-0/+28
| | | | | | | | This makes it easier to type ovs-vsctl, ovn-sbctl, ovn-nbctl, and vtep-ctl commands without cut-and-paste. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Always support all tables in schema.Ben Pfaff2017-01-131-126/+126
| | | | | | | | | | | | | | | | | When one adds a new table to a database schema, it's easy to forget to add the table to the list of tables in the *ctl.c program. When this happens, the database commands for that program don't work on that table at all, even for commands like "list" and "create" that don't need any special help. This patch fixes that problem, by making sure that db-ctl-base always has the complete list of tables. Previously, each ctl_table_class pointed directly to the corresponding ovsdb_idl_table_class. With this patch, there are instead two parallel arrays, one of ovsdb_idl_table_classes and the other of ctl_table_classes. This change accounts for the bulk of the change to the db-ctl-base code. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Lance Richardson <lrichard@redhat.com>
* ovsdb-data: Add support for integer ranges in database commandsLukasz Rzasik2017-01-051-5/+5
| | | | | | | | | | | | | | | | Adding / removing a range of integers to a column accepting a set of integers requires enumarating all of the integers. This patch simplifies it by introducing 'range' concept to the database commands. Two integers separated by a hyphen represent an inclusive range. The patch adds positive and negative tests for the new syntax. The patch was tested by 'make check'. Covarage was tested by 'make check-lcov'. Signed-off-by: Lukasz Rzasik <lukasz.rzasik@gmail.com> Suggested-by: <my_ovs_discuss@yahoo.com> Suggested-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-2/+2
| | | | | | | | | | | | | | | To easily allow both in- and out-of-tree building of the Python wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to include/openvswitch. This also requires moving lib/{hmap,shash}.h. Both hmap.h and shash.h were #include-ing "util.h" even though the headers themselves did not use anything from there, but rather from include/openvswitch/util.h. Fixing that required including util.h in several C files mostly due to OVS_NOT_REACHED and things like xmalloc. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-vsctl: Support identifying Flow_Sample_Collector_Set records by id.Ben Pfaff2016-06-131-11/+24
| | | | | | | | | | This allows commands like ovs-vsctl list Flow_Sample_Collector_Set 123 if there's a record with id 123. It's not perfect, since there can be more than one record with the same id, but it's helpful. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Fix a typo.Russell Bryant2016-03-211-1/+1
| | | | | Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* Move lib/dynamic-string.h to include/openvswitch directoryBen Warren2016-03-191-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* vlog: Make the most common module reference more direct.Ben Pfaff2016-02-101-1/+1
| | | | | | | | | | | | | Most vlog calls are for the log module owned by the translation unit being compiled, but this module was referenced indirectly through a pointer variable. That seems silly, so this commit changes the code so that the local vlog module is referred to directly, as &this_module. We could get rid of the global variables for vlog modules entirely, but I like getting linker errors when there's a duplicate module name. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* db-ctl-base: Make 'cmd_show_tables' argument to ctl_init() optional.Ben Pfaff2015-09-141-3/+14
| | | | | | | | | This allows the client to omit the "show" command if it doesn't want it. This will be used in an upcoming commit. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Alex Wang <ee07b291@gmail.com>
* db-ctl-base: Allow print rows that weak reference to table inAlex Wang2015-08-131-0/+43
| | | | | | | | | | | | | | | | | | | | 'cmd_show_table'. Sometimes, it is desirable to print the table with weak reference to the table specified in 'struct cmd_show_table'. For example the Port_Binding table rows in OVN_Southbound database that refer to the same Chassis table row can be printed under the same chassis entry in 'ovn-sbctl show' output. To achieve it, this commit adds a new struct in 'struct cmd_show_table' that allows users to print a table with weak reference to 'table' specified in 'struct cmd_show_table'. The 'ovn-sbctl' which now prints the Port_Binding entries with Chassis table, is the first user of this new feature. Requested-by: Justin Pettit <jpettit@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* db-ctl-base: make cmd_show_table privateAndy Zhou2015-07-231-9/+11
| | | | | | | | Instead of requiring user to declare a global variable, pass the value via ctl_init(). Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: remove the recurse member from struct cmd_show_tableAndy Zhou2015-07-231-6/+14
| | | | | | | | | | | | The 'recurse' is used during run time to suppress duplicated prints. It is not essential to describe how show command should work. This patch remove the 'recurse' member. Duplicated prints is now suppressed by maintaining an 'sset' of tables that have been printed at run time. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: Add "static" to definition of ctl_exit().Ben Pfaff2015-07-201-1/+1
| | | | | | | | | The prototype said "static" but the definition did not. Reported by sparse. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* db-ctl-base: make use of user supplied exit functionAndy Zhou2015-07-171-10/+24
| | | | | | | | | The user is required to expose the_idl and the_idl_txn global variables, so that memory can be cleaned up on fatal errors. This patch changes to ask user to supply an exit function via ctl_init(). What user needs to do on exit can now remain private. Signed-off-by: Andy Zhou <azhou@nicira.com>
* db-ctl-base: remove ctl_get_all_commands() functionAndy Zhou2015-07-171-10/+4
| | | | | | | all_commands currently is some times accessed directly, some times via a function call. Change to always access it directly. Signed-off-by: Andy Zhou <azhou@nicira.com>
* db-ctl-base: remove db_ctl_show_command tableAndy Zhou2015-07-171-8/+2
| | | | | | | It is not clear why "show" command needs its own command table. Remove it for simplicity. Signed-off-by: Andy Zhou <azhou@nicira.com>
* db-ctl-base: group static functions togetherAndy Zhou2015-07-131-83/+83
| | | | | | | | | This file follows a convention that all static functions are grouped towards the beginning, ahead of public functions. Re-arrange the code to confirm to this convention. No functional changes. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* db-ctl-base: do not require client to expose the "tables" variableAndy Zhou2015-07-131-1/+7
| | | | | | | Instead, client now pass it via the modified ctl_init() API. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* db-ctl-base: do not expose get_table() APIAndy Zhou2015-07-131-2/+13
| | | | | | | | | | | | Both get_table() and set_cloum() APIs are mostly used within db-ctl-base library. This patch makes both private to the library. Add a new ctl_set_colum() API for library client. The changes are cleanups. No functional changes. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* db-ctl-base: Improve show command.Alex Wang2015-06-231-0/+39
| | | | | | | | | | This commit adds improvement to 'show' command logic and allows it to print key->table_ref maps. The direct effect can be observed from the tests/vtep-ctl.at change. The improvement will also be used in the ovn-sbctl implementation. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: Librarize show command.Alex Wang2015-06-231-0/+130
| | | | | | | | This commit extracts the 'show' command code and puts it into the db-ctl-base module. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: Librarize code in parse_options().Alex Wang2015-06-231-0/+220
| | | | | | | | This commit extracts general code from parse_options() and puts it into db-ctl-base module. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: Make common database command code into library.Alex Wang2015-06-231-0/+1683
This commit extracts common database command (e.g. ovs-vsctl, vtep-ctl) code into a new library module, db-ctl-base. Specifically, the module unifies the command syntax and common database-operating commands like (get, list, find, set ...), and provides apis which allow user to create more specific commands. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>