Re: [netmod] type equivalence

Ladislav Lhotka <ladislav.lhotka@nic.cz> Mon, 22 February 2021 10:00 UTC

Return-Path: <ladislav.lhotka@nic.cz>
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 5107E3A1224 for <netmod@ietfa.amsl.com>; Mon, 22 Feb 2021 02:00:43 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.099
X-Spam-Level:
X-Spam-Status: No, score=-2.099 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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] 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 cWpEwyFtwcMG for <netmod@ietfa.amsl.com>; Mon, 22 Feb 2021 02:00:41 -0800 (PST)
Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2B5C63A1222 for <netmod@ietf.org>; Mon, 22 Feb 2021 02:00:40 -0800 (PST)
Received: from [IPv6:2001:1488:fffe:6:a88f:7eff:fed2:45f8] (unknown [IPv6:2001:1488:fffe:6:a88f:7eff:fed2:45f8]) by mail.nic.cz (Postfix) with ESMTPSA id 30D6413FFA6; Mon, 22 Feb 2021 11:00:37 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1613988037; bh=c35KDUDrpTCvF0U/bDuPjThg2FJowiQyb+CWDV+7NxU=; h=To:From:Date; b=asBbW2fOsI6U/EN0tLsD4hpG0NPmyLNQhFXgKEwxyU9MUAzbaU4J3Yu/WnBetDLUS KjjyAmuzoI/yn2Bh1AiXfn3OjvbJjtmTdRXyV4UTa/IQ+dfJd5BOXrqT8NFc/Mvcm7 ZmnQMnMa7+lXlMBEOyGdNc9sDeqzZY0yO5t0tLqo=
To: Martin Björklund <mbj+ietf@4668.se>, j.schoenwaelder@jacobs-university.de
Cc: netmod@ietf.org
References: <20210219181858.arafmdtraq4ydir2@anna.jacobs.jacobs-university.de> <CD64BB41-E2BE-4B25-AA55-3B91D7C0D313@tzi.org> <20210222092455.qupjm2d4lpm4ay4n@anna.jacobs.jacobs-university.de> <20210222.104938.680142326480637892.id@4668.se>
From: Ladislav Lhotka <ladislav.lhotka@nic.cz>
Organization: CZ.NIC
Message-ID: <552f005f-d636-702b-a82f-efd81abd5f45@nic.cz>
Date: Mon, 22 Feb 2021 11:00:36 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1
MIME-Version: 1.0
In-Reply-To: <20210222.104938.680142326480637892.id@4668.se>
Content-Type: text/plain; charset="utf-8"
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: clamav-milter 0.102.2 at mail
X-Virus-Status: Clean
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/KzFVmiEC-iSxqST5r0MMPHqcJ-4>
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 10:00:43 -0000

On 22. 02. 21 10:49, Martin Björklund wrote:
> 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).

Agreed. Another problem related to sec. 11 is that it permits to update
a module so that the range specification is extended, which may then
expose the incompatibility of e.g. uint8 and int8.

But I thought that Jürgen's question was directed to the definition of
backward compatibility in the semver context.

Lada

> 
> 
> /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
> 
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod
> 

-- 
Ladislav Lhotka
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67