2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 12:58:00 +00:00

78 Commits

Author SHA1 Message Date
Zengyuan Wang
23a70e2866 db-ctl-base: Fix memory leak of db commands.
Variable "want_key" in function check_condition and variable "key"
in function set_column were not destroyed in exception branch.

This patch calls ovsdb_atom_destroy to release resources to avoid
memory leak.

Fixes: 79c1a00fb5a5 ("db-ctl-base: Don't die in set_column() on error.")
Fixes: e09b3af3e249 ("db-ctl-base: Don't die in is_condition_satisfied() on error")
Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Zengyuan Wang <wangzengyuan@huawei.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2023-10-18 23:01:29 +02:00
Daniel Alvarez Sanchez
daeab9548a db-ctl-base: Partially revert b8bf410a5.
The commit b8bf410a5 [0] broke the `ovs-vsctl add` command
which now overwrites the value if it existed already.

This patch reverts the code around the `cmd_add` function
to restore the previous behavior. It also adds testing coverage
for this functionality.

[0] b8bf410a5c

Fixes: b8bf410a5c94 ("db-ctl-base: Use partial map/set updates for last add/set commands.")
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2182767
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Daniel Alvarez Sanchez <dalvarez@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2023-03-30 22:10:40 +02:00
Ilya Maximets
b8bf410a5c db-ctl-base: Use partial map/set updates for last add/set commands.
Currently, command to add one item into a large set generates the
transaction with the full new content of that set plus 'wait'
operation for the full old content of that set.  So, if we're adding
one new load-balancer into a load-balancer group in OVN using
ovn-nbctl, transaction will include all the existing load-balancers
from that groups twice.

IDL supports partial updates for sets and maps.  The problem with that
is changes are not visible to the IDL user until the transaction
is committed.  That will cause problems for chained ctl commands.
However, we still can optimize the very last command in the list.
It makes sense to do, since it's a common case for manual invocations.

Updating the 'add' command as well as 'set' for a case where we're
actually adding one new element to the map.

One downside is that we can't check the set size without examining
it and checking for duplicates, so allowing the transaction to be
sent and constraints to be checked on the server side in that case.

Not touching 'remove' operation for now, since removals may have
different type, e.g. if elements from the map are removed by the key.
The function will likely need to be fully re-written to accommodate
all the corner cases.

Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-12-06 16:21:54 +01:00
Numan Siddique
55b9507e68 ovsdb-idl: Add the support to specify the uuid for row insert.
ovsdb-server allows the OVSDB clients to specify the uuid for
the row inserts [1].  Both the C IDL client library and Python
IDL are missing this feature.  This patch adds this support.

In C IDL, for each schema table, a new function is generated -
<schema_table>insert_persistent_uuid(txn, uuid) which can
be used the clients to persist the uuid.

ovs-vsctl and other derivatives of ctl now supports the same
in the generic 'create' command with the option "--id=<UUID>".

In Python IDL, the uuid to persist can be specified in
the Transaction.insert() function.

