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

25 Commits

Author SHA1 Message Date
Ilya Maximets
1de4a08c22 json: Use functions to access json arrays.
Internal implementation of JSON array will be changed in the future
commits.  Add access functions that users can rely on instead of
accessing the internals of 'struct json' directly and convert all the
users.  Structure fields are intentionally renamed to make sure that
no code is using the old fields directly.

json_array() function is removed, as not needed anymore.  Added new
functions:  json_array_size(), json_array_at(), json_array_set()
and json_array_pop().  These are enough to cover all the use cases
within OVS.

The change is fairly large, however, IMO, it's a much overdue cleanup
that we need even without changing the underlying implementation.

Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-30 16:53:56 +02:00
Ilya Maximets
7ab8f6f7c7 ovsdb: Preserve column diffs read from the storage.
Database file contains the column diff, but it is discarded once
the 'new' state of a row is constructed.  Keep it in the transaction
row, as it can be used later by other parts of the code.

Diffs do not live long, we keep them around only while transaction
is alive, so should not affect memory consumption.

Users for this data will be added in later commits.

Acked-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-01-11 20:13:27 +01:00
Ilya Maximets
2f1b430645 ovsdb: relay: Fix handling of XOR updates with size constraints.
Relay servers apply updates via ovsdb_table_execute_update().  XOR
updates contain datum diffs, and datum diffs can be larger than the
type constraints.  Currently, relay will fail to parse such update
into ovsdb row triggering a syntax error and a re-connection.

Fix that by relaxing the size constraints for this kind of updates.

Fixes: 026c77c58ddb ("ovsdb: New ovsdb 'relay' service model.")
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2023-08-03 14:19:32 +02:00
Dumitru Ceara
a9ec4e3be3 ovsdb-server: Log database transactions for user requested tables.
Add a new command, 'ovsdb-server/tlog-set DB:TABLE on|off', which
allows the user to enable/disable transaction logging for specific
databases and tables.

By default, logging is disabled.  Once enabled, logs are generated
with level INFO and are also rate limited.

If used with care, this command can be useful in analyzing production
deployment performance issues, allowing the user to pin point
bottlenecks without the need to enable wider debug logs, e.g., jsonrpc.

A command to inspect the logging state is also added:
'ovsdb-server/tlog-list'.

Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-06-28 13:45:36 +02:00
Adrian Moreno
9e56549c2b hmap: use short version of safe loops if possible.
Using SHORT version of the *_SAFE loops makes the code cleaner and less
error prone. So, use the SHORT version and remove the extra variable
when possible for hmap and all its derived types.

In order to be able to use both long and short versions without changing
the name of the macro for all the clients, overload the existing name
and select the appropriate version depending on the number of arguments.

Acked-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-03-30 16:59:02 +02:00
Ilya Maximets
b4cef64c83 ovsdb: row: Add support for xor-based row updates.
This will be used to apply update3 type updates to ovsdb tables
while processing updates for future ovsdb 'relay' service model.

'ovsdb_datum_apply_diff' is allowed to fail, so adding support
to return this error.

Acked-by: Mark D. Gray <mark.d.gray@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-07-15 22:37:46 +02:00
Ilya Maximets
85dbbe275b ovsdb: table: Expose functions to execute operations on ovsdb tables.
These functions will be used later for ovsdb 'relay' service model, so
moving them to a common code.

Warnings translated to ovsdb errors, caller in replication.c only
printed inconsistency warnings, but mostly ignored them.  Implementing
the same logic by checking the error tag.

Also ovsdb_execute_insert() previously printed incorrect warning about
duplicate row while it was a syntax error in json.  Fixing that by
actually checking for the duplicate and reporting correct ovsdb error.

Acked-by: Mark D. Gray <mark.d.gray@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-07-15 22:37:43 +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
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
Andy Hill
ec9f40dce1 Fix misspellings in comments and docs.
Flagged with: https://github.com/lyda/misspell-check
Run with: git ls-files | misspellings -f -

Signed-off-by: Andy Hill <hillad@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-04 21:53:33 -07:00
Ben Pfaff
cb22974d77 Replace most uses of assert by ovs_assert.
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>
2013-01-16 16:03:37 -08: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
6910a6e6f2 ovsdb: Implement table uniqueness constraints ("indexes"). 2011-06-06 09:09:10 -07:00
Ben Pfaff
29d7226e8b ovsdb: Move ovsdb_table_put_row() into test program.
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.
2011-06-06 08:58:02 -07:00
Ben Pfaff
e3c1773370 Consistently write null pointer constants as NULL instead of 0.
Found with sparse.
2011-05-16 13:40:47 -07:00
Ben Pfaff
c5f341ab19 ovsdb: Implement garbage collection. 2011-03-10 11:24:00 -08:00
Ben Pfaff
4e8e4213a8 Switch many macros from using CONTAINER_OF to using OBJECT_CONTAINING.
These macros require one fewer argument by switching, which makes code
that uses them shorter and more readable.
2010-10-01 10:25:29 -07:00
Ben Pfaff
87ab878cad ovsdb: Allow constraining the number of rows in a table. 2010-03-18 11:32:26 -07:00
Ben Pfaff
2e57b53730 ovsdb: Remove "comment" support from OVSDB schemas.
Using a separate XML file to document a schema is much more flexible.
You end up with two files (a schema and documentation for it), each of
which is readable and maintainable, instead of a single schema file that
is almost illegible.
2010-03-05 17:05:43 -08:00
Ben Pfaff
58985e09ea ovsdb: Add functions to clone schemas.
These will be used by an upcoming commit.
2010-02-15 11:31:05 -08:00
Ben Pfaff
bd76d25d8b ovsdb: Add simple constraints. 2010-02-08 14:16:19 -08:00
Ben Pfaff
629cd2f17f ovsdb: Slightly simplify ovsdb_table_get_row(), ovsdb_table_put_row().
There is no value in saving a call to uuid_hash() in ovsdb_table_put_row(),
because uuid_hash() is a trivial inline function, so integrate
ovsdb_table_get_row__() into ovsdb_table_get_row() and simplify
ovsdb_table_put_row().
2010-02-08 14:16:19 -08:00
Ben Pfaff
71c93bd4cc ovsdb: Use direct pointer from table to txn_table to simplify code.
Until now, when a transaction modified rows in a table, the metadata
associated with that table modification (in struct ovsdb_txn_table) had to
be looked up through a hash table.  This made the code unnecessarily
complicated and had no benefit in itself, so this commit changes
struct ovsdb_table to have a direct pointer to its ovsdb_txn_table.
2010-02-08 14:16:18 -08:00
Ben Pfaff
b966380b45 ovsdb: Require database, table, column names to be valid identifiers.
Database, table, and column names have always been required by the OVSDB
specification to be identifiers (e.g. valid C identifiers), but this has
never been enforced.

This commit adds enforcement and fixes one instance of an invalid column
name in the vswitch schema.
2009-11-19 16:48:12 -08:00
Ben Pfaff
f85f8ebbfa Initial implementation of OVSDB. 2009-11-04 17:12:10 -08:00