Re: [Cbor] CBOR-YANG representation of common types

Maria Matejka <maria.matejka@nic.cz> Tue, 02 January 2024 17:46 UTC

Return-Path: <maria.matejka@nic.cz>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D6725C14CF17 for <cbor@ietfa.amsl.com>; Tue, 2 Jan 2024 09:46:18 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.105
X-Spam-Level:
X-Spam-Status: No, score=-2.105 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, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=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 ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Yw0mBGyPK6n9 for <cbor@ietfa.amsl.com>; Tue, 2 Jan 2024 09:46:14 -0800 (PST)
Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 702E5C14F71D for <cbor@ietf.org>; Tue, 2 Jan 2024 09:46:13 -0800 (PST)
Received: from [IPV6:2001:1488:fffe:6:ffff:ffff:fffe:4] (unknown [IPv6:2001:1488:fffe:6:ffff:ffff:fffe:4]) by mail.nic.cz (Postfix) with ESMTPSA id 159AD1C0353; Tue, 2 Jan 2024 18:46:08 +0100 (CET)
Authentication-Results: mail.nic.cz; auth=pass smtp.auth=maria.matejka@nic.cz smtp.mailfrom=maria.matejka@nic.cz
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1704217569; bh=uB1KIa3HCMmGNINRippLnzE2FPeegbDgUxeph2KvOHc=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From:Reply-To: Subject:To:Cc; b=rGx9Nvo7Z4ILk/lq3/kChCj16432nl0MP0DAoSaEXPOUbjRBs+xxmNwWICFfnNTZV pxNfwau9+1MqyaEwu/9bbYO1e89cW0Xl+QLJwhM2fuPooiQtarIipIrJhJ073mqn/0 phGeR+1zrQj+/3Igp7v1qlV9ojNMYPm+LIqc1bno=
Content-Type: multipart/alternative; boundary="------------0wg7LB4Tsszei9lpIcP43yp0"
Message-ID: <235c1ce9-64e2-4d67-9561-af505d4b454b@nic.cz>
Date: Tue, 02 Jan 2024 18:46:07 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US, cs
From: Maria Matejka <maria.matejka@nic.cz>
To: Carsten Bormann <cabo@tzi.org>
Cc: cbor@ietf.org, Kateřina Kubecová <katerina.kubecova@nic.cz>, vojtech.vilimek@nic.cz, Laurent Toutain <laurent.toutain@imt-atlantique.fr>, Michael Richardson <mcr+ietf@sandelman.ca>
References: <77159997-0cc1-4b5d-9a1d-cc61f3d0be73@nic.cz> <D2E0DEDC-F078-4430-B54B-29BAFBAEDAD1@tzi.org> <ce42506f-49b8-4b5f-a92d-cf3142a29095@nic.cz>
In-Reply-To: <ce42506f-49b8-4b5f-a92d-cf3142a29095@nic.cz>
X-Virus-Scanned: clamav-milter 0.103.10 at mail
X-Virus-Status: Clean
X-Rspamd-Queue-Id: 159AD1C0353
X-Spamd-Bar: /
X-Spamd-Result: default: False [-0.10 / 20.00]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; WHITELISTED_IP(0.00)[2001:1488:fffe:6:ffff:ffff:fffe:4]; MIME_TRACE(0.00)[0:+,1:+,2:~]; TAGGED_RCPT(0.00)[ietf]; ASN(0.00)[asn:25192, ipnet:2001:1488::/32, country:CZ]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]
X-Rspamd-Action: no action
X-Rspamd-Pre-Result: action=no action; module=multimap; Matched map: WHITELISTED_IP
X-Rspamd-Server: mail
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/HfhBa27K3SaA6ar-S1Fkc4n7nsc>
Subject: Re: [Cbor] CBOR-YANG representation of common types
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 02 Jan 2024 17:46:18 -0000

Hello Carsten and others,

