From patchwork Tue Sep 19 22:00:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 815916 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxd4t2hqgz9sNV for ; Wed, 20 Sep 2017 08:35:58 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3CF7EDDD; Tue, 19 Sep 2017 22:24:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id CB33DBF8 for ; Tue, 19 Sep 2017 22:24:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from slow1-d.mail.gandi.net (slow1-d.mail.gandi.net [217.70.178.86]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 702BC20C for ; Tue, 19 Sep 2017 22:24:48 +0000 (UTC) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by slow1-d.mail.gandi.net (Postfix) with ESMTP id 08407534EB1 for ; Wed, 20 Sep 2017 00:02:10 +0200 (CEST) X-Originating-IP: 208.91.2.3 Received: from sigabrt.benpfaff.org (unknown [208.91.2.3]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 4CE541720A3; Wed, 20 Sep 2017 00:02:08 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Tue, 19 Sep 2017 15:00:57 -0700 Message-Id: <20170919220125.32535-25-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170919220125.32535-1-blp@ovn.org> References: <20170919220125.32535-1-blp@ovn.org> X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH RFC 24/52] ovsdb-client: Show even invalid data in "dump" output. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- 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)); } }