Re: [core] Comments on draft-ietf-core-yang-cbor-00

Carsten Bormann <cabo@tzi.org> Sat, 21 May 2016 08:31 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: core@ietfa.amsl.com
Delivered-To: core@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 601A212D534 for <core@ietfa.amsl.com>; Sat, 21 May 2016 01:31:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.62
X-Spam-Level:
X-Spam-Status: No, score=-2.62 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YsJn7MhWo8-l for <core@ietfa.amsl.com>; Sat, 21 May 2016 01:31:04 -0700 (PDT)
Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 79FC012B00F for <core@ietf.org>; Sat, 21 May 2016 01:31:04 -0700 (PDT)
Received: from mfilter28-d.gandi.net (mfilter28-d.gandi.net [217.70.178.159]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 0FF0DA80DF; Sat, 21 May 2016 10:31:03 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mfilter28-d.gandi.net
Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter28-d.gandi.net (mfilter28-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id ubhW2ayaZW6W; Sat, 21 May 2016 10:31:01 +0200 (CEST)
X-Originating-IP: 93.199.242.26
Received: from nar-3.local (p5DC7F21A.dip0.t-ipconnect.de [93.199.242.26]) (Authenticated sender: cabo@cabo.im) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 7A8D1A80D2; Sat, 21 May 2016 10:31:00 +0200 (CEST)
Message-ID: <57401CC2.2040002@tzi.org>
Date: Sat, 21 May 2016 10:30:58 +0200
From: Carsten Bormann <cabo@tzi.org>
User-Agent: Postbox 4.0.8 (Macintosh/20151105)
MIME-Version: 1.0
To: Ladislav Lhotka <lhotka@nic.cz>
References: <CABCOCHRRACvVXx2S_hZm2TxbvP48aO4Q4REkh0LFjmHkMkZ1Vg@mail.gmail.com> <m2y473svm0.fsf@nic.cz>
In-Reply-To: <m2y473svm0.fsf@nic.cz>
X-Enigmail-Version: 1.2.3
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Archived-At: <http://mailarchive.ietf.org/arch/msg/core/I-weDkIV2Qg_t8Tg_WM3Q_7zAPA>
Cc: Core <core@ietf.org>
Subject: Re: [core] Comments on draft-ietf-core-yang-cbor-00
X-BeenThere: core@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: "Constrained RESTful Environments \(CoRE\) Working Group list" <core.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/core>, <mailto:core-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/core/>
List-Post: <mailto:core@ietf.org>
List-Help: <mailto:core-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/core>, <mailto:core-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 21 May 2016 08:31:06 -0000

Ladislav Lhotka wrote:
> The receiving side will resolve the union type by the first union member
> type that matches the CBOR-encoded value. It's the same as in JSON encoding.

Or, at least, similar -- we are not always making the same serialization
decisions.

The weird aspect of this part of YANG is that the actual validity (and
specific semantics and thus usefulness) of a union in the YANG module
depends on the specifics of the serialization below.
More frankly: Tying the semantics of a modeling language to one specific
serialization mechanism is an utterly broken design.
I'm not sure that it can be fixed, though, so we'll likely have to work
around this breakage.

What we were trying to figure out was the extent of the situations where
a YANG module specifier might rely on the XML-specific way of resolving
unions.

Examples that seem painful:

1)

 type union {
      type enumeration {
         enum one; /* value 0 */
         enum two; /* value 1 */
      }
      type uint32;
 }

Here, the XML will have the string "one" or "two", or a decimal string,
which is unambiguous.  The JSON encoding also has the string for
enumerations, which we obviously want to replace by the numeric value in
a compact encoding.

We were thinking about possibly adding CBOR tags to disambiguate this.
This becomes more insidious if this is an evolution from an earlier
version that just said:

 type enumeration {
   ...
 }

(We wouldn't want to sprinkle in tags just in case a type might possibly
evolve into a union later.)

2)

Also, just having a tag saying "this is an enumeration value" does not
work for this case:

 type union {
      type enumeration {
         enum one; /* value 0 */
         enum two; /* value 1 */
      }
      type enumeration {
         enum alpha; /* value 0 */
         enum beta; /* value 1 */
      }
 }

We haven't found a way yet to tag this case that is robust against
further evolution of the YANG module.

Clearly, YANG module specifiers will not rely on this when they are
cognizant of concise encodings.  However, relying on specification
writers not doing this would mean that YANG modules have to be vetted
for mistakes of this kind before they can be used in a CBOR environment
after an exclusively XML/JSON life.  (Maybe that actually *is* the
answer -- if we could get pyang to detect this case and issue a warning,
that might be enough.)

Grüße, Carsten