Re: [ovs-dev] [PATCH v2 3/9] ovsdb: table: Expose functions to execute operations on ovsdb tables.

2021-06-25 Thread Dumitru Ceara
On 6/12/21 4:00 AM, Ilya Maximets wrote:
> 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.
> 
> Signed-off-by: Ilya Maximets 
> ---

Acked-by: Dumitru Ceara 

Thanks!

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v2 3/9] ovsdb: table: Expose functions to execute operations on ovsdb tables.

2021-06-19 Thread Mark Gray
On 12/06/2021 03:00, Ilya Maximets wrote:
> 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.
> 
> Signed-off-by: Ilya Maximets 

Acked-by: Mark D. Gray 

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH v2 3/9] ovsdb: table: Expose functions to execute operations on ovsdb tables.

2021-06-11 Thread Ilya Maximets
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.

Signed-off-by: Ilya Maximets 
---
 ovsdb/replication.c | 83 -
 ovsdb/table.c   | 69 +
 ovsdb/table.h   | 14 
 3 files changed, 90 insertions(+), 76 deletions(-)

diff --git a/ovsdb/replication.c b/ovsdb/replication.c
index bb1bd4250..b755976b0 100644
--- a/ovsdb/replication.c
+++ b/ovsdb/replication.c
@@ -54,18 +54,6 @@ static struct ovsdb_error *process_table_update(struct json 
*table_update,
 const char *table_name,
 struct ovsdb *database,
 struct ovsdb_txn *txn);
-
-static struct ovsdb_error *execute_insert(struct ovsdb_txn *txn,
-  const struct uuid *row_uuid,
-  struct ovsdb_table *table,
-  struct json *new);
-static struct ovsdb_error *execute_delete(struct ovsdb_txn *txn,
-  const struct uuid *row_uuid,
-  struct ovsdb_table *table);
-static struct ovsdb_error *execute_update(struct ovsdb_txn *txn,
-  const struct uuid *row_uuid,
-  struct ovsdb_table *table,
-  struct json *new);
 
 /* Maps from db name to sset of table names. */
 static struct shash excluded_tables = SHASH_INITIALIZER(_tables);
@@ -687,77 +675,20 @@ process_table_update(struct json *table_update, const 
char *table_name,
 new = shash_find_data(json_object(row_update), "new");
 
 struct ovsdb_error *error;
-error = (!new ? execute_delete(txn, , table)
- : !old ? execute_insert(txn, , table, new)
- : execute_update(txn, , table, new));
+error = (!new ? ovsdb_table_execute_delete(txn, , table)
+ : !old ? ovsdb_table_execute_insert(txn, , table, new)
+ : ovsdb_table_execute_update(txn, , table, new));
 if (error) {
+if (!strcmp(ovsdb_error_get_tag(error), "consistency violation")) {
+ovsdb_error_assert(error);
+error = NULL;
+}
 return error;
 }
 }
 return NULL;
 }
 
-static struct ovsdb_error *
-execute_insert(struct ovsdb_txn *txn, const struct uuid *row_uuid,
-   struct ovsdb_table *table, struct json *json_row)
-{
-struct ovsdb_row *row = ovsdb_row_create(table);
-struct ovsdb_error *error = ovsdb_row_from_json(row, json_row, NULL, NULL);
-if (!error) {
-*ovsdb_row_get_uuid_rw(row) = *row_uuid;
-ovsdb_txn_row_insert(txn, row);
-} else {
-static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
-VLOG_WARN_RL(, "cannot add existing row "UUID_FMT" to table %s",
- UUID_ARGS(row_uuid), table->schema->name);
-ovsdb_row_destroy(row);
-}
-
-return error;
-}
-
-static struct ovsdb_error *
-execute_delete(struct ovsdb_txn *txn, const struct uuid *row_uuid,
-   struct ovsdb_table *table)
-{
-const struct ovsdb_row *row = ovsdb_table_get_row(table, row_uuid);
-if (row) {
-ovsdb_txn_row_delete(txn, row);
-} else {
-static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
-VLOG_WARN_RL(, "cannot delete missing row "UUID_FMT" from table %s",
- UUID_ARGS(row_uuid), table->schema->name);
-}
-return NULL;
-}
-
-static struct ovsdb_error *
-execute_update(struct ovsdb_txn *txn, const struct uuid *row_uuid,
-   struct ovsdb_table *table, struct json *json_row)
-{
-const struct ovsdb_row *row = ovsdb_table_get_row(table, row_uuid);
-if (!row) {
-static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
-VLOG_WARN_RL(, "cannot modify missing row "UUID_FMT" in table %s",
- UUID_ARGS(row_uuid), table->schema->name);
-return NULL;
-}
-
-struct ovsdb_column_set columns = OVSDB_COLUMN_SET_INITIALIZER;
-struct ovsdb_row *update = ovsdb_row_create(table);
-struct ovsdb_error *error = ovsdb_row_from_json(update, json_row,
-NULL, );
-
-if (!error && !ovsdb_row_equal_columns(row, update, )) {
-