Re: [netmod] [core] CBOR YANG encoding of union & bits [draft-ietf-core-yang-cbor-12]

Andy Bierman <andy@yumaworks.com> Fri, 08 May 2020 15:51 UTC

Return-Path: <andy@yumaworks.com>
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 35C913A0BB5 for <netmod@ietfa.amsl.com>; Fri, 8 May 2020 08:51:54 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.887
X-Spam-Level:
X-Spam-Status: No, score=-1.887 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01, URIBL_BLOCKED=0.001] autolearn=ham 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 1oWKmWgjw3nZ for <netmod@ietfa.amsl.com>; Fri, 8 May 2020 08:51:52 -0700 (PDT)
Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) (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 68D3E3A0BB2 for <netmod@ietf.org>; Fri, 8 May 2020 08:51:52 -0700 (PDT)
Received: by mail-yb1-xb30.google.com with SMTP id w19so1162006ybs.5 for <netmod@ietf.org>; Fri, 08 May 2020 08:51:52 -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=mY87m/tJI7hneJvMdWPXq8YJTENVCkCa3y80ZFMOnuQ=; b=dcJfFpHIdtUu4vuEL6TjWZnxbIimG7vEEPKaiKzPuae1gWXOrCoxRocZKTQVgyut0g bvQW6XDdb1gOpZhrWXEscZk0jnKsTgWRrQLW4/HplGohoEhkgL3EaGI3wDpSH2o7IYJG ct0b9oHmv4NcM3DAN13rryAUvr9mo/i6pTQuOdsN/UV4jyTggrxZwZVfvl8ylBbsUtix c/crbg00ZkDSqZgg81gaSXjqacTGcCLjXlqoyMMjiwwpoaeLrgXfKzBhVGQQ/lIEgl0P Y3g5GJxXNBmmf0PNnIXXNQOLKJ1zSHF3Q7Kx6mHUwOW7MGX3fpkmYweH7FbB1cnLHIds 5Qzw==
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=mY87m/tJI7hneJvMdWPXq8YJTENVCkCa3y80ZFMOnuQ=; b=mQfRunIzHqWfhnrbgR8mr186Eiw4yI2gBqN9HLxziyVjUAgh10bO9Sk67BgQArufCP dNpn1Jyme8WSgO7Yeesp2X9jNypA7wT90gB9chS5ooy6ufspB9k+Or+RUIZOP1BQnsn6 iAm4wwxedOYJ+L9JGo4HBAKXlhqRdq4ljlz8iXL+LHBEDUb3NTirA5ncMo5VjWIUCaLh OIywiVnVNkvJMOLsS7YHXqHtIObh72XnwAXQPAKxO6rYIP/1I1THMRogjwL9D1qAIf1W 2SHLmf5n5IwmkD1BqAITMWyL9Q4Km1qURmu5+Z/B5W1Cv7cY3Do0yN/c9ZcEJ9h3T3ay VUxQ==
X-Gm-Message-State: AGi0PuY6kPsA6r/im6C0xGGKvKkf9dVvUktucT+CDTaWkLD4IaT++i3t 9iKnbJzpwFSXH5ntdv3q4AoNvMP+vd0/sA+zUP0Mww==
X-Google-Smtp-Source: APiQypK8LRLVFNtcySIxWq+rVAjIVmjG6JjntZHRTgT6qI6GnRGRsTh0w4lHA7ifEwBVDShHgsBsJq92xK0k51H2vuY=
X-Received: by 2002:a25:3252:: with SMTP id y79mr6188889yby.274.1588953110948; Fri, 08 May 2020 08:51:50 -0700 (PDT)
MIME-Version: 1.0
References: <BY5PR11MB4355C26250C9CF46713C9956B5A40@BY5PR11MB4355.namprd11.prod.outlook.com> <D66596CE-7F5C-4562-89A4-48FCE96D0E18@tzi.org> <28486.1588785684@localhost> <CABCOCHRRDYDomEPctAHaHf+MxS2qXab1J4o=_LUEWcJ2=by5Ww@mail.gmail.com> <8F06BFE6-CE7C-4D10-AC61-24AAA2807E45@tzi.org>
In-Reply-To: <8F06BFE6-CE7C-4D10-AC61-24AAA2807E45@tzi.org>
From: Andy Bierman <andy@yumaworks.com>
Date: Fri, 08 May 2020 08:51:40 -0700
Message-ID: <CABCOCHRUCK_FpwSCnOOy8fBCX_HeAWQeFvJEyZy2hUL4L2WhrQ@mail.gmail.com>
To: Carsten Bormann <cabo@tzi.org>
Cc: Michael Richardson <mcr+ietf@sandelman.ca>, "netmod@ietf.org" <netmod@ietf.org>, "core@ietf.org" <core@ietf.org>
Content-Type: multipart/alternative; boundary="000000000000be42b905a524f9e0"
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/nZD8JWBamapeAUti3TrPCVJDkBs>
Subject: Re: [netmod] [core] CBOR YANG encoding of union & bits [draft-ietf-core-yang-cbor-12]
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: Fri, 08 May 2020 15:51:55 -0000

On Thu, May 7, 2020 at 11:22 PM Carsten Bormann <cabo@tzi.org> wrote:

> On 2020-05-08, at 05:27, Andy Bierman <andy@yumaworks.com> wrote:
> >
> > Why is the bit position allowed to be a uint32 in YANG? Who knows, but
> it has to be supported.
>
> If we think that is the way to go, I like Kio’s proposal over in the CBOR
> list:
> <https://mailarchive.ietf.org/arch/msg/cbor/3sZ4YfWLzmVVnNnQbttkovgjTP8>
>
>

Yes -- this encoding should work well


> We probably should arm that with some text that says (in nicer words) that
> this is an emergency representation and implementations should not invoke
> it for sane YANG models (with an operable definition of sane).
>
>

Not sure what this means.
Wouldn't this map approach be used all the time for a bits type?
The "normal" case would be a small number of octets representing all the
bits present
 (e..g 0x7 for 3 bits : bit 0 to bit 2)
This would simply be 1 map entry with {offset=0,length=1,value=0x7}

The actual bitmap is conceptually constructed by starting with an array of
zero bytes.
Overlapping offsets are allowed. Duplicate offsets are allowed.
There is no requirement to list offsets in ascending order.
There is no canonical representation.

Each map entry is added to the array using a "bit or" operator.
After all map entries are processed the full bits value is known.
This allows an implementation to encode bits serially (often done this way
with YANG bit names)

So the same bitset 0x7 could be sent different ways including:

  { 0, 1, 0x1 }
  { 0, 1, 0x2 }
  { 0, 1, 0x4 }

If the position is really bit 4 million (bit 1 in byte 500,000)

  { 0, 500000, 0x1 }



> Grüße, Carsten
>
>

Andy