]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ovsdb-client: Show even constraint-breaking data in "dump" output.
authorBen Pfaff <blp@ovn.org>
Fri, 8 Dec 2017 20:36:57 +0000 (12:36 -0800)
committerBen Pfaff <blp@ovn.org>
Fri, 22 Dec 2017 19:51:47 +0000 (11:51 -0800)
The ovsdb-client "dump" command is a fairly low-level tool that can be
used, among other purposes, to debug the OVSDB protocol.  It's better if
it just prints what the server sends without being too judgmental about it.
Thus, we might as well ignore constraints for the purpose of dumping
tables.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
lib/ovsdb-data.c
lib/ovsdb-data.h
ovsdb/ovsdb-client.c

index cdd1bb6530dad1a411146d1ecc8028d1613bfe9f..87d8effd1d677c639f37c640672bfd54d0f38f43 100644 (file)
@@ -1341,6 +1341,23 @@ ovsdb_transient_datum_from_json(struct ovsdb_datum *datum,
     return ovsdb_datum_from_json(datum, &relaxed_type, json, NULL);
 }
 
+/* Parses 'json' as a datum of the type described by 'type', but ignoring all
+ * constraints. */
+struct ovsdb_error * OVS_WARN_UNUSED_RESULT
+ovsdb_unconstrained_datum_from_json(struct ovsdb_datum *datum,
+                                    const struct ovsdb_type *type,
+                                    const struct json *json)
+{
+    struct ovsdb_type relaxed_type;
+
+    ovsdb_base_type_init(&relaxed_type.key, type->key.type);
+    ovsdb_base_type_init(&relaxed_type.value, type->value.type);
+    relaxed_type.n_min = 0;
+    relaxed_type.n_max = UINT_MAX;
+
+    return ovsdb_datum_from_json(datum, &relaxed_type, json, NULL);
+}
+
 static struct json *
 ovsdb_base_to_json(const union ovsdb_atom *atom,
                    const struct ovsdb_base_type *base,
index 84639c4a3ecfccb76577d6572bb9d345965d5cf7..c842fe28fc1ae35709d2cc9339bbe7f55ae24d5b 100644 (file)
@@ -173,6 +173,11 @@ struct ovsdb_error *ovsdb_transient_datum_from_json(
                                           const struct ovsdb_type *,
                                           const struct json *)
     OVS_WARN_UNUSED_RESULT;
+struct ovsdb_error *
+ovsdb_unconstrained_datum_from_json(struct ovsdb_datum *,
+                                    const struct ovsdb_type *,
+                                    const struct json *)
+    OVS_WARN_UNUSED_RESULT;
 struct json *ovsdb_datum_to_json(const struct ovsdb_datum *,
                                  const struct ovsdb_type *);
 
index 947cad0c7bbba2854bfc12cb630ed7599243390e..f930c0e09ab88a546fc80485a5d5bebd56f4d6f1 100644 (file)
@@ -1312,9 +1312,8 @@ dump_table(const char *table_name, const struct shash *cols,
                           y, table_name, columns[x]->name);
             }
 
-            check_ovsdb_error(ovsdb_datum_from_json(&data[y][x],
-                                                    &columns[x]->type,
-                                                    json, NULL));
+            check_ovsdb_error(ovsdb_unconstrained_datum_from_json(
+                                  &data[y][x], &columns[x]->type, json));
         }
     }