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

Ladislav Lhotka <lhotka@nic.cz> Tue, 24 May 2016 15:08 UTC

Return-Path: <lhotka@nic.cz>
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 703B612D858 for <core@ietfa.amsl.com>; Tue, 24 May 2016 08:08:57 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -8.426
X-Spam-Level:
X-Spam-Status: No, score=-8.426 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, RP_MATCHES_RCVD=-1.426] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nic.cz
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 yjcVM-4U7hxb for <core@ietfa.amsl.com>; Tue, 24 May 2016 08:08:55 -0700 (PDT)
Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id DEBB112D853 for <core@ietf.org>; Tue, 24 May 2016 08:08:54 -0700 (PDT)
Received: from [IPv6:2001:718:1a02:1:19a:9961:8dbe:3869] (unknown [IPv6:2001:718:1a02:1:19a:9961:8dbe:3869]) by mail.nic.cz (Postfix) with ESMTPSA id 8DA5F617DD; Tue, 24 May 2016 17:08:53 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1464102533; bh=jg1NY7rZQ4qQVbbrC3lHnwUXIN0BNYHfUWmwqS0Xsy0=; h=From:Date:To; b=pAdgzlIpwwe6EiEIrhVbk8REcM8Ok8e4xeeIInJTlgdXsMDeIyvJj3l564LzSdtTc 1Bm5ou00jqsGJ7v1gxCcm+kwEktuocQpK9nHStZ6DdR9YZpshdQdq1+kmqCvu/3U5U TmIl6TUosVXsijV+eWHAnHVgYNVZkWdybKkbXdus=
Content-Type: text/plain; charset="us-ascii"
Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\))
From: Ladislav Lhotka <lhotka@nic.cz>
In-Reply-To: <20160524142924.GB10130@elstar.local>
Date: Tue, 24 May 2016 17:08:58 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <C6C84E10-70FB-4C47-8272-8018F99C2D0E@nic.cz>
References: <CABCOCHRRACvVXx2S_hZm2TxbvP48aO4Q4REkh0LFjmHkMkZ1Vg@mail.gmail.com> <m2y473svm0.fsf@nic.cz> <57401CC2.2040002@tzi.org> <20160521112857.GA4437@elstar.local> <m2zirh81d8.fsf@birdie.labs.nic.cz> <20160524123613.GB9897@elstar.local> <AF6317CD-C9A7-4D7A-A80C-B2DBE0A210A9@nic.cz> <20160524142924.GB10130@elstar.local>
To: Jürgen Schönwälder <j.schoenwaelder@jacobs-university.de>
X-Mailer: Apple Mail (2.3124)
X-Virus-Scanned: clamav-milter 0.98.7 at mail
X-Virus-Status: Clean
Archived-At: <http://mailarchive.ietf.org/arch/msg/core/TsZNYHJl2Nes0yKugCHdMfEQCXU>
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: Tue, 24 May 2016 15:08:57 -0000

> On 24 May 2016, at 16:29, Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de> wrote:
> 
> On Tue, May 24, 2016 at 04:25:13PM +0200, Ladislav Lhotka wrote:
>> 
>>> On 24 May 2016, at 14:36, Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de> wrote:
>>> 
>>> On Mon, May 23, 2016 at 01:22:59PM +0200, Ladislav Lhotka wrote:
>>> 
>>>>> YANG's native serialization of values are untyped strings.
>>>> 
>>>> To my knowledge, this hasn't been stated as a design feature for YANG,
>>>> it's just a side effect of XML being the only serialization that was
>>>> considered when YANG was being designed.
>>> 
>>> We use string representations of values in other contexts, e.g., when
>>> writing pattern restrictions or when evaluating xpath expressions. We
>> 
>> Actually, pattern restrictions are only possible for the "string" type.
>> 
>> And XPath is not limited to strings, we can write, e.g.,
>> 
>>    must ". mod 2 = 0";
> 
> But the expression is at least conceptually evaluated on a string
> representation of what is being interpreted as a number.

Hmm, I would say it's just the other way around: for example, XPath expression "foo = 0" evaluates to true even if "foo" happens to have YANG "string" type and value of "00".

> 
>>> also do define canonical string formats for our types.
>>> 
>>> Note, this does not mean an implementation has store internally all
>>> values as strings but when it matters, the string representation of
>>> values defines the behavior. Except for unions in JSON...
>>> 
>>> My take has been that non-XML encodings may take advantage of being
>>> able to present data mode 'efficiently' (CBOR) or to make it easier
>>> for applications / libraries (JSON). For me, encodings that change how
>>> we interpret types at the YANG level are somewhat surprising.
>> 
>> The problem is that XML, JSON and CBOR are not just different encodings (as in Unicode) but rather different ways for representing structured data, and each has different priorities and semantics. I don't think that "gleichgeschaltetes" JSON or CBOR, where everything is a string, is an attractive option.
> 
> And I did not suggest that. All I said is that encodings should not
> change how the YANG type system works. I continue to find that broken.

I don't think CBOR or JSON really change how YANG type system works. They just provide some extra information that (unfortunately) isn't available in XML serialization. Rather than blaming non-XML serializations, we should think about a generic way for signalling the actual member type that can be used whenever the chosen serialization falls short. If we have, e.g.

leaf foo {
  type union {
    type string;
    type uint8;
  }
}

then it should IMO be possible to pass a number, no matter what the encoding is. So nothing extra needs to be done in JSON and CBOR, but in XML encoding the data could be sent as

<foo member-type="2">42</foo>

Lada  

> 
> /js
> 
> -- 
> Juergen Schoenwaelder           Jacobs University Bremen gGmbH
> Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
> Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C