On 2023-11-14 19:47, Maria Matejka wrote:
> On 2023-11-14 19:02, Carsten Bormann wrote:
>> On 2023-11-14, at 17:54, Maria Matejka<maria.matejka=40nic.cz@dmarc.ietf.org>  wrote:
>>> Dear CBOR WG,
>>>
>>> we're currently trying to embrace the CBOR described by YANG in BIRD interface and we're struggling with the representation of certain types like date, time, IP address or prefix. We would assume that if there is RFC 9164 or RFC 8943, we shall then encode dates or IP addresses in these defined formats in CBOR and they shall get converted between CBOR and JSON/XML appropriately. But I can't find any RFC on this, nor any implementation of CBOR-JSON convertor.
>> These types are all defined as text string types in RFC 6991 etc. (and RFC 6991bis does not change anything about this).
>> RFC 9254 defines a basic representation of YANG in CBOR, not trying to change this.
[snip]
>> There definitely is discussion, as the representation of these types as a CBOR text string is inefficient (with respect to both space and CPU time).
>>
>>> 	• Is there any RFC on draft on this? If not, we're probably gonna create one. We need it
>> Writing up a proposal is on my to do list.
I was thinking about how such a proposal should look like … [snip]
>>
>> This can use tags from RFC 8949, RFC 9164, RFC 9090; we probably need to discuss little details such as whether tag 23 can be used for hex-string.
>
> These are the most needed, surely, at least for us. Anyway, other 
> RFC's and drafts tend to define additional types as strings (yes, I'm 
> looking at you, BGP YANG draft) so what I'd like to see, is not only 
> explicit definition of these, but maybe also a future requirement or 
> at least some extension of YANG itself, to allow for defining some 
> type both as a string in JSON and XML, and as a specific format in 
> CBOR, e.g. like this:
>
> typedef ipv6-address-no-zone {
>   type string { … };
>   compact type {
>     tag 54;
>     blob;
>   };
> }
>
> typedef ipv6-prefix {
>   type string { … };
>   compact type {
>     tag 54;
>     uint length;
>     blob prefix;
>   };
> }
>
> but it inevitably leads to weird problems where the CBOR 
> representation is more structured and in fact is a grouping. I'm not 
> sure yet how to handle this but I still refuse to believe that we're 
> all screwed into the string representation, this way the other way 
> around compared to the ****** with SNMP MIBs.
>
… and what I'm coming to, is standardizing a YANG extension. And before 
I slide down the rabbit hole, I'd like to check that it makes any sense 
at all.

The problem is that these "canonical extended types" are actually 
defined as YANG derived types (typedef) by RFC 6991, so adding some 
update to RFC 9254 doesn't look like a viable option by itself, because 
it would need the CBOR-capable transcoders to selectively ignore these 
core parts of the YANG ecosystem. This smells to me of adding more worms 
to an already full can.

Also, I'd like to be futureproof – if somebody finds a new, better 
format to store structured data, they shall have a possibility to define 
these RFC-6991 types. The same goes with other types defined externally 
– if somebody wants to define a type which is "just a binary blob 
usually formatted in a fancy way", which IP addresses definitely are, 
I'd like to provide them with a standardized possibility to actually 
define them as (tagged) blobs for CBOR.

So I'm proposing to define a extension based on RFC 6020, § 7.17:

module cbor {
   extension tag {
     description "This type or container SHOULD be encoded in CBOR as a 
structure with this tag";
     argument number;
   }
}

… eh, but this requires the number to be written as a string, shame. Is 
it worth making the draft also to update RFC 6020, to add a "type" 
option to the "extension" clause, to allow for writing typedef 
ipv6-prefix { type string { … }; cbor:tag 54 } without the quotes?

And then we shall update RFC 6991 by adding these tags. The actual 
representation is needed to be implemented by CBOR transcoders anyway, 
so we don't have to bother about what is hidden behind the tag number … 
or should we?

This way, the draft would have 3 parts (apart from the needed headers, 
footers and so):

 1. Update to RFC 6020 to allow for typed extension argument
 2. Definition of the cbor encoding module using the updated extension
    definition
 3. Update to RFC 6991 stating all the tags involved

I'll be happy if I get some feedback to this idea before I actually 
start typing the draft and implementing this in our tooling to showcase 
that it indeed works.

Thank you and sorry for writing obnoxiously long sentences and have a 
very happy new year (if your new year started yesterday as well as mine)!

Maria

-- 
Maria Matejka (she/her) | BIRD Team Leader | CZ.NIC, z.s.p.o.