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.

Signed-off-by: Ben Pfaff <b...@ovn.org>
---
 lib/ovsdb-data.c     | 17 +++++++++++++++++
 lib/ovsdb-data.h     |  5 +++++
 ovsdb/ovsdb-client.c |  5 ++---
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c
index 3ddf5f5bd539..711d84d9badc 100644
--- a/lib/ovsdb-data.c
+++ b/lib/ovsdb-data.c
@@ -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);
+}
+
 /* Converts 'datum', of the specified 'type', to JSON format, and returns the
  * JSON.  The caller is responsible for freeing the returned JSON.
  *
diff --git a/lib/ovsdb-data.h b/lib/ovsdb-data.h
index 72c8fe35bce3..257e58e2a653 100644
--- a/lib/ovsdb-data.h
+++ b/lib/ovsdb-data.h
@@ -169,6 +169,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 *datum,
+                                    const struct ovsdb_type *type,
+                                    const struct json *json)
+    OVS_WARN_UNUSED_RESULT;
 struct json *ovsdb_datum_to_json(const struct ovsdb_datum *,
                                  const struct ovsdb_type *);
 
diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index 76c2cdf4dd23..41b9727b12b9 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -1231,9 +1231,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));
         }
     }
 
-- 
2.10.2

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

Reply via email to