Re: [netconf] [core] YANG encoding in CBOR

Andy Bierman <andy@yumaworks.com> Sun, 24 March 2019 11:30 UTC

Return-Path: <andy@yumaworks.com>
X-Original-To: netconf@ietfa.amsl.com
Delivered-To: netconf@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id E4EB8128BE6 for <netconf@ietfa.amsl.com>; Sun, 24 Mar 2019 04:30:00 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=unavailable autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=yumaworks-com.20150623.gappssmtp.com
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 YY6z1QESDe6F for <netconf@ietfa.amsl.com>; Sun, 24 Mar 2019 04:29:59 -0700 (PDT)
Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 973DB1279AF for <netconf@ietf.org>; Sun, 24 Mar 2019 04:29:58 -0700 (PDT)
Received: by mail-lf1-x134.google.com with SMTP id v14so4210377lfi.0 for <netconf@ietf.org>; Sun, 24 Mar 2019 04:29:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yumaworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=86u4rCtozzj8VkUZGpOwDr1VvmXXNVeMmeKVB4jZp0Y=; b=ed+RnGxUruuJ5yZMRXzBODo9flZKHhCQEf6zB25R2PpEujTh4BgwyzfbJ4nMsmVWoQ lu+gVzClXcfmqlVxmaMJdw1Dsw+R+VtbomLkX0PHeWN/oBCMHyDmQDLw7YJZwerWoMND Nx38i39gY7YFId7Yfdue1mg1b4+JujpWfF2j0/XDADm6XFmEH2JMr0RVFn6m3TCy3sQJ Nuz6+4qXg5xaY97Y1YW4EAVpRtLToC6qNrgeI4vaEIxm2iLWnDNr5u7esHXt0i3HUBqn 9WO4TkOndg3yubMqYRu76Ex5GHoukBO9aQRw4lhuFhN5hb6PM/mgspxPSVFz/TJNT+C1 ynYg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=86u4rCtozzj8VkUZGpOwDr1VvmXXNVeMmeKVB4jZp0Y=; b=AGrDnTCbQfUiUOeUA1uaZl9vCZgvqLEJqHsVhmrSl5buT/FfA0ezYnPw01mqjLEJwR cIt32UyPCPHcZ7XyTn5dFdamCalCXtpYx/vujidGmZUbLDIR/Ox2DxxGSYUfnNPWyuHm k3Fo94iuygwJVJn5BYLRQirboQWbC8D1PbaB2+SsBr6K/7ezflvudWCU+fU0mFb1Nlwo qt3Dp/8ZTDM15lnxeclOfJT/OpJFOyHJGuxFsy2yHmIWhlAEDN5D0gnBvUMK66ZLFSOl ANRcLsBS+c5RlCFXFfb7aObLJI4uRJCA/WWZ3bP0hs7vp1RosHRJ+hO+zwxsBySzmw7N 3+iA==
X-Gm-Message-State: APjAAAVDympBcZManw9lNXkpnxOSzgPLUia1ROqW5BcE45a0kWAtXtQz CEcfb0xQ3vB3Kb/SXFK9AkHy4UHVWbnakKm0nMPkKA==
X-Google-Smtp-Source: APXvYqxXyt4mZu+8LXD+16/Omjo/DtPZNlwK9g9seEjVPHxQCvDmFIzNinkW7LdjCkr64k37KqBmwQNo80yYwQbZAC8=
X-Received: by 2002:ac2:569b:: with SMTP id 27mr10336213lfr.24.1553426996571; Sun, 24 Mar 2019 04:29:56 -0700 (PDT)
MIME-Version: 1.0
References: <6235c6683ff14848a661f8b8cec94280@XCH-RCD-007.cisco.com> <BL0PR06MB5042823429DB7CDA0F33408B9A430@BL0PR06MB5042.namprd06.prod.outlook.com> <588401AB-483E-40F5-95BB-20A066E56DAC@tzi.org> <15fbaf84b20343a1b83f40b571149a14@XCH-RCD-007.cisco.com> <1ADF8201-ABB4-44FD-A515-F3F8E0DBF5FC@tzi.org> <20190323101003.gp3zvsvqqwc26jip@anna.jacobs.jacobs-university.de> <6BAAAC0E-F91B-411B-8768-F628C57FF2E0@tzi.org> <20190323133519.nv6sw72upxchr7p3@anna.jacobs.jacobs-university.de> <3D7C33C9-CB86-4965-899D-93C4B7343DF7@tzi.org>
In-Reply-To: <3D7C33C9-CB86-4965-899D-93C4B7343DF7@tzi.org>
From: Andy Bierman <andy@yumaworks.com>
Date: Sun, 24 Mar 2019 04:29:45 -0700
Message-ID: <CABCOCHRcEPUB=Yf2Vdf6ZpN-SxjYeMPL_54-EKMYSpUO9b-RwA@mail.gmail.com>
To: Carsten Bormann <cabo@tzi.org>
Cc: Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>, "netconf@ietf.org" <netconf@ietf.org>, "core@ietf.org" <core@ietf.org>
Content-Type: multipart/alternative; boundary="00000000000050d1ab0584d56848"
Archived-At: <https://mailarchive.ietf.org/arch/msg/netconf/6WcHzrnOa1OyrcAwEBS7JrVZtXk>
Subject: Re: [netconf] [core] YANG encoding in CBOR
X-BeenThere: netconf@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETCONF WG list <netconf.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netconf>, <mailto:netconf-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netconf/>
List-Post: <mailto:netconf@ietf.org>
List-Help: <mailto:netconf-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netconf>, <mailto:netconf-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 24 Mar 2019 11:30:01 -0000

