2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-29 13:27:59 +00:00

53 Commits

Author SHA1 Message Date
Ben Pfaff
65d9759c4f ovsdb-data: Add OVS_WARN_UNUSED_RESULT annotations to function definitions.
The function prototypes in ovsdb-data.h already have these, but it seems
more complete to have the annotation on the definitions too.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
2017-12-08 13:39:29 -08:00
Lukasz Rzasik
1ab39058cc ovsdb-data: Add support for integer ranges in database commands
Adding / removing a range of integers to a column accepting a set of
integers requires enumarating all of the integers. This patch simplifies
it by introducing 'range' concept to the database commands. Two integers
separated by a hyphen represent an inclusive range.

The patch adds positive and negative tests for the new syntax.
The patch was tested by 'make check'. Covarage was tested by
'make check-lcov'.

Signed-off-by: Lukasz Rzasik <lukasz.rzasik@gmail.com>
Suggested-by: <my_ovs_discuss@yahoo.com>
Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-01-05 08:48:10 -08:00
Ben Pfaff
9b03e59d20 ovsdb-idlc: Use ovsdb_datum_from_smap() instead of open-coding it.
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>
2016-10-19 11:38:31 -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
Andy Zhou
1a6f1cefc0 lib: add diff and apply diff APIs for ovsdb_datum
When an OVSDB column change its value, it is more efficient to only
send what has changed, rather than sending the entire new copy.
This is analogous to software programmer send patches rather than
the entire source file.

For columns store a single element, the "diff" datum is the same
as the "new" datum.

For columns that store set or map, it is only necessary to send the
information about the elements changed (including addition or removal).
The "diff" for those types are all elements that are changed.

Those APIs are mainly used for implementing a new OVSDB server
"update2" JSON-RPC notification, which encodes modifications
of a column with the contents of those "diff"s. Later patch implements
the "update2" notification.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@ovn.org>
2015-12-11 14:22:33 -08:00
Andy Zhou
aefd97b779 lib: avoid set size check when generating diff datum from json
Added ovsdb_transient_datum_from_json() to avoid size check for
the diff datum that is transient in nature.
Suppose a datum contains set, and the max number of elements is 2.
If we are changing from set that contains [A, B], to a set contains
[C, D], the diff datum will contains 4 elements [A, B, C, D].

Thus diff datum should not be constrained by the size limit. However
the datum after diff is applied should not violate the size limit.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@ovn.org>
2015-12-11 14:22:32 -08:00
Thomas Graf
cab5044987 lib: Move compiler.h to <openvswitch/compiler.h>
The following macros are renamed to avoid conflicts with other headers:
 * WARN_UNUSED_RESULT to OVS_WARN_UNUSED_RESULT
 * PRINTF_FORMAT to OVS_PRINTF_FORMAT
 * NO_RETURN to OVS_NO_RETURN

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Ben Pfaff <blp@nicira.com>
2014-12-15 14:14:47 +01:00
Ben Pfaff
c70a77673c ovsdb: Remove SPECS in favor of referring to RFC 7047.
Also, add some clarifications relative to RFC 7047 to ovsdb-server(1).

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
2014-04-04 13:51:32 -07:00
Ben Pfaff
7bd02255d9 Revert "ovsdb-data: New functions for predicting serialized length of data."
This reverts commit 0ea7bec76d804a2c4efccd3dbdaa3e30cf536a5c.

Connections that queue up too much data, because they are monitoring a
table that is changing quickly and failing to keep up with the updates,
cause problems with buffer management.  Since commit 60533a405b2e
(jsonrpc-server: Disconnect connections that queue too much data.),
ovsdb-server has dealt with them by disconnecting the connection and
letting them start up again with a fresh copy of the database.  However,
this is not ideal because of situations where disconnection happens
repeatedly.  For example:

     - A manager toggles a column back and forth between two or more values
       quickly (in which case the data transmitted over the monitoring
       connections always increases quickly, without bound).

     - A manager repeatedly extends the contents of some column in some row
       (in which case the data transmitted over the monitoring connection
       grows with O(n**2) in the length of the string).

A better way to deal with this problem is to combine updates when they are
sent to the monitoring connection, if that connection is not keeping up.
In both the above cases, this reduces the data that must be sent to a
manageable amount.  An upcoming patch implements this new way.  This commit
reverts part of the previous solution that disconnects backlogged
connections, since it is no longer useful.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
2014-04-03 07:53:48 -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
Alin Serdean
34582733d9 Avoid printf type modifiers not supported by MSVC C runtime library.
The MSVC C library printf() implementation does not support the 'z', 't',
'j', or 'hh' format specifiers.  This commit changes the Open vSwitch code
to avoid those format specifiers, switching to standard macros from
<inttypes.h> where available and inventing new macros resembling them
where necessary.  It also updates CodingStyle to specify the macros' use
and adds a Makefile rule to report violations.

