summaryrefslogtreecommitdiff
path: root/lib/ovsdb-types.c
Commit message (Collapse)AuthorAgeFilesLines
* ovsdb-types: Add functions to compare types for equality.Ilya Maximets2023-01-271-0/+61
| | | | | | | Will be used in the next commit to optimize database conversion. Acked-by: Han Zhou <hzhou@ovn.org> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* ovsdb: Add lazy-copy support for ovsdb_datum objects.Ilya Maximets2022-07-131-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently ovsdb-server is using shallow copies of some JSON objects by keeping a reference counter. JSON string objects are also used directly as ovsdb atoms in database rows to avoid extra copies. Taking this approach one step further ovsdb_datum objects can also be mostly deduplicated by postponing the copy until it actually needed. datum object itself contains a type and 2 pointers to data arrays. Adding a one more pointer to a reference counter we may create a shallow copy of the datum by simply copying type and pointers and increasing the reference counter. Before modifying the datum, special function needs to be called to perform an actual copy of the object, a.k.a. unshare it. Most of the datum modifications are performed inside the special functions in ovsdb-data.c, so that is not very hard to track. A few places like ovsdb-server.c and column mutations are accessing and changing the data directly, so a few extra unshare() calls has to be added there. This change doesn't affect the maximum memory consumption too much, because most of the copies are short-living. However, not actually performing these copies saves up to 40% of CPU time on operations with large sets. Reported-at: https://bugzilla.redhat.com/2069089 Acked-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* Embrace anonymous unions.Ben Pfaff2018-05-251-54/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several OVS structs contain embedded named unions, like this: struct { ... union { ... } u; }; C11 standardized a feature that many compilers already implemented anyway, where an embedded union may be unnamed, like this: struct { ... union { ... }; }; This is more convenient because it allows the programmer to omit "u." in many places. OVS already used this feature in several places. This commit embraces it in several others. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org> Tested-by: Alin Gabriel Serdean <aserdean@ovn.org> Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
* ovsdb-types: Fix memory leak on error path.Yunjian Wang2017-07-111-0/+1
| | | | | | Fixes: bd76d25d8b3b ("ovsdb: Add simple constraints.") Signed-off-by: Yunjian Wang <wangyunjian@huawei.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-1/+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>
* 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>
* Rename NOT_REACHED to OVS_NOT_REACHEDHarold Lim2013-12-171-11/+11
| | | | | | | | This allows other libraries to use util.h that has already defined NOT_REACHED. Signed-off-by: Harold Lim <haroldl@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb-types: Make ovsdb_base_type_get_enum_type() thread-safe.Ben Pfaff2013-07-231-8/+16
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@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>
* python: Take advantage of Python "x < y < z" syntax.Ben Pfaff2011-08-241-2/+1
| | | | Suggested-by: Reid Price <reid@nicira.com>
* ovsdb: Add support for weak references.Ben Pfaff2010-03-171-0/+23
|
* ovsdb: Add support for "enum" constraints.Ben Pfaff2010-02-251-3/+59
| | | | | | Some of the uses for the formerly supported regular expression constraints were simply to limit values to those in a set of allowed values. This commit adds support for that kind of simple enumeration constraint.
* ovsdb: Drop regular expression constraints.Ben Pfaff2010-02-251-90/+1
| | | | | | | | Regular expression constraints have caused nothing but trouble due to the lack of a ubiquitous regular expression library. PCRE is *almost* everywhere, but it has different versions, and different features, and different bugs, in different places. It is more trouble than it is worth. So this commit drops support.
* ovsdb: Make scalars and 1-element sets interchangeable.Ben Pfaff2010-02-081-1/+2
| | | | | | It is natural to write "abc" in place of ["set",["abc"]] and vice versa. I cannot think of a reason not to support this, and it can make reading and writing OVSDB files and transactions easier, so support it.
* ovsdb: Fix support for systems where libpcre is not installed.Ben Pfaff2010-02-081-1/+24
| | | | | This is one of the loose ends that I intended to fix up and test before pushing off my commits to add use of PCRE, but obviously I forgot.
* ovsdb: Add support for referential integrity in the database itself.Ben Pfaff2010-02-081-1/+22
|
* ovsdb: Add simple constraints.Ben Pfaff2010-02-081-32/+439
|
* ovsdb: Require column type "min" value be 0 or 1.Ben Pfaff2010-01-261-1/+2
| | | | | | | | | | A "min" value greater than 1 is problematic for the database. There is no reasonable way to synthesize a default value for such a column: keys in a set or map must unique, so the database cannot, say, simply set a set of 3 or more integers to [0, 0, 0]. This should have no effect on the vswitch in practice because it does not have any columns that require more than one element.
* Initial implementation of OVSDB.Ben Pfaff2009-11-041-0/+251