Re: [netmod] type equivalence

Martin Björklund <mbj+ietf@4668.se> Mon, 22 February 2021 09:49 UTC

Return-Path: <mbj+ietf@4668.se>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 1C4C33A11F3 for <netmod@ietfa.amsl.com>; Mon, 22 Feb 2021 01:49:45 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.799
X-Spam-Level:
X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_NAKED_TO_NUMERO=1.999, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=4668.se header.b=Qcddc7bj; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=tca3rEId
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 we0MrC3zSI_g for <netmod@ietfa.amsl.com>; Mon, 22 Feb 2021 01:49:43 -0800 (PST)
Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 96BAD3A11F0 for <netmod@ietf.org>; Mon, 22 Feb 2021 01:49:43 -0800 (PST)
Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id F19345C0081; Mon, 22 Feb 2021 04:49:41 -0500 (EST)
Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 22 Feb 2021 04:49:41 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=4668.se; h=date :message-id:to:cc:subject:from:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm1; bh= HW0wewfENFKkB8K21rbPliGyDqmcv01NUSYgeD0I754=; b=Qcddc7bjzmRSDsi0 1tV79g3Sy5OeycGX8Vy3dC+Jz74VhURNp9KLx0JBscU5uSqkv0XsKbhtwVwcJ6Hv TzDG2pODJe3Vi4YO6+veJwjA15B04F28wbHDR6po8LZvIdqxxElSaOR9O/jM4jcS eMJj3VdcZj7Ayzqi+quc7pVBj/1T6kiCKQqGi76gtbm4NU9P4DR2ObeSqBbzC/uz MimM9OKosdE+x5H382eli/Dd7BHTkAeVuvdP7GUYR2KVADN0+R3lZaI+LKoIDdrF IqmGbdgcCk+niLyHLFbSvk6yB9GmwnqvNTN3rU2AfKotXNpRWfmQlQt3Pg1vts+v JCLxKg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=HW0wewfENFKkB8K21rbPliGyDqmcv01NUSYgeD0I7 54=; b=tca3rEId8j/TZG0tEJPFMxHTobHexIW2GtkZiK97ilag+TpX6seEBOn7Y /+um7BXtuF0/IUduXk3ucGyUGfX/Sq7qjqvOZZqpcR0ph+iK6SCHTC+fhUNu/tPD dJV9LP13sbRMy0EUeeJrmZJ1Z8TnVBNdwdeVa95hG/0UIeK+snyzLamK6YTGTXoU 4to9l7ulGCNVMrQn+W2Ky/RUHqYD7GSVfOzXKXar1r6P2N0VNWdM1hFB1OKiGfWD uij68jjFzR7syvtgwNsEKlHnJd41P3emis2buE2eRrFnsdXgbRDRa2Ca35tNbPNH ierjEd2pTpMPiRuvvECCOhlSO9ZAQ==
X-ME-Sender: <xms:NH4zYDZ86meYLkmho_iY98YeWWVh3RwhusZ1e1WaIFhvRH18sEKV3g> <xme:NH4zYCaDLYjfWbjzyWPWMVTD9-U2LIQTgZLIo1A6UmpueG7tRzFYpAfvgRwNDp5r1 cvI7V1Q4KH77gjX14Y>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrkeefgddtkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffkvffuhfgjfhfogggtgfesthejre dtredtvdenucfhrhhomhepofgrrhhtihhnuceujhpnrhhklhhunhguuceomhgsjhdoihgv thhfseegieeikedrshgvqeenucggtffrrghtthgvrhhnpeffuddtheekgeehteettdehje elieevjeeiheegveffheeguddvffelvdejkefgieenucffohhmrghinhepjhgrtghosghs qdhunhhivhgvrhhsihhthidruggvpdhivghtfhdrohhrghenucfkphepudehkedrudejge drgedrvdduheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpehmsghjodhivghtfhesgeeiieekrdhsvg
X-ME-Proxy: <xmx:NH4zYF9TnbGW-a5qUEXjV_pdEbEMkgfbd-LV2BdHEOxMsqfFAQbtwg> <xmx:NH4zYJpFW3sXi5iu_ltDxlBZbhjbJWRsdMmFOuxsgolkrzhnyOc-kw> <xmx:NH4zYOrCoHjHPDq-44kZn0jx6P0NC17QGr-xVutS1BOS4h9LKbC6Ug> <xmx:NX4zYFTdF9KffPrM5ytFbSrUgd3OKoZt4hn3ZZRqWMU3XvhG2fCDoQ>
Received: from localhost (unknown [158.174.4.215]) by mail.messagingengine.com (Postfix) with ESMTPA id D98DC24005C; Mon, 22 Feb 2021 04:49:39 -0500 (EST)
Date: Mon, 22 Feb 2021 10:49:38 +0100
Message-Id: <20210222.104938.680142326480637892.id@4668.se>
To: j.schoenwaelder@jacobs-university.de
Cc: cabo@tzi.org, netmod@ietf.org
From: Martin Björklund <mbj+ietf@4668.se>
In-Reply-To: <20210222092455.qupjm2d4lpm4ay4n@anna.jacobs.jacobs-university.de>
References: <20210219181858.arafmdtraq4ydir2@anna.jacobs.jacobs-university.de> <CD64BB41-E2BE-4B25-AA55-3B91D7C0D313@tzi.org> <20210222092455.qupjm2d4lpm4ay4n@anna.jacobs.jacobs-university.de>
X-Mailer: Mew version 6.8 on Emacs 26.3
Mime-Version: 1.0
Content-Type: Text/Plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/l1fFrmDd701KI5fSSMlIdqLu578>
Subject: Re: [netmod] type equivalence
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 22 Feb 2021 09:49:45 -0000

