diff mbox series

[ovs-dev,1/4] ovsdb: file: Fix inability to read diffs that violate type size.

Message ID 20230725093220.1408301-2-i.maximets@ovn.org
State Accepted
Commit edfbd44ffd623fbc2fcdbcc3a13c7d9e3931aa2a
Headers show
Series ovsdb: Fixes for a set size constraints. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Ilya Maximets July 25, 2023, 9:32 a.m. UTC
Diff records in a database file may contain sets larger than a maximum
set size, so constraints should not be checked on read.  They will be
checked later after applying the diff to a column.

Fixes: 2ccd66f594f7 ("ovsdb: Use column diffs for ovsdb and raft log entries.")
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2023-July/406685.html
Reported-by: Peng He <xnhp0320@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 ovsdb/file.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Dumitru Ceara Aug. 2, 2023, 8:19 p.m. UTC | #1
On 7/25/23 11:32, Ilya Maximets wrote:
> Diff records in a database file may contain sets larger than a maximum
> set size, so constraints should not be checked on read.  They will be
> checked later after applying the diff to a column.
> 
> Fixes: 2ccd66f594f7 ("ovsdb: Use column diffs for ovsdb and raft log entries.")
> Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2023-July/406685.html
> Reported-by: Peng He <xnhp0320@gmail.com>
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> ---

Looks good to me, thanks!

Acked-by: Dumitru Ceara <dceara@redhat.com>
diff mbox series

Patch

diff --git a/ovsdb/file.c b/ovsdb/file.c
index 400b34794..6e7e47ca6 100644
--- a/ovsdb/file.c
+++ b/ovsdb/file.c
@@ -107,7 +107,14 @@  ovsdb_file_update_row_from_json(struct ovsdb_row *row, bool converting,
                                       column_name, schema->name);
         }
 
-        error = ovsdb_datum_from_json(&datum, &column->type, node->data, NULL);
+        if (row_contains_diff) {
+            /* Diff may violate the type size rules. */
+            error = ovsdb_transient_datum_from_json(&datum, &column->type,
+                                                    node->data);
+        } else {
+            error = ovsdb_datum_from_json(&datum, &column->type,
+                                          node->data, NULL);
+        }
         if (error) {
             return error;
         }