summaryrefslogtreecommitdiff
path: root/ovsdb/ovsdb-idlc.in
Commit message (Collapse)AuthorAgeFilesLines
* ovsdb-idl: Tolerate initialization races for singleton tables.Ben Pfaff2017-12-111-2/+6
| | | | | | | | | | | | | | | By verifying that singleton tables (that is, tables that should have exactly one row) are empty when they emit transactions that insert into them, ovs-vsctl and similar tools tolerate initialization races, where more than one client at a time tries to initialize a singleton table. The upshot is that if you create a database and then run multiple ovs-vsctl (etc.) commands against it in parallel (without first initializing it serially), then without this patch sometimes you will sometimes get failures but this patch avoids them. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
* lib, ovsdb: Adapt headers for C++ usageYi-Hung Wei2017-12-011-1/+10
| | | | | | | | This patch adds 'extern "C"' in a couple of header files so that they can be compiled with C++ compilers. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idl: Avoid mutable type specifier.Joe Stringer2017-08-151-1/+1
| | | | | | | | | | In C++, 'mutable' 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 'is_mutable' to avoid this issue. Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* 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>
* ovsdb-idl: Autogenerated functions for compound indexesLance Richardson2017-08-031-0/+258
| | | | | | | | | | | | | | Generates and fills in the default comparators for columns with type int, real, string. Also creates the macros that allow iteration over the contents of the index, and perform queries. Signed-off-by: Arnoldo Lutz Guevara <arnoldo.lutz.guevara@hpe.com> Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com> Co-authored-by: Arnoldo Lutz Guevara <arnoldo.lutz.guevara@hpe.com> Co-authored-by: Esteban Rodriguez Betancourt <estebarb@hpe.com> Signed-off-by: Lance Richardson <lrichard@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Python3 compatibility: fix integer problemsJason Wessel2017-07-061-1/+1
| | | | | | | | | | | | In python3 maxint is not defined, but maxsize is defined in both python2 and python3. The put_text() will not automatically use a value which came in as float due to a pior math function and python3 will throw an exception. The simple answer is to convert it with int() and move on. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Python3 compatibility: iteritems to itemsJason Wessel2017-07-061-4/+4
| | | | | | | | Allow compability with python3 and python2 by changing iteritems() to items(). Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Python3 compatibility: execfile to execJason Wessel2017-07-061-1/+1
| | | | | | | | Allow compability with python3 and python2 by changing execfile() to exec(). Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Python3 compatibility: exception cleanupJason Wessel2017-07-061-2/+2
| | | | | | | | The exception syntax which is compatible with python2 and python3 is to use the "as" form for "except:". Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Python3 compatibility: Convert print statementsJason Wessel2017-07-061-261/+262
| | | | | | | | This patch fixes up all the print statements to work with python3 or python2. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idlc: Initialize nonnull string columns for inserted rows.Ben Pfaff2016-12-201-0/+5
| | | | | | | | | | | | | | | | | | | | When a schema column has type "exactly one string", the corresponding struct member has type "char *" and the documented and expected behavior is that the string should always be nonnull. (The code generator even adds a comment /* Always nonnull. */ in the struct definition.) In the case where a value is not available, the string is supposed to be initialized to "" instead of to NULL. However, the IDL code for inserting a new row did not properly initialize the column to "", instead leaving it NULL. This could cause null pointer dereferences in corner cases. This commit fixes the problem. Reported-by: Lance Richardson <lrichard@redhat.com> Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2016-December/326500.html Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Lance Richardson <lrichard@redhat.com>
* ovsdb-idl: Change interface to conditional monitoring.Ben Pfaff2016-12-191-191/+12
| | | | | | | | | | | | | | | | | | | | | | | | 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-idlc: Remove special case for "sizeof bool".Ben Pfaff2016-10-191-23/+4
| | | | | | | | | | | | The "sparse" checker used to warn about sizeof(bool). These days, it does not warn (without -Wsizeof-bool), so remove this ugly special case. If you have a version of "sparse" that still warns by default, please upgrade to a version that includes commit 2667c2d4ab33 (sparse: Allow override of sizeof(bool) warning). Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idl: Sort and unique-ify datum in ovsdb_idl_txn_write().Ben Pfaff2016-10-191-2/+0
| | | | | | | | | | | | I noticed that there were lots of calls to ovsdb_datum_sort_unique() from "set" functions in generated IDL code. This moves that call into common code, reducing redundancy. There are more calls to the same function that are a little harder to remove. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idlc: Eliminate <prefix>_init() function from generated code.Ben Pfaff2016-10-191-57/+30
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idlc: Consolidate assertions.Ben Pfaff2016-10-191-21/+12
| | | | | | | | There were lots of bits of code emitting "assert(inited);". This combines many of them. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idlc: Declare loop variables in for statements in generated code.Ben Pfaff2016-10-191-14/+5
| | | | | | | | | | | | This changes several instances of size_t i; for (i = 0; i < ...; i++) into: for (size_t i = 0; i < ...; i++) in generated code, making it slightly more compact and easier to read. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idlc: Make generated references to columns easier to read.Ben Pfaff2016-10-191-38/+28
| | | | | | | | | This replaces ovsrec_open_vswitch_columns[OVSREC_OPEN_VSWITCH_COL_CUR_CFG] by the easier to read and equivalent ovsrec_open_vswitch_col_cur_cfg in generated code. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idlc: Make generated references to table classes easier to read.Ben Pfaff2016-10-191-28/+29
| | | | | | | | This replaces &ovsrec_table_classes[OVSREC_TABLE_OPEN_VSWITCH] by the easier to read and equivalent &ovsrec_table_open_vswitch in generated code. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idlc: Simplify code generation to parse sets and maps of references.Ben Pfaff2016-10-191-21/+21
| | | | | | | | | | | | | | | | | This switches from code that looks like: if (keyRow) { ... } to: if (!keyRow) { continue; } ... which is a little easier to generate because the indentation of ... is constant. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idlc: Factor out sorting columns.Ben Pfaff2016-10-191-17/+20
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idlc: Remove obsolete documentation and usage.Ben Pfaff2016-10-191-1/+0
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idlc: Use ovsdb_datum_from_smap() instead of open-coding it.Ben Pfaff2016-10-191-42/+3
| | | | | | | | | | | | There's no reason to have three copies of this code for every smap-type column. The code wasn't a perfect match for ovsdb_datum_from_smap(), so this commit also changes ovsdb_datum_from_smap() to better suit it. It only had one caller and the new design is adequate for that caller. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* ovsdb-idl: Update comments.Ben Pfaff2016-09-191-3/+1
| | | | | | | | | TXN_AGAIN_WAIT and TXN_AGAIN_NOW were combined into a single return code TXN_TRY_AGAIN a long time ago, but these comment was not updated. Reported-by: Justin Pettit <jpettit@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ovsdb-idlc: Fix logic error in IDL parse function.Mickey Spiegel2016-09-021-1/+1
| | | | | | | | | | | | | | This was found due to a build error when adding an ovsschema column with "type": {"key": "string", "value": "integer"} with no min or max, only a single instance. I am rather unfamiliar with IDL, so no tests have been added yet. I could use some pointers, or someone familiar with IDL tests could take over. Signed-off-by: Mickey Spiegel <mickeys.dev@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idlc: Make set and map update operations take const arguments.Ben Pfaff2016-08-311-19/+19
| | | | | | | | | | In a call like "ovsrec_bridge_update_ports_delvalue(bridge, port)", there's no reason for the port argument to be nonconst, because the call doesn't do anything to the port at all--it only searches the list of ports in the bridge for that particular port and, if it finds it, removes it. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* ovsdb-idlc: Fix memory leaks in add and remove clause functions.Ben Pfaff2016-08-301-8/+24
| | | | | | | Found by inspection. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Amitabha Biswas <abiswas@us.ibm.com>
* ovsdb: Fix reference to table's row on condition_add|remove_clauseLiran Schour2016-08-261-20/+20
| | | | | | | | Use struct uuid * on [add|remove]_clause on columns which are references to tables. That prevents use-after-free errors. Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb: Add/use partial set updates.Ryan Moats2016-08-141-1/+64
| | | | | | | | | | | | | | | | | | | | 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>
* lib: add monitor_cond_change API to C IDL libLiran Schour2016-07-181-2/+362
| | | | | | | | | | 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>
* ovn-controller: Use new ovsdb-idl helpers to make logic more readable.Ben Pfaff2016-06-231-0/+12
| | | | | | | | Also there were lots of 'continue's sprinkled around that didn't seem to be needed given some simple code rearrangement. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Ryan Moats <rmoats@us.ibm.com>
* ovsdb-idlc.in: Autogenerate partial map updates functions.Edward Aymerich2016-05-181-0/+69
| | | | | | | | | | | Code inserted that autogenerates corresponding map functions to set and delete elements in map columns. Inserts description to the functions that are autogenerated. 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> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idl: Add support for column tracking in IDL.Shad Ansari2016-01-121-4/+11
| | | | | | | | | | 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: Add support for change tracking.Shad Ansari2015-11-231-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* ovsdb-idlc: Generate comments for "*_set_*" functions.Justin Pettit2015-03-041-17/+75
| | | | | Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idlc: Remove "*_get_*" warning from header file.Justin Pettit2015-03-041-4/+1
| | | | | | | | The warning is now captured in the C file, which has documentation for all the public functions. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idlc: Add comments for remaining non-"set" non-static functions.Justin Pettit2015-03-041-12/+64
| | | | | Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idlc: Use column name for "*_set_*" smap arguments.Justin Pettit2015-03-041-4/+4
| | | | | Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idlc: Constify 'char **'.Russell Bryant2015-02-191-1/+3
| | | | | | | | | | | | | Update the logic used in constify() to add const to a 'char **' while still excluding all other cases of more than one level of indirection. This results in adding const to a parameter of a generated setter function where we're generally passing in array of constant strings. As a result, this patch includes the other necessary fixes to the code base to reflect the const addition. Signed-off-by: Russell Bryant <rbryant@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idlc: Generate new *_get_for_uuid() functions.Ben Pfaff2014-03-281-0/+7
| | | | | | | | | | | | | This allows a client to obtain the IDL version of a row given its UUID. It isn't normally useful, but there's a specialized use case for getting the IDL version of a row given the UUID returned by ovsdb_idl_txn_get_insert_uuid() following transaction commit. An alternative would be to generate table-specific versions of ovsdb_idl_txn_get_insert_uuid(). That seems reasonable to me too. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* ovsdb-idlc: Make schema version available.Justin Pettit2014-02-281-0/+12
| | | | | | | | Future patches will make use of the ability to retrieve the schema version against which they were compiled. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idlc: Ensure that initialization occurs single-threaded.Ben Pfaff2013-07-231-0/+2
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* ovsdb-idlc: Write a new-line at the end of "annotate" output.Ben Pfaff2013-06-101-0/+1
| | | | | | | | | | | | | | | Some tools do not like text files that lack a trailing new-line. In particular, Debian's dpkg-source utility complains about a missing new-line in the file generated by ovsdb-idlc: dpkg-source: warning: file openvswitch-1.9.2+git20130605/lib/vswitch-idl.ovsidl has no final newline (either original or modified version) This commit fixes the problem. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* ovsdb-idlc: Make no-op writes to write-only columns cheaper.Ben Pfaff2013-03-051-9/+31
| | | | | | | | | For 1000 tunnels with CFM enabled, this reduces CPU use from about 36% to about 30%. Bug #15171. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* Replace most uses of assert by ovs_assert.Ben Pfaff2013-01-161-12/+12
| | | | | | | | This is a straight search-and-replace, except that I also removed #include <assert.h> from each file where there were no assert calls left. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* ovsdb: Enforce immutability of immutable columns.Ben Pfaff2012-09-051-0/+5
| | | | | | | | | | | 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-63/+95
| | | | | | | | | | 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>
* ovsdb-idlc: Fix memory leak in "optional bool" columns.Ben Pfaff2012-03-231-9/+1
| | | | | | | | | | | | Commit 1bf2c9096858 (idl: Generalize special case boolean exception.) changed the IDL to do dynamic allocation with (x)malloc() for optional booleans, but it didn't add the corresponding calls to free(). This commit fixes the problem. Bug #10357. Reported-by: Paul Ingram <paul@nicira.com> Reported-by: Krishna Miriyala <krishna@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* idl: New helpers for accessing string maps.Ethan Jackson2012-03-221-0/+50
| | | | | | This removes some boilerplate from the bridge. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* idl: Generalize special case boolean exception.Ethan Jackson2012-02-081-25/+25
| | | | | | | | | | | Sparse doesn't like taking sizeof boolean values. The idl had worked around this limitation with a special case in the case of optional booleans. A future patch needs an array with boolean values which the existing special case did not handle. This patch generalizes the special case to handle this situation as well. Signed-off-by: Ethan Jackson <ethan@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>