On Sun, Mar 24, 2019 at 2:47 AM Carsten Bormann <cabo@tzi.org> wrote:

> On Mar 23, 2019, at 14:35, Juergen Schoenwaelder <
> j.schoenwaelder@jacobs-university.de> wrote:
> >
> > RFC 7950 section 9.12:
>
> Thank you, this is very useful.
>
> Let me try to ask my other question in a very concrete way:
>
> If I have
>
> > typedef foo {
> >  type union {
> >    type enumeration {
> >      enum red { value 1; }
> >      enum breen { value 2; }
> >      enum glue { value 3; }
> >    }
> >    type enumeration {
> >      enum tacks { value 1; }
> >      enum nails { value 2; }
> >      enum glue { value 3; }
> >    }
> >  }
> > }
>
> in one place, and
>
> > typedef bar {
> >  type union {
> >    type enumeration {
> >      enum red { value 1; }
> >      enum breen { value 2; }
> >      enum glue { value 3; }
> >    }
> >    type enumeration {
> >      enum sparkling { value 1; }
> >      enum blinking { value 2; }
> >      enum steady { value 3; }
> >    }
> >  }
> > }
>
> in another place, is the value “red” between the two types referring to
> the “same thing”?
>
>

no -- and this is not an error, although it is position-dependent:

  typedef baz {
     type union {
       type foo;
       type bar;
    }
  }

The issue for CBOR applies to both bits and enumerations.
The probability of 2 enum names clashing is almost zero.
The probability of 2 value-stmts clashing is almost 100%

The answer seems to be simple but inefficient:
Always encode bits or enumeration as a string, if this is within a union
type.
There are not many of these -- more likely to find strings with different
patterns
where first-match-wins is no different than before (for XML)


> If there were a typedef for the two anonymous enumerations that both look
> the same, as in
>
>   typedef color {
> >    type enumeration {
> >      enum red { value 1; }
> >      enum breen { value 2; }
> >      enum glue { value 3; }
> >    }
>   }
>
> and that typedef being referenced from both unions instead of copy-pasting
> it, would that change the answer?
>
>

I think first-match-wins still dictates the result.

The JSON issue (and maybe CBOR) is what Juergen is talking about:

    typedef maybe-first {
       type union {
           type string;
           type int32;
        }
     }

Use 42 as an example...
The XML encoding <foo>42</foo> will always match string.
The JSON (or CBOR) encoding { "foo": 42 } will always match int32
We want YANG data to maintain fidelity and still be encoding-independent,
but this is broken for union types.


Grüße, Carsten
>
>
Andy


> _______________________________________________
> core mailing list
> core@ietf.org
> https://www.ietf.org/mailman/listinfo/core
>