Signed-off-by: Alin Serdean <aserdean@cloudbasesolutions.com>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-11-25 23:38:59 -08:00
Ben Pfaff
21a0e105f1 ovsdb-data: Make ovsdb_atom_default() thread-safe.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-22 10:53:11 -07:00
Ben Pfaff
0ea7bec76d ovsdb-data: New functions for predicting serialized length of data.
These will be used for the first time in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-04-01 13:20:04 -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
Ben Pfaff
ebc56baa41 util: New macro CONST_CAST.
Casts are sometimes necessary.  One common reason that they are necessary
is for discarding a "const" qualifier.  However, this can impede
maintenance: if the type of the expression being cast changes, then the
presence of the cast can hide a necessary change in the code that does the
cast.  Using CONST_CAST, instead of a bare cast, makes these changes
visible.

Inspired by my own work elsewhere:
http://git.savannah.gnu.org/cgit/pspp.git/tree/src/libpspp/cast.h#n80

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-08-03 13:33:13 -07:00
Ben Pfaff
57c8677b51 system-stats: Use "smap" instead of "shash".
"smap" is now the appropriate data structure for a string-to-string map.

Also changes ovsdb_datum_from_shash() into ovsdb_datum_from_smap() since
system-stats related code was the only client.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-18 10:51:02 -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
e49190c493 Fix minor memory leaks found by valgrind.
All of these leaks are in normally short-lived programs, so none of them
is very important.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-28 14:54:48 -07:00
Ben Pfaff
ca261b6535 ovsdb-data: Short-circuit ovsdb_datum_includes_all() in trivial case.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-01-11 09:56:11 -08:00
Ben Pfaff
6a6f8d1673 ovsdb-data: Simplify converting an OVSDB datum to JSON by reordering logic.
Putting the "map" case first avoids duplicate tests.

Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
be44585c21 tests: Fix the two Python XFAIL tests.
OVS has two Python tests that have always failed, for reasons not
understood, since they were added to the tree.  This commit fixes them.

One problem was that Python was assuming that stdout was encoded in ASCII.
Apparently the only way to "fix" this at runtime is to set PYTHONIOENCODING
to utf_8 in the environment, so this change does that.

Second, it appears that Python really doesn't like to print invalid UTF-8,
so this avoids doing that in python/ovs/json.py, instead just printing
the hexadecimal values of the invalid bytes.  For consistency, it makes
the same change to the C version.

Third, the C version of test-ovsdb doesn't check UTF-8 for consistency, it
just sends it blindly to the OVSDB server, but Python does check it and so
it bails out earlier.  This commit changes the Python version of the
"no invalid UTF-8 sequences in strings" to allow for the slight difference
in output that occurs for that reason.

Finally, test-ovsdb.py needs to convert error messages to Unicode
explicitly before printing them in the "parse-atoms" function.  I don't
really understand why, but now it works.
2011-05-24 11:32:22 -07:00
Ben Pfaff
c5f341ab19 ovsdb: Implement garbage collection. 2011-03-10 11:24:00 -08:00
Ben Pfaff
0dc66db95b ovsdb-data: Expose guts of ovsdb_symbol_table() to clients.
ovs-vsctl will, in upcoming commits, want to more closely examine its
ovsdb_symbol_table structures.  This could be done by providing a more
complete API, but it doesn't seem worth it to me.  This commit instead goes
the other way, exposing the internals to clients.  This commit also
eliminates the ovsdb_symbol_table_find_uncreated() function, which
ovs-vsctl can now implement itself.
2011-03-10 11:24:00 -08:00
Ben Pfaff
e9387de4a2 ovsdb-data: Rename 'used' to 'created' in struct ovsdb_symbol.
The name 'created' better reflects the actual meaning of this member: in
both ovsdb and ovs-vsctl, it is true if a row has been created with the
symbol's UUID and false otherwise.
2011-03-10 11:24:00 -08:00
Ben Pfaff
d198c4beee ovsdb-data: Verify that named-uuid string is an <id>.
The "uuid-name" that creates symbols must be an <id> but we weren't
verifying the same constraint on the "named-uuid"s that refer to symbols,
which was a bit confusing in writing transactions by hand.  This commit
fixes the inconsistency and updates the SPECS file to clarify that a
named-uuid string has to be an <id>.
2011-03-10 11:23:59 -08:00
Justin Pettit
9466d7d4b9 ovsdb-data: Free string leaked in ovsdb_datum_from_string().
Coverity #10725
2011-02-22 09:36:57 -08:00
Ben Pfaff
c6a4125250 table: Add new "bare" output formatting options.
--format=list corresponds to the output format that "ovs-vsctl list" has
always used.