Hi,

Section 11 of RFC 7950 says:

   o  A "type" statement may be replaced with another "type" statement
      that does not change the syntax or semantics of the type.  For
      example, an inline type definition may be replaced with a typedef,
      but an int8 type cannot be replaced by an int16, since the syntax
      would change.

If we're just considering XML, then the syntax or encoding wouldn't
change if we went from

  type int64 { range "2..4"; }

to

  type string { pattern "2|3|4"; }

or

  type enumeration {
    enum 2;
    enum 3;
    enum 4;
  }

or

  type union {
    type uint8 { range "2"; }
    type string { pattern "3"; }
    type enumeration { enum 4; }
  }


But I don't think this is reasonable, and not the intention.  I think
that changing the base built-in type always should be considered
non-backwards compatible (which the quoted text above seems to imply).


/martin




Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de> wrote:
> On Fri, Feb 19, 2021 at 10:32:34PM +0100, Carsten Bormann wrote:
> > 
> > 
> > > On 2021-02-19, at 19:18, Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de> wrote:
> > > 
> > > I think the CBOR encoding picks different tags depending on the
> > > signedness of the base type and this is why things are not that simple
> > > anymore.
> > 
> > (This is not the CBOR encoding, but the COMI encoding of keys in URIs.)
> 
> OK. The CBOR document indeed says:
> 
> 6.1.  The unsigned integer Types
> 
>    Leafs of type uint8, uint16, uint32 and uint64 MUST be encoded using
>    a CBOR unsigned integer data item (major type 0).
> 
> 6.2.  The integer Types
> 
>    Leafs of type int8, int16, int32 and int64 MUST be encoded using
>    either CBOR unsigned integer (major type 0) or CBOR negative integer
>    (major type 1), depending on the actual value.
> 
> This means the type 'int8 { range 0..10; }' leads to the same
> encodings as the type 'uint8 { range 0..10; }'.
> 
> > > For the XML and JSON encodings, all definitions lead to the
> > > same on-the-wire representation, hence the difference is more an
> > > implementation detail. I have no clue what the gnmi people do. The
> > > more diverse encodings we add, the more complex things get.
> > 
> > Well, if the equivalence expectation that I was trying to describe actually is ingrained, then whoever designs an encoding (COMI for its URI encoding included) needs to respect it.  That would be important to know.
> > 
> 
> Exactly. I think we never defined this. And of course, this can get
> even more fun if you consider string based encodings. The type
> 
>    type string { pattern "1|2|3|4"; }
> 
> yields the same _XML encoded_ value space as
> 
>    type int32 { range "1..4"; }
> 
> but as far as I recall the JSON/CBOR encodings will treat these two
> differently. So yes, ideally the YANG language would have clear rules
> what YANG's type equivalences are.
> 
> /js
> 
> -- 
> Juergen Schoenwaelder           Jacobs University Bremen gGmbH
> Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
> Fax:   +49 421 200 3103         <https://www.jacobs-university.de/>
> 
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod