2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00

ovsdb-client: Show even constraint-breaking data in "dump" output.

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>
This commit is contained in:
Ben Pfaff 2017-12-08 12:36:57 -08:00
parent 80f66ee041
commit 9041097aee
3 changed files with 24 additions and 3 deletions

View File

@ -1341,6 +1341,23 @@ ovsdb_transient_datum_from_json(struct ovsdb_datum *datum,
return ovsdb_datum_from_json(datum, &relaxed_type, json, NULL); 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 * static struct json *
ovsdb_base_to_json(const union ovsdb_atom *atom, ovsdb_base_to_json(const union ovsdb_atom *atom,
const struct ovsdb_base_type *base, const struct ovsdb_base_type *base,

View File

@ -173,6 +173,11 @@ struct ovsdb_error *ovsdb_transient_datum_from_json(
const struct ovsdb_type *, const struct ovsdb_type *,
const struct json *) const struct json *)
OVS_WARN_UNUSED_RESULT; 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 *, struct json *ovsdb_datum_to_json(const struct ovsdb_datum *,
const struct ovsdb_type *); const struct ovsdb_type *);

View File

@ -1312,9 +1312,8 @@ dump_table(const char *table_name, const struct shash *cols,
y, table_name, columns[x]->name); y, table_name, columns[x]->name);
} }
check_ovsdb_error(ovsdb_datum_from_json(&data[y][x], check_ovsdb_error(ovsdb_unconstrained_datum_from_json(
&columns[x]->type, &data[y][x], &columns[x]->type, json));
json, NULL));
} }
} }