2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00

20 Commits

Author SHA1 Message Date
Ilya Maximets
a20e2c8ce2 ovsdb-types: Fix use of uninitialized reference type.
Types for UUID columns that are not references (e.g. version column)
may end up with the refType not initialized.  At the same time, some
functions use the value during the type comparison, which may result
in a false negative type check:

 WARNING: MemorySanitizer: use-of-uninitialized-value
  0 0x75abf7 in ovsdb_base_type_equals lib/ovsdb-types.c:321:16
  1 0x75f899 in ovsdb_type_equals lib/ovsdb-types.c:626:12
  2 0x4fc607 in ovsdb_convert_table ovsdb/file.c:316:13
  3 0x4fb5ec in ovsdb_convert ovsdb/file.c:388:17
  4 0x598bcf in ovsdb_trigger_try ovsdb/trigger.c:313:25
  5 0x596902 in ovsdb_trigger_init ovsdb/trigger.c:66:12
  6 0x5189e8 in ovsdb_jsonrpc_trigger_create ovsdb/jsonrpc-server.c:1247:27
  7 0x51473d in ovsdb_jsonrpc_session_got_request ovsdb/jsonrpc-server.c:1112:13
  8 0x512ea2 in ovsdb_jsonrpc_session_run ovsdb/jsonrpc-server.c:677:17
  9 0x50d67d in ovsdb_jsonrpc_session_run_all ovsdb/jsonrpc-server.c:700:21
 10 0x50cc49 in ovsdb_jsonrpc_server_run ovsdb/jsonrpc-server.c:522:9
 11 0x4d756f in main_loop ovsdb/ovsdb-server.c:330:9
 12 0x4c4e52 in main ovsdb/ovsdb-server.c:890:5
 13 0x7f42bb in __libc_start_call_main
 14 0x7f42bb in __libc_start_main@GLIBC_2.2.5
 15 0x432b64 in _start (ovsdb/ovsdb-server+0x432b64)

Fix the initialization function to always set the refType to some
value.  Using the "strong" as we don't have an UNSPEC value in the
enumeration.  It will not be meaningful unless the refTable is also
set, in which case it will be properly updated, we just need the
value to be the same for all the columns that are not references.

Fixes: e0e4266a90a2 ("ovsdb-types: Add functions to compare types for equality.")
Acked-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-11-29 18:33:23 +01:00
Ilya Maximets
e0e4266a90 ovsdb-types: Add functions to compare types for equality.
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>
2023-01-27 15:53:06 +01:00
Ilya Maximets
485ac63d10 ovsdb: Add lazy-copy support for ovsdb_datum objects.
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>
2022-07-13 20:33:07 +02:00
Ben Pfaff
fa37affad3 Embrace anonymous unions.
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>
2018-05-25 13:36:05 -07:00
Yunjian Wang
2434d05d27 ovsdb-types: Fix memory leak on error path.
Fixes: bd76d25d8b3b ("ovsdb: Add simple constraints.")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-07-11 21:42:10 -07:00
Terry Wilson
ee89ea7b47 json: Move from lib to include/openvswitch.
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>
2016-07-22 17:09:17 -07:00
Ben Warren
3e8a2ad145 Move lib/dynamic-string.h to include/openvswitch directory
Signed-off-by: Ben Warren <ben@skyportsystems.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-03-19 10:02:12 -07:00
Harold Lim
428b2eddc9 Rename NOT_REACHED to OVS_NOT_REACHED
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>
2013-12-17 13:16:39 -08:00
Ben Pfaff
d2d3264cd6 ovsdb-types: Make ovsdb_base_type_get_enum_type() thread-safe.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
2013-07-23 11:37:39 -07:00
Raju Subramanian
e0edde6fee Global replace of Nicira Networks.
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>
2012-05-02 17:08:02 -07:00
Ben Pfaff
d272c10ecd python: Take advantage of Python "x < y < z" syntax.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
7360012bdf ovsdb: Add support for weak references. 2010-03-17 14:24:56 -07:00
Ben Pfaff
bfc96d9b50 ovsdb: Add support for "enum" constraints.
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.
2010-02-25 14:59:41 -08:00
Ben Pfaff
89521e3f79 ovsdb: Drop regular expression constraints.
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.
2010-02-25 14:59:16 -08:00
Ben Pfaff
ae8f13e290 ovsdb: Make scalars and 1-element sets interchangeable.
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.
2010-02-08 16:37:49 -08:00
Ben Pfaff
bfe8e67ad5 ovsdb: Fix support for systems where libpcre is not installed.
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.
2010-02-08 15:37:49 -08:00
Ben Pfaff
0d0f05b909 ovsdb: Add support for referential integrity in the database itself. 2010-02-08 14:16:19 -08:00
Ben Pfaff
bd76d25d8b ovsdb: Add simple constraints. 2010-02-08 14:16:19 -08:00
Ben Pfaff
31a763d7d7 ovsdb: Require column type "min" value be 0 or 1.
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.
2010-01-26 10:32:33 -08:00
Ben Pfaff
f85f8ebbfa Initial implementation of OVSDB. 2009-11-04 17:12:10 -08:00