summaryrefslogtreecommitdiff
path: root/tests/test-ovsdb.c
Commit message (Collapse)AuthorAgeFilesLines
* Move lib/ofp-util.h to include/openvswitch directoryBen Warren2016-04-141-0/+1
| | | | | | | | This commit also adds several #include directives in source files in order to make the 'ofp-util.h' move possible Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* list: Rename all functions in list.h with ovs_ prefix.Ben Warren2016-03-301-2/+2
| | | | | | | This attempts to prevent namespace collisions with other list libraries Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@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>
* test-ovsdb: Fix memory leak reported by valgrind.William Tu2016-02-101-0/+4
| | | | | | | | | | | | | Testcase 1314: UUID-distinct queries on scalars. Call stacks: allocate_row (row.c:37) ovsdb_row_clone (row.c:67) do_query_distinct (test-ovsdb.c:1232) ovs_cmdl_run_command (command-line.c:121) main (test-ovsdb.c:72) Signed-off-by: William Tu <u9012063@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* test-ovsdb: Fix memory leak reported by valgrind.William Tu2016-02-051-0/+2
| | | | | | | | | | | | Testcase 1311, 1312: Boolean-distinct queries on scalars, reports leak below: xmalloc (util.c:112) do_query_distinct (test-ovsdb.c:1208) ovs_cmdl_run_command (command-line.c:121) main (test-ovsdb.c:72) Signed-off-by: William Tu <u9012063@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idl: Add support for column tracking in IDL.Shad Ansari2016-01-121-0/+63
| | | | | | | | | | Recent IDL change tracking patches allow quick traversal of changed rows. This patch adds additional support to track changed columns. It allows an IDL client to efficiently check if a specific column of a row was updated by IDL. Signed-off-by: Shad Ansari <shad.ansar@hpe.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* test-ovsdb: Fix memory leak reported by valgrind.William Tu2016-01-111-1/+3
| | | | | | | | | | | | | | Test case 1205: generate and apply diff -- set -- size (ovsdb-data.at:827) Call stack: ovsdb_error_valist (ovsdb-error.c:40) ovsdb_error (ovsdb-error.c:55) do_diff_data (test-ovsdb.c:427) ovs_cmdl_run_command (command-line.c:121) main (test-ovsdb.c:72) Fix by calling ovsdb_error_destroy() before ovs_fatal() Signed-off-by: William Tu <u9012063@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* lib: add diff and apply diff APIs for ovsdb_datumAndy Zhou2015-12-111-1/+60
| | | | | | | | | | | | | | | | | | | | | | When an OVSDB column change its value, it is more efficient to only send what has changed, rather than sending the entire new copy. This is analogous to software programmer send patches rather than the entire source file. For columns store a single element, the "diff" datum is the same as the "new" datum. For columns that store set or map, it is only necessary to send the information about the elements changed (including addition or removal). The "diff" for those types are all elements that are changed. Those APIs are mainly used for implementing a new OVSDB server "update2" JSON-RPC notification, which encodes modifications of a column with the contents of those "diff"s. Later patch implements the "update2" notification. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idl: Add support for change tracking.Shad Ansari2015-11-231-52/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ovsdb-idl notifies a client that something changed; it does not track which table, row changed in what way (insert, modify or delete). As a result, a client has to scan or reconfigure the entire idl after ovsdb_idl_run(). This is presumably fine for typical ovs schemas where tables are relatively small. In use-cases where ovsdb is used with schemas that can have very large tables, the current ovsdb-idl notification mechanism does not appear to scale - clients need to do a lot of processing to determine the exact change delta. This change adds support for: - Table and row based change sequence numbers to record the most recent IDL change sequence numbers associated with insert, modify or delete update on that table or row. - Change tracking of specific columns. This ensures that changed rows (inserted, modified, deleted) that have tracked columns, are tracked by IDL. The client can directly access the changed rows with get_first, get_next operations without the need to scan the entire table. The tracking functionality is not enabled by default and needs to be turned on per-column by the client after ovsdb_idl_create() and before ovsdb_idl_run(). /* Example Usage */ idl = ovsdb_idl_create(...); /* Track specific columns */ ovsdb_idl_track_add_column(idl, column); /* Or, track all columns */ ovsdb_idl_track_add_all(idl); for (;;) { ovsdb_idl_run(idl); seqno = ovsdb_idl_get_seqno(idl); /* Process only the changed rows in Table FOO */ FOO_FOR_EACH_TRACKED(row, idl) { /* Determine the type of change from the row seqnos */ if (foo_row_get_seqno(row, OVSDB_IDL_CHANGE_DELETE) >= seqno)) { printf("row deleted\n"); } else if (foo_row_get_seqno(row, OVSDB_IDL_CHANGE_MODIFY) >= seqno)) printf("row modified\n"); } else if (foo_row_get_seqno(row, OVSDB_IDL_CHANGE_INSERT) >= seqno)) printf("row inserted\n"); } } /* All changes processed - clear the change track */ ovsdb_idl_track_clear(idl); } Signed-off-by: Shad Ansari <shad.ansari@hp.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* command-line: add ovs_cmdl_contextRussell Bryant2015-03-171-105/+111
| | | | | | | | | | | | | | | | | | | | | | | I started working on a new command line utility that used this shared code. I wanted the ability to pass some data from common initialization code to all of the commands. You can find a similar pattern in ovs-vsctl. This patch updates the command handler to take a new struct, ovs_cmdl_context, instead of argc and argv directly. It includes argc and argv, but also includes an opaque type (void *), where the user of this API can attach its custom data it wants passed along to command handlers. This patch affected the ovstest sub-programs, as well. The patch includes a bit of an odd hack to OVSTEST_REGISTER() to avoid making the main() function of the sub-programs take a ovs_cmdl_context. The test main() functions still receive argc and argv directly, as that seems more natural. The test-subprograms themselves are able to make use of a context internally, though. Signed-off-by: Russell Bryant <rbryant@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* command-line: add ovs_cmdl_ prefixRussell Bryant2015-03-161-7/+7
| | | | | | | | | | | | | | | | | The coding style guidelines include the following: - Pick a unique name prefix (ending with an underscore) for each module, and apply that prefix to all of that module's externally visible names. Names of macro parameters, struct and union members, and parameters in function prototypes are not considered externally visible for this purpose. This patch adds the new prefix to the externally visible names. This makes it a bit more obvious what code is coming from common command line handling code. Signed-off-by: Russell Bryant <rbryant@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* lib: Move vlog.h to <openvswitch/vlog.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | A new function vlog_insert_module() is introduced to avoid using list_insert() from the vlog.h header. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib: Move compiler.h to <openvswitch/compiler.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | | | The following macros are renamed to avoid conflicts with other headers: * WARN_UNUSED_RESULT to OVS_WARN_UNUSED_RESULT * PRINTF_FORMAT to OVS_PRINTF_FORMAT * NO_RETURN to OVS_NO_RETURN Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* command-line: Add function to print command usage.Alex Wang2014-10-281-35/+35
| | | | | | | | | | | | | This commit adds a new variable in 'struct command' for recording the command usage. Also, a new function is added to print the usage given the array of defined commands. Later patch will use the output in bash command-line completion script. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* compiler: Define NO_RETURN for MSVC.Gurucharan Shetty2014-09-151-1/+1
| | | | | | | | | | | | | To prevent warnings such as "Not all control paths return a value", we should define NO_RETURN for MSVC. Currently for gcc, we add NO_RETURN at the end of function declaration. But for MSVC, "__declspec(noreturn)" is needed at the beginning of function declaration. So this commit moves NO_RETURN to the beginning of the function declaration as it works with gcc and clang too. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* test-ovsdb: Fix setvbuf incompatibility on Windows.Gurucharan Shetty2014-05-141-1/+1
| | | | | | | | | | | setvbuf() in Windows treats _IOLBF to be the same as _IOFBF. So we cannot have size as zero (otherwise, there is a crash). Workaround is to set _IONBF. I don't see unit test failures because of the change. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Avoid static declarations of arrays with unknown size.Gurucharan Shetty2014-04-041-3/+8
| | | | | | | | | | | Visual studio does not like it. This commit is similar to commit 3815d6c2c (Avoid designated initializers and static decls of arrays of unknown size.) but touches more files. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Revert "ovsdb-data: New functions for predicting serialized length of data."Ben Pfaff2014-04-031-11/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 0ea7bec76d804a2c4efccd3dbdaa3e30cf536a5c. Connections that queue up too much data, because they are monitoring a table that is changing quickly and failing to keep up with the updates, cause problems with buffer management. Since commit 60533a405b2e (jsonrpc-server: Disconnect connections that queue too much data.), ovsdb-server has dealt with them by disconnecting the connection and letting them start up again with a fresh copy of the database. However, this is not ideal because of situations where disconnection happens repeatedly. For example: - A manager toggles a column back and forth between two or more values quickly (in which case the data transmitted over the monitoring connections always increases quickly, without bound). - A manager repeatedly extends the contents of some column in some row (in which case the data transmitted over the monitoring connection grows with O(n**2) in the length of the string). A better way to deal with this problem is to combine updates when they are sent to the monitoring connection, if that connection is not keeping up. In both the above cases, this reduces the data that must be sent to a manageable amount. An upcoming patch implements this new way. This commit reverts part of the previous solution that disconnects backlogged connections, since it is no longer useful. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* Avoid printf type modifiers not supported by MSVC C runtime library.Alin Serdean2013-11-251-6/+6
| | | | | | | | | | | | | The MSVC C library printf() implementation does not support the 'z', 't', 'j', or 'hh' format specifiers. This commit changes the Open vSwitch code to avoid those format specifiers, switching to standard macros from <inttypes.h> where available and inventing new macros resembling them where necessary. It also updates CodingStyle to specify the macros' use and adds a Makefile rule to report violations. Signed-off-by: Alin Serdean <aserdean@cloudbasesolutions.com> Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Make most "struct option" instances "const".Ben Pfaff2013-05-031-1/+1
| | | | | | | | Reducing non-const static data makes code more obviously thread-safe. Although option parsing does not normally need to be thread-safe, I don't know of a drawback to making its data const. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb-data: New functions for predicting serialized length of data.Ben Pfaff2013-04-011-3/+11
| | | | | | These will be used for the first time in an upcoming commit. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-vsctl: Try connecting only once for active connections by default.Ben Pfaff2013-03-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Until now, ovs-vsctl has kept trying to the database server until it succeeded or the timeout expired (if one was specified with --timeout). This meant that if ovsdb-server wasn't running, then ovs-vsctl would hang. The result was that almost every ovs-vsctl invocation in scripts specified a timeout on the off-chance that the database server might not be running. But it's difficult to choose a good timeout. A timeout that is too short can cause spurious failures. A timeout that is too long causes long delays if the server really isn't running. This commit should alleviate this problem. It changes ovs-vsctl's behavior so that, if it fails to connect to the server, it exits unsuccessfully. This makes --timeout obsolete for the purpose of avoiding a hang if the database server isn't running. (--timeout is still useful to avoid a hang if ovsdb-server is running but ovs-vswitchd is not, for ovs-vsctl commands that modify the database. --no-wait also avoids that issue.) Bug #2393. Bug #15594. Reported-by: Jeff Merrick <jmerrick@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb-server: Add support for multiple databases.Ben Pfaff2012-09-241-2/+6
| | | | | | | | | | The OVSDB protocol has supported multiple databases for a long time, but the ovsdb-server implementation only supported one database at a time. This commit adds support for multiple databases. Feature #12353. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* Global replace of Nicira Networks.Raju Subramanian2012-05-021-1/+1
| | | | | | | | Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idl: Improve ovsdb_idl_txn_increment() interface.Ben Pfaff2012-04-121-3/+12
| | | | | | The previous interface was just bizarre. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idl: Simplify transaction retry.Ben Pfaff2012-04-121-3/+11
| | | | | | | | | | | | | | | | | | | | | | Originally the IDL transaction state machine had a return value TXN_TRY_AGAIN to signal the client to wait for a change in the database and then retry its transaction. However, this logic was incomplete, because it was possible for the database to change before the reply to the transaction RPC was received, in which case the client would wait for a further change. Commit 4fdfe5ccf84c (ovsdb-idl: Prevent occasional hang when multiple database clients race.) fixed the problem by breaking TXN_TRY_AGAIN into two status codes, TXN_AGAIN_WAIT that meant to wait for a further change and TXN_AGAIN_NOW that meant that a change had already occurred so try again immediately. This is correct enough, but it is more complicated than necessary. It is simpler and just as correct to use a single "try again" status that requires the client to wait for a change relative to the database contents *before* the transaction was committed. This commit makes that change. It also changes ovsdb_idl_run()'s return type from bool to void because its return type is hardly useful anymore. Signed-off-by: Ben Pfaff <blp@nicira.com>
* Allow configuring DSCP on controller and manager connections.Mehak Mahajan2012-03-231-2/+2
| | | | | | | | | | | The changes allow the user to specify a separate dscp value for the controller connection and the manager connection. The value will take effect on resetting the connections. If no value is specified a default value of 192 is chosen for each of the connections. Feature #10074 Requested-by: Rajiv Ramanathan <rramanathan@nicira.com> Signed-off-by: Mehak Mahajan <mmahajan@nicira.com>
* jsonrpc: Don't swallow errors in jsonrpc_transact_block().Ethan Jackson2012-02-211-1/+1
| | | | | | | | | If a server returned an error in response to a request, jsonrpc_transact_block() would ignore it. This patch changes the behavior and updates its callers to gracefully handle the possibility. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* tests: Fix typos in C versions of test-ovsdb error messages.Ben Pfaff2011-09-231-3/+3
|
* ovsdb: Implement a "lock" feature in the database protocol.Ben Pfaff2011-07-261-1/+1
| | | | | | | | | | | This provides clients a way to coordinate their access to the database. This is a voluntary, not mandatory, locking protocols, that is, clients are not prevented from modifying the database unless they cooperate with the locking protocol. It is also not related to any of the ACID properties of database transactions. It is strictly a way for clients to coordinate among themselves. The following commit will introduce one user.
* ovsdb: Refactor jsonrpc-server to make the concept of a session public.Ben Pfaff2011-07-261-5/+7
| | | | | | | An upcoming commit will need to expose the concept of a database session to the execution engine, to allow the execution engine to query the locks held by the session. This commit prepares for that by making sessions a publicly visible data structure.
* ovsdb-idl: Plug hole in state machine.Ben Pfaff2011-06-211-0/+7
| | | | | | | | | | | | The state machine didn't have a proper state for "not yet committed or aborted", which meant that destroying an ovsdb_idl_txn without committing or aborting it caused a segfault. This fixes the problem by adding a new state TXN_UNCOMMITTED to the state machine. This is related to commit 79554078d "ovsdb-idl: Fix bad logic in ovsdb_idl_txn_commit() state transitions", which fixed a related bug. Bug #2438.
* ovsdb: Move ovsdb_table_put_row() into test program.Ben Pfaff2011-06-061-2/+12
| | | | | | This function is not useful inside ovsdb itself but only in the "test-ovsdb" test program. To avoid the temptation to use it incorrectly inside ovsdb, this commit moves it into the test program.
* ovsdb: Make ovsdb_column_set_from_json() take table schema instead of table.Ben Pfaff2011-06-061-1/+2
| | | | | | | This function took a struct ovsdb_table but only used the 'schema' member. An upcoming patch needs to parse a column set when only the schema is available, so to prepare for that this patch changes ovsdb_column_set_from_json() to only take the schema that it really needs.
* Consistently write null pointer constants as NULL instead of 0.Ben Pfaff2011-05-161-4/+4
| | | | Found with sparse.
* ovsdb: Implement garbage collection.Ben Pfaff2011-03-101-3/+6
|
* test-ovsdb: Check uuid_from_string() return value.Ben Pfaff2011-02-231-2/+4
| | | | Coverity #10699.
* test-ovsdb: Don't leak return value from ovsdb_txn_commit().Justin Pettit2011-02-231-1/+1
| | | | Coverity #10727
* ovsdb-idl: Make selecting tables and columns to replicate more flexible.Ben Pfaff2010-11-161-1/+1
| | | | | | | | | Until now, by default the IDL replicated all tables and all columns in the database, and a few functions made it possible to avoid replicating selected columns. This commit adds a mode in which nothing is replicated by default and the client code is responsible for specifying each column and table that it is interested in. The following commit adds a user for this mode.
* ovsdb-idl: Test prerequisite checking.Ben Pfaff2010-10-221-1/+28
|
* Switch many macros from using CONTAINER_OF to using OBJECT_CONTAINING.Ben Pfaff2010-10-011-2/+1
| | | | | These macros require one fewer argument by switching, which makes code that uses them shorter and more readable.
* Avoid shadowing local variable names.Ben Pfaff2010-09-201-2/+4
| | | | | | | | | | | All of these changes avoid using the same name for two local variables within a same function. None of them are actual bugs as far as I can tell, but any of them could be confusing to the casual reader. The one in lib/ovsdb-idl.c is particularly brilliant: inner and outer loops both using (different) variables named 'i'. Found with GCC -Wshadow.
* ovsdb: Remove unused ovsdb_datum_from_json_unique().Ben Pfaff2010-08-251-10/+0
| | | | | This function was not used outside of the test-ovsdb program. It seems like we might as well remove it.
* vlog: Remove explicit calls to vlog_init().Ben Pfaff2010-07-211-1/+0
| | | | This is no longer necessary.
* timeval: Make time_init() static and remove calls to it.Ben Pfaff2010-07-211-1/+0
| | | | | | Since the timeval module now initializes itself on-demand, there is no longer any need to initialize it explicitly, or to provide an interface to do so.
* ovsdb: New functions ovsdb_datum_sort_unique(), ovsdb_datum_from_json_unique().Ben Pfaff2010-07-121-2/+23
| | | | | | These new functions are more forgiving than the corresponding functions without "_unique". The goal is to be more tolerant of data provided by IDL clients, which will happen in a followup patch.
* ovsdb: New functions ovsdb_atom_default(), ovsdb_datum_default().Ben Pfaff2010-07-121-0/+71
| | | | | Having access to const copies of default atoms and data will allow OVSDB code to avoid memory allocations and reduce copying in upcoming commits.
* ovsdb-idl: Simplify usage of ovsdb_idl_run().Ben Pfaff2010-06-231-27/+17
| | | | | It makes client code simpler if ovsdb_idl_run() simply lets the caller know whether anything changed.
* ovs-vsctl: Support references among records at creation time.Ben Pfaff2010-06-171-2/+2
| | | | | | This makes it easy to create a bunch of records that are all related to each other in a single ovs-vsctl invocation. It adds an example to the ovs-vsctl manpage.
* tests: fix compile warning of tests/test-ovsdb.cWei Yongjun2010-05-171-5/+5
| | | | | | | | | | | | | | | | | This patch fixed the following compile warning: tests/test-ovsdb.c: In function 'do_evaluate_conditions': tests/test-ovsdb.c:744: warning: format '%2d' expects type 'int', but argument 2 has type 'size_t' tests/test-ovsdb.c: In function 'do_execute_mutations': tests/test-ovsdb.c:850: warning: format '%2d' expects type 'int', but argument 2 has type 'size_t' tests/test-ovsdb.c: In function 'do_query': tests/test-ovsdb.c:972: warning: format '%2d' expects type 'int', but argument 2 has type 'size_t' tests/test-ovsdb.c: In function 'do_query_distinct': tests/test-ovsdb.c:1105: warning: format '%2d' expects type 'int', but argument 2 has type 'size_t' tests/test-ovsdb.c: In function 'parse_uuids': tests/test-ovsdb.c:1600: warning: format '%d' expects type 'int', but argument 2 has type 'size_t' Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>