summaryrefslogtreecommitdiff
path: root/lib/ovsdb-idl-provider.h
Commit message (Collapse)AuthorAgeFilesLines
* ovsdb-idl: Change interface to conditional monitoring.Ben Pfaff2016-12-191-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | Most users of OVSDB react to whatever is currently in their view of the database, as opposed to keeping track of changes and reacting to those changes individually. The interface to conditional monitoring was different, in that it expected the client to say what to add or remove from monitoring instead of what to monitor. This seemed reasonable at the time, but in practice it turns out that the usual approach actually works better, because the condition is generally a function of the data visible in the database. This commit changes the approach. This commit also changes the meaning of an empty condition for a table. Previously, an empty condition meant to replicate every row. Now, an empty condition means to replicate no rows. This is more convenient for code that gradually constructs conditions, because it does not need special cases for replicating nothing. This commit also changes the internal implementation of conditions from linked lists to arrays. I just couldn't see an advantage to using linked lists. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Liran Schour <lirans@il.ibm.com>
* ovsdb-idl: Drop write-only member from struct ovsdb_idl_condition.Ben Pfaff2016-12-191-1/+0
| | | | | | | | The 'tc' member of struct ovsdb_idl_condition was written but never read, so remove it. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
* ovsdb-idl: Mark ovsdb_idl_get_row_arc() parameter const.Ben Pfaff2016-10-191-1/+1
| | | | | | | | This function doesn't modify its 'dst_table' parameter, so it might as well be marked const. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idl: Add some more implementation comments.Ben Pfaff2016-10-191-0/+36
| | | | | | | | I wrote this code and if I have to rediscover how it works, it's time to improve the commnts. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idl: Style and comment improvements for conditional replication.Ben Pfaff2016-08-151-1/+6
| | | | | | | | | | The conditional replication code had hardly any comments. This adds some. This commit also fixes a number of style problems, factors out some code into a helper function, and moves some struct declarations from a public header, that were not used by client code, into more private locations. Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb: Add/use partial set updates.Ryan Moats2016-08-141-0/+3
| | | | | | | | | | | | | | | | | | | | This patchset mimics the changes introduced in f199df26 (ovsdb-idl: Add partial map updates functionality.) 010fe7ae (ovsdb-idlc.in: Autogenerate partial map updates functions.) 7251075c (tests: Add test for partial map updates.) b1048e6a (ovsdb-idl: Fix issues detected in Partial Map Update feature) but for columns that store sets of values rather than key-value pairs. These columns will now be able to use the OVSDB mutate operation to transmit deltas on the wire rather than use verify/update and transmit wait/update operations on the wire. Side effect of modifying the comments in the partial map update tests. Signed-off-by: Ryan Moats <rmoats@us.ibm.com> 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>
* lib: add monitor_cond_change API to C IDL libLiran Schour2016-07-181-0/+2
| | | | | | | | | | Add to IDL API that allows the user to add and remove clauses on a table's condition iteratively. IDL maintain tables condition and send monitor_cond_change to the server upon condition change. Add tests for conditional monitoring to IDL. Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idl: Add partial map updates functionality.Edward Aymerich2016-05-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the current implementation, every time an element of either a map or set column has to be modified, the entire content of the column is sent to the server to be updated. This is not a major problem if the information contained in the column for the corresponding row is small, but there are cases where these columns can have a significant amount of elements per row, or these values are updated frequently, therefore the cost of the modifications becomes high in terms of time and bandwidth. In this solution, the ovsdb-idl code is modified to use the RFC 7047 'mutate' operation, to allow sending partial modifications on map columns to the server. The functionality is exposed to clients in the vswitch idl. This was implemented through map operations. A map operation is defined as an insertion, update or deletion of a key-value pair inside a map. The idea is to minimize the amount of map operations that are send to the OVSDB server when a transaction is committed. In order to keep track of the requested map operations, structs map_op and map_op_list were defined with accompanying functions to manipulate them. These functions make sure that only one operation is send to the server for each key-value that wants to be modified, so multiple operation on a key value are collapsed into a single operation. As an example, if a client using the IDL updates several times the value for the same key, the functions will ensure that only the last value is send to the server, instead of multiple updates. Or, if the client inserts a key-value, and later on deletes the key before committing the transaction, then both actions cancel out and no map operation is send for that key. To keep track of the desired map operations on each transaction, a list of map operations (struct map_op_list) is created for every column on the row on which a map operation is performed. When a new map operation is requested on the same column, the corresponding map_op_list is checked to verify if a previous operations was performed on the same key, on the same transaction. If there is no previous operation, then the new operation is just added into the list. But if there was a previous operation on the same key, then the previous operation is collapsed with the new operation into a single operation that preserves the final result if both operations were to be performed sequentially. This design keep a small memory footprint during transactions. When a transaction is committed, the map operations lists are checked and all map operations that belong to the same map are grouped together into a single JSON RPC "mutate" operation, in which each map_op is transformed into the necessary "insert" or "delete" mutators. Then the "mutate" operation is added to the operations that will be send to the server. Once the transaction is finished, all map operation lists are cleared and deleted, so the next transaction starts with a clean board for map operations. Using different structures and logic to handle map operations, instead of trying to force the current structures (like 'old' and 'new' datums in the row) to handle then, ensures that map operations won't mess up with the current logic to generate JSON messages for other operations, avoids duplicating the whole map for just a few changes, and is faster for insert and delete operations, because there is no need to maintain the invariants in the 'new' datum. Signed-off-by: Edward Aymerich <edward.aymerich@hpe.com> Signed-off-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com> Co-authored-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com> [blp@ovn.org made style changes and factored out error checking] Signed-off-by: Ben Pfaff <blp@ovn.org>
* list: Remove lib/list.h completely.Ben Warren2016-03-301-1/+1
| | | | | | | | All code is now in include/openvswitch/list.h. Signed-off-by: Ben Warren <ben@skyportsystems.com> Acked-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idl: Add support for column tracking in IDL.Shad Ansari2016-01-121-1/+3
| | | | | | | | | | 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>
* ovsdb-idl: Improve ovsdb_idl_add_table() comment.Aymerich, Edward2015-11-301-1/+2
| | | | | | | | | | | | The new comment reflects with more clarity what ovsdb_idl_add_table() does. Previous comment could be misunderstood, leading to believe that this function replicates all columns on IDL. Hopefully this fix clarifies that columns are not replicated, just minimal data for reference integrity is replicated. A comment in ovsdb_idl_table_class is also modified to better reflect this behaviour. Signed-off-by: Edward Aymerich <edward.aymerich@hpe.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idl: Add support for change tracking.Shad Ansari2015-11-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* list: Rename struct list to struct ovs_listThomas Graf2014-12-151-2/+2
| | | | | | | struct list is a common name and can't be used in public headers. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb: Enforce immutability of immutable columns.Ben Pfaff2012-09-051-1/+2
| | | | | | | | | | | OVSDB has always had the ability to mark a column as "immutable", so that its value cannot be changed in a given row after that row is initially inserted. However, we discovered recently that ovsdb-server has never enforced this constraint. This commit implements enforcement. Reported-by: Paul Ingram <paul@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Kyle Mestery <kmestery@cisco.com>
* lib: Utilize smaps in the idl.Ethan Jackson2012-06-141-0/+1
| | | | | | | | | | String to string maps are used all over the Open vSwitch database. Before this patch, they were implemented in the idl as parallel string arrays. This strategy has proven a bit cumbersome. With this patch, string to string maps are implemented using the smap library. Signed-off-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: Implement garbage collection.Ben Pfaff2011-03-101-1/+2
|
* ovsdb-idl: Make selecting tables and columns to replicate more flexible.Ben Pfaff2010-11-161-23/+2
| | | | | | | | | 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: Make it possible to omit or pay less attention to columns.Ben Pfaff2010-08-111-0/+23
| | | | | | | | | | | | | | | ovs-vswitchd has no need to replicate some parts of the database. In particular, it doesn't need to replicate the bits that it never reads, such as the external_ids column in the Open_vSwitch table. This saves some memory, CPU time, and bandwidth to the database. Another type of column that benefits from special treatment is "write-only columns", that is, those that ovs-vswitchd writes and keeps up-to-date but never expects another client to write, such as the cur_cfg column in the Open_vSwitch table. If the IDL reports that the database has changed when ovs-vswitchd updates such a column, then ovs-vswitchd reconfigures itself for no reason, wasting CPU time. This commit also adds support for such columns.
* ovsdb: Add support for multiple databases to the protocol.Ben Pfaff2010-02-091-0/+1
| | | | | | This also adds protocol compatibility to the database itself and to ovsdb-client. It doesn't actually add multiple database support to ovsdb-server, since we don't really need that yet.
* ovsdb-idl: Export ovsdb_idl_txn_delete() and ovsdb_idl_txn_insert().Ben Pfaff2010-01-271-4/+0
| | | | | | | | ovs-vsctl wants to use these functions directly, so make them available through the ovsdb-idl public header instead of only through the private one. Also, change the prototypes to make them usable without casts.
* ovsdb-idl: Allow clients to modify records without using structs.Ben Pfaff2010-01-261-11/+3
| | | | | | | | | | | | | | | The IDL is intended to allow clients easier access to data in the database by providing an extra layer of abstraction. However, ovs-vsctl needs to also provide generic access to database tables, rows, and columns, and until now the IDL has not allowed this. In particular, there was no way to modify the value of a database column by providing a "struct ovsdb_datum" with the new value and then have that reflected in the IDL structs, although the other direction was possible. This commit fixes that problem, which requires a bit of refactoring of the IDL layer. It also exposes the interface for iterating through table records to clients directly, by moving it from the "private" IDL header to the public one.
* ovsdb-idl: New function to obtain the current transaction from any row.Ben Pfaff2009-12-081-0/+2
|
* ovsdb-idl: Make it possible to write data through the IDL.Ben Pfaff2009-12-071-1/+17
| | | | | Until now the IDL has been exclusively a read-only interface. This commit introduces a general-purpose interface for writing to ovsdb via the IDL.
* ovsdb: Implement C bindings for IDL.Ben Pfaff2009-12-021-0/+71