[1] - a529e3cd1f("ovsdb-server: Allow OVSDB clients to specify the UUID for inserted rows.:)

Acked-by: Adrian Moreno <amorenoz@redhat.com>
Acked-by: Han Zhou <hzhou@ovn.org>
Acked-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2022-11-30 15:15:57 +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
Ilya Maximets
429b114c5a ovsdb-data: Deduplicate string atoms.
ovsdb-server spends a lot of time cloning atoms for various reasons,
e.g. to create a diff of two rows or to clone a row to the transaction.
All atoms, except for strings, contains a simple value that could be
copied in efficient way, but duplicating strings every time has a
significant performance impact.

Introducing a new reference-counted structure 'ovsdb_atom_string'
that allows to not copy strings every time, but just increase a
reference counter.

This change allows to increase transaction throughput in benchmarks
up to 2x for standalone databases and 3x for clustered databases, i.e.
number of transactions that ovsdb-server can handle per second.
It also noticeably reduces memory consumption of ovsdb-server.

Next step will be to consolidate this structure with json strings,
so we will not need to duplicate strings while converting database
objects to json and back.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Mark D. Gray <mark.d.gray@redhat.com>
2021-09-24 15:53:46 +02:00
Ilya Maximets
51946d2227 ovsdb-data: Optimize union of sets.
Current algorithm of ovsdb_datum_union looks like this:

  for-each atom in b:
      if not bin_search(a, atom):
          push(a, clone(atom))
  quicksort(a)

So, the complexity looks like this:

   Nb * log2(Na)   +    Nb     +   (Na + Nb) * log2(Na + Nb)
   Comparisons        clones       Comparisons for quicksort
   for search

ovsdb_datum_union() is heavily used in database transactions while
new element is added to a set.  For example, if new logical switch
port is added to a logical switch in OVN.  This is a very common
use case where CMS adds one new port to an existing switch that
already has, let's say, 100 ports.  For this case ovsdb-server will
have to perform:

   1 * log2(100)  + 1 clone + 101 * log2(101)
   Comparisons                Comparisons for
   for search                   quicksort.
       ~7           1            ~707
   Roughly 714 comparisons of atoms and 1 clone.

Since binary search can give us position, where new atom should go
(it's the 'low' index after the search completion) for free, the
logic can be re-worked like this:

  copied = 0
  for-each atom in b:
      desired_position = bin_search(a, atom)
      push(result, a[ copied : desired_position - 1 ])
      copied = desired_position
      push(result, clone(atom))
  push(result, a[ copied : Na ])
  swap(a, result)

Complexity of this schema:

   Nb * log2(Na)   +    Nb     +         Na
   Comparisons        clones       memory copy on push
   for search

'swap' is just a swap of a few pointers.  'push' is not a 'clone',
but a simple memory copy of 'union ovsdb_atom'.

In general, this schema substitutes complexity of a quicksort
with complexity of a memory copy of Na atom structures, where we're
not even copying strings that these atoms are pointing to.

Complexity in the example above goes down from 714 comparisons
to 7 comparisons and memcpy of 100 * sizeof (union ovsdb_atom) bytes.

General complexity of a memory copy should always be lower than
complexity of a quicksort, especially because these copies usually
performed in bulk, so this new schema should work faster for any input.

All in all, this change allows to execute several times more
transactions per second for transactions that adds new entries to sets.

Alternatively, union can be implemented as a linear merge of two
sorted arrays, but this will result in O(Na) comparisons, which
is more than Nb * log2(Na) in common case, since Na is usually
far bigger than Nb.  Linear merge will also mean per-atom memory
copies instead of copying in bulk.

'replace' functionality of ovsdb_datum_union() had no users, so it
just removed.  But it can easily be added back if needed in the future.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Han Zhou <hzhou@ovn.org>
Acked-by: Mark D. Gray <mark.d.gray@redhat.com>
2021-09-24 14:55:54 +02:00
Alexey Roytman
50b0b4d866 db-ctl-base: Warn if "destroy" command lacks --all or record argument.
Signed-off-by: Alexey Roytman <roytman@il.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2021-03-30 15:47:49 -07:00
Ben Pfaff
9513c0233d db-ctl-base: Add {in} and {not-in} set relational operators.
I would have found these useful for the OVN tests.  The {in} operator
is the same as {<=}, but it's still useful to have the alternate syntax
because most of the time we think of set inclusion separately from
set subsets.  The {not-in} operator is different from any existing
operator though.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
2021-02-02 12:59:05 -08:00
Yifeng Sun
720043046d db-ctl-base: Free leaked ovsdb_datum
Valgrind reported:

2491: database commands -- negative checks

==19245== 36 (32 direct, 4 indirect) bytes in 1 blocks are definitely lost in loss record 36 of 53
==19245==    at 0x4C2FD5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19245==    by 0x431AB4: xrealloc (util.c:149)
==19245==    by 0x41656D: ovsdb_datum_reallocate (ovsdb-data.c:1883)
==19245==    by 0x41656D: ovsdb_datum_union (ovsdb-data.c:1961)
==19245==    by 0x4107B2: cmd_add (db-ctl-base.c:1494)
==19245==    by 0x406E2E: do_vsctl (ovs-vsctl.c:2626)
==19245==    by 0x406E2E: main (ovs-vsctl.c:183)

==19252== 16 bytes in 1 blocks are definitely lost in loss record 9 of 52
==19252==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19252==    by 0x430F74: xmalloc (util.c:138)
==19252==    by 0x414D07: clone_atoms (ovsdb-data.c:990)
==19252==    by 0x4153F6: ovsdb_datum_clone (ovsdb-data.c:1012)
==19252==    by 0x4104D3: cmd_remove (db-ctl-base.c:1564)
==19252==    by 0x406E2E: do_vsctl (ovs-vsctl.c:2626)
==19252==    by 0x406E2E: main (ovs-vsctl.c:183)

This patch fixes them.

Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-09-19 09:24:07 -07:00
Ben Pfaff
cf0e423946 db-ctl-base: Give better error messages for ambiguous abbreviations.
Tables and columns may be abbreviated to unique prefixes, but until
now the error messages have just said there's more than one match.
This commit makes the error messages list the possibilities.

Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-09-18 08:42:34 -07:00
Damijan Skvarc
7b34595d88 db-ctl-base: fix memory leak in cmd-get() function
Memory leak occured in case specified key was not found in table
record.

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-07-05 09:53:58 -07:00
Darrell Ball
eb739be2ec db-ctl-base: Fix build with gcc 7.3 with O3.
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-08-03 17:37:05 -07:00
Jakub Sitnicki
a95199f26a db-ctl-base: Propagate errors from the commands parser.
Let the caller decide how to handle the error. Prepare for using the
parser in ovn-nbctl daemon mode.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-23 16:09:43 -07:00
Jakub Sitnicki
6441935951 db-ctl-base: Propagate error from parse_command().
Let the caller handle the error. Needed for ovn-nbctl daemon mode.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-23 16:09:40 -07:00
Jakub Sitnicki
192ab8d8dc db-ctl-base: Don't die in cmd_add() on error.
Return the error via the context instead of calling ctl_fatal() so that
the caller can decide how to handle it.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-09 15:45:32 -07:00
Darrell Ball
5c0dc2fa79 db-ctl-base: Use boolean variable values.
Traditionally, for boolean variables we use boolean values.
Lets keep to that tradition.
Hopefully, using false with a bool works with gcc 6.3.1;
I use both recent versions of gcc (7.3) and older
versions (4.x), but did not see the issue found in
165c1f0649af commit.

Cc: Ian Stokes<ian.stokes@intel.com>
Fixes: 165c1f0649af ("db-ctl-base: Fix compilation warnings.")
Signed-off-by: Darrell Ball <dlu998@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-05 13:49:30 -07:00
Ian Stokes
165c1f0649 db-ctl-base: Fix compilation warnings.
This commit fixes uninitialized variable warnings in functions
cmd_create() and cmd_get() when compiling with gcc 6.3.1 and -Werror
by initializing variables 'symbol' and 'new' to NULL.

Cc: Alex Wang <alexw@nicira.com>
Fixes: 07ff77ccb82a ("db-ctl-base: Make common database command code into library.")
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-05 10:58:57 -07:00
Jakub Sitnicki
e7cd8cfc5a db-ctl-base: Don't die in cmd_destroy() on error.
Return the error via the context instead of calling ctl_fatal() so that
the caller can decide how to handle it.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:20:00 -07:00
Jakub Sitnicki
d0adfd7756 db-ctl-base: Don't die in cmd_clear() on error.
Return the error via the context instead of calling ctl_fatal() so that
the caller can decide how to handle it.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:59 -07:00
Jakub Sitnicki
1c4f051bee db-ctl-base: Don't die in cmd_remove() on error.
Return the error via the context instead of calling ctl_fatal() so that
the caller can decide how to handle it.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:57 -07:00
Jakub Sitnicki
0268e922e2 db-ctl-base: Don't die in cmd_get() on error.
Return the error via the context instead of calling ctl_fatal() so that
the caller can decide how to handle it.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:56 -07:00
Jakub Sitnicki
f06d958c38 db-ctl-base: Kill die_if_error() helper.
All users are gone.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:54 -07:00
Jakub Sitnicki
d4f720a060 db-ctl-base: Fix resource deallocation on error path in cmd_find().
Release resources now that we are returning to the caller on error.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:52 -07:00
Jakub Sitnicki
93e6bda51a db-ctl-base: Fix resource deallocation on error path in cmd_list().
Release resources now that we are returning to the caller on error.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:51 -07:00
Jakub Sitnicki
02c56d5532 db-ctl-base: Fix resource deallocation on error path in cmd_get().
Release resources now that we are returning to the caller on error.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:50 -07:00
Jakub Sitnicki
dd712844a5 db-ctl-base: Stop using die_if_error().
Propagate the error via the context for the caller to handle it.

Result of applying the following semantic patch (Coccinelle):

@@
expression s;
@@
- die_if_error(s);
+ ctx->error = s;
+ if (ctx->error) {
+     return;
+ }

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:48 -07:00
Jakub Sitnicki
675b152e99 db-ctl-base: Extend ctl_context with an error message.
Prepare for the command handlers (pre_cmd_*() cmd_*() functions) to
report errors by storing them in the context.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:46 -07:00
Jakub Sitnicki
fd26f9a2bd db-ctl-base: Don't die in ctl_set_column() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:45 -07:00
Jakub Sitnicki
0e8e4c8f8d db-ctl-base: Don't die in pre_list_columns() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:43 -07:00
Jakub Sitnicki
7ecbc7f618 db-ctl-base: Don't die in pre_parse_column_key_value() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Also, we no longer return the column as it was not used by any of
existing callers.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:41 -07:00
Jakub Sitnicki
c835e58951 db-ctl-base: Don't die in pre_get_table() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:37 -07:00
Jakub Sitnicki
87e2227246 db-ctl-base: Don't die in pre_get_column() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:36 -07:00
Jakub Sitnicki
73c0d4508d db-ctl-base: Don't die in ctl_get_row() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:34 -07:00
Jakub Sitnicki
28fcaca6a4 db-ctl-base: Don't die in get_row_by_id() on multiple matches.
Signal that multiple rows match the record identifier via a new output
parameter instead of reporting the problem and dying, so that the caller
can handle the error without terminating the process if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:29 -07:00
Jakub Sitnicki
9065ca453a db-ctl-base: Don't die in create_symbol() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:02 -07:00
Jakub Sitnicki
79c1a00fb5 db-ctl-base: Don't die in set_column() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:19:01 -07:00
Jakub Sitnicki
e85ec8e8a5 db-ctl-base: Don't die in check_mutable() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:18:59 -07:00
Jakub Sitnicki
e09b3af3e2 db-ctl-base: Don't die in is_condition_satisfied() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Also, rename the function as it is no longer a typical predicate, so
that the users don't assume that the result is passed in return value.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:18:58 -07:00
Jakub Sitnicki
d44cf05efb db-ctl-base: Don't die in get_table() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:18:56 -07:00
Jakub Sitnicki
128ac95e0c db-ctl-base: Don't die in parse_column_names() on error.
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-07-03 13:18:16 -07:00
Ben Pfaff
15f6255fdd ovs-vsctl, ovn-nbctl, ovn-sbctl, vtep-ctl: Parse options before logging.
These utilities logged the command very early, before parsing the options
or the command.  This meant that logging options (like --log-file or
-vsyslog:off) weren't considered for the purpose of logging the command.
This fixes the problem.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
2018-05-25 14:25:54 -07: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
Justin Pettit
bcfed23136 db-ctl-base: Don't shadow 'invalidate_cache' callback.
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
2018-02-28 14:53:32 -08:00
Mark Michelson
8519ea87d7 Refer to database manpages in *ctl manpages
The ovn-nbctl, ovn-sbctl, and ovs-vsctl manpages are inconsistent in
their "Database Commands" section when it comes to referring to what
database tables exist. This commit amends this by making each *ctl
manpage reference the corresponding database manpage instead.

To aid in having a more handy list, the --help text of ovn-nbctl,
ovn-sbctl, and ovs-vsctl have been modified to list the available
tables. This is also referenced in the manpages for those applications.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-02-26 14:19:56 -08:00
Joe Stringer
3eb1423353 ovsdb-idl: Avoid class declaration.
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>
2017-08-15 14:09:40 -07:00
Ben Pfaff
71f21279f6 Eliminate most shadowing for local variable names.
Shadowing is when a variable with a given name in an inner scope hides a
different variable with the same name in a surrounding scope.  This is
generally undesirable because it can confuse programmers.  This commit
eliminates most of it.

Found with -Wshadow=local in GCC 7.  The repo is not really ready to enable
this option by default because of a few cases that are harder to fix, and
harmless, such as nested use of CMAP_FOR_EACH.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
2017-08-02 15:03:35 -07:00
ZhiPeng Lu
d9c59d5b35 db-ctl-base: Fix reference-following feature in get_row_by_id().
If a particular column is supposed to be reached by following a reference
from a UUID column, then that really needs to happen; if there's no
reference, then we're probably starting from a row in the wrong table.

This fixes an assertion failure in command "ovs-vsctl list netflow br0",
if bridge br0 without any netflows.
$ovs-vsctl list netflow br0
ovs-vsctl: lib/ovsdb-idl.c:2407: assertion column_idx < class->n_columns failed
in ovsdb_idl_read()
Aborted

Fixes: 3f5b5f7b4115 ("db-ctl-base: Always support all tables in schema.")
Signed-off-by: Zhipeng Lu <lu.zhipeng@zte.com.cn>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-07-13 17:16:07 -07:00
Ben Pfaff
c2f4c39be4 ovn-sbctl: Add --ovs option to "lflow-list", for listing OpenFlow flows.
This is like the --ovs option to ovn-trace, but it applies to every flow
dumped, so it has different applications.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
2017-05-03 16:18:44 -07:00
Ben Pfaff
bed7aef902 ovn-sbctl: Get rid of redundant code by using function from db-ctl-base.
This renames get_row() to ctl_get_row() and makes it public.  It's
unfortunate that it adds a cast, but getting rid of redundant code seems
worth it to me.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
2017-05-03 16:18:44 -07:00