--bare is easier for scripts to parse.
2011-02-08 16:10:05 -08:00
Ethan Jackson
829d41bdc8 ovsdb-data: Fix warnings.
This commit fixes "may be used uninitialized" warnings in
ovsdb-data.c
2011-01-13 10:48:22 -08:00
Ben Pfaff
e4af561537 ovsdb-data: New function ovsdb_datum_from_shash(). 2010-09-23 11:45:35 -07:00
Ben Pfaff
d931cde4d7 ovsdb: Remove unused ovsdb_datum_from_json_unique().
This function was not used outside of the test-ovsdb program.  It seems
like we might as well remove it.
2010-08-25 14:55:47 -07:00
Ben Pfaff
2b66469b96 ovsdb: New functions ovsdb_datum_sort_unique(), ovsdb_datum_from_json_unique().
These new functions are more forgiving than the corresponding functions
without "_unique".  The goal is to be more tolerant of data provided by
IDL clients, which will happen in a followup patch.
2010-07-12 10:07:36 -07:00
Ben Pfaff
958ac03a3f ovsdb: New functions ovsdb_atom_default(), ovsdb_datum_default().
Having access to const copies of default atoms and data will allow OVSDB
code to avoid memory allocations and reduce copying in upcoming commits.
2010-07-12 10:05:16 -07:00
Ben Pfaff
5413de95be ovsdb: Document some ovsdb-data.[ch] functions. 2010-07-12 10:03:33 -07:00
Ben Pfaff
e89e5374be ovs-vsctl: Prepare for more flexible database argument parsing.
The wait-until command to be added in an upcoming commit needs to support
!=, <, >, <=, and >= operators in addition to =, so this commit adds that
infrastructure.
2010-06-29 09:33:13 -07:00
Ben Pfaff
506051fcb5 Use shash_destroy_free_data() to simplify a few scattered pieces of code. 2010-06-23 12:43:02 -07:00
Ben Pfaff
ce5a3e38da ovs-vsctl: Support references among records at creation time.
This makes it easy to create a bunch of records that are all related to
each other in a single ovs-vsctl invocation.  It adds an example to the
ovs-vsctl manpage.
2010-06-17 10:30:18 -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
fbf925e45d ovsdb: Get rid of "declare" operation.
It's more elegant, and just as easy to implement, if we allow a
"named-uuid" to be a forward reference to a "uuid-name" in a later
"insert" operation.
2010-02-08 16:03:21 -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
9397a13f60 ovsdb-data: Allow spaces around '=' in key-value pairs.
This allows a = b, a= b, a =b, etc. whereas before only a=b was accepted.
2010-01-28 14:22:40 -08:00
Ben Pfaff
cb4562170b ovsdb-data: Allow arbitrary white space as string data delimiters. 2010-01-28 14:22:40 -08:00
Ben Pfaff
54a687fd7b ovsdb-data: Make string parsing of negative 0 match JSON parsing. 2010-01-28 14:22:39 -08:00
Ben Pfaff
1bc6ff2918 ovs-vsctl: Make parsing functions return error instead of aborting.
The upcoming "remove" command for ovs-vsctl wants to try parsing an
argument two different ways.  This doesn't work if a parse error always
aborts immediately.  This commit fixes the problem, by making a parsing
failure pass up an error for higher layers to deal with instead of aborting
immediately.

This commit should have no user-visible effect.
2010-01-27 13:51:52 -08:00
Ben Pfaff
0194f33a6c ovsdb-datum: Add functions for parsing and formatting atoms, data.
These functions provide an alternative to JSON parsing and formatting that
is more human-friendly (and shorter).

These will be used in an upcoming commit to enhance ovs-vsctl.
2010-01-26 09:49:30 -08:00
Ben Pfaff
2f47998bae ovsdb-data: Add some more functions for dealing with "struct ovsdb_datum".
This commit refactors the functions for working with "struct ovsdb_datum",
adding and exposing some more operations for ovs-vsctl to use in an
upcoming commit.
2010-01-26 09:49:30 -08:00
Ben Pfaff
c532bf9dd4 ovsdb: Save some space in the log for newly inserted records.
When a new record is inserted into a database, ovsdb logs the values of all
of the fields in the record.  However, often new records have many columns
that contain default values.  There is no need to log those values, so this
commit causes them to be omitted.

As a side effect, this also makes "ovsdb-tool show-log --more --more"
output easier to read, because record insertions print less noise.  (Adding
--more --more to this command makes it print changes to database records.
The --more option will be introduced in an upcoming commit.)
2010-01-11 13:14:54 -08:00