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

"Rob Wilton (rwilton)" <rwilton@cisco.com> Wed, 06 May 2020 10:43 UTC

Return-Path: <rwilton@cisco.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 40B313A0932; Wed, 6 May 2020 03:43:57 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -9.598
X-Spam-Level:
X-Spam-Status: No, score=-9.598 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, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cisco.com header.b=EY95BxtZ; dkim=pass (1024-bit key) header.d=cisco.onmicrosoft.com header.b=og6tyKwF
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 idZ5MdFcTDya; Wed, 6 May 2020 03:43:55 -0700 (PDT)
Received: from rcdn-iport-2.cisco.com (rcdn-iport-2.cisco.com [173.37.86.73]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 86C8F3A0894; Wed, 6 May 2020 03:43:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2455; q=dns/txt; s=iport; t=1588761835; x=1589971435; h=from:to:subject:date:message-id: content-transfer-encoding:mime-version; bh=OiO7Noju3+Mq7NgAXsR9oMyowjbTe/pfRpRH6NgVJp4=; b=EY95BxtZOl1r/v0TKSBABDcIIvADNivWLl4mlQdntrsrZFvd5jJ7eVaV GcXuPJh4Yw8SEWrwtwaRbFwHNucCkrwDrXdfl+FPHUSnSC1f9NdJqXh8m zsShGnOLrsxkChJknKbhHUMfb/Ip4oDvVYFVlF9f6SPLqwetlLpgizuLF U=;
IronPort-PHdr: 9a23:gyqqIxWjVPLefkIdIBpTeHR34qTV8LGuZFwc94YnhrRSc6+q45XlOgnF6O5wiEPSBNyBufNJl+SQtLrvCiQM4peE5XYFdpEEFxoIkt4fkAFoBsmZQVb6I/jnY21ffoxCWVZp8mv9PR1TH8DzNFzfvnP06iQdSV3zMANvLbHzHYjfx828y+G1/cjVZANFzDqwaL9/NlO4twLU48IXmoBlbK02z0jE
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0CuDwBNlLJe/4oNJK1mgQmDG1EFgUYvKgqHXwOLNZpGglIDVAsBAQEMAQEtAgQBAYREAoIBJDgTAgMBAQsBAQUBAQECAQUEbYVWDIYKKAYBASkPEQE+QiYBBAEaGoVQAy4BA6h4AoE5iGF0gTSDAAEBBYUkGIIOCYE4gmOJYRqBQT+BEUOHW4NDgi2yVQqCSJgznSCQF50cAgQCBAUCDgEBBYFpIimBLXAVgyRQGA2UNIpWdDcCBggBAQMJfJA6AYEPAQE
X-IronPort-AV: E=Sophos;i="5.73,358,1583193600"; d="scan'208";a="766687812"
Received: from alln-core-5.cisco.com ([173.36.13.138]) by rcdn-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 06 May 2020 10:43:52 +0000
Received: from XCH-ALN-005.cisco.com (xch-aln-005.cisco.com [173.36.7.15]) by alln-core-5.cisco.com (8.15.2/8.15.2) with ESMTPS id 046Ahqux005973 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=FAIL); Wed, 6 May 2020 10:43:53 GMT
Received: from xhs-rtp-001.cisco.com (64.101.210.228) by XCH-ALN-005.cisco.com (173.36.7.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 6 May 2020 05:43:52 -0500
Received: from xhs-rtp-003.cisco.com (64.101.210.230) by xhs-rtp-001.cisco.com (64.101.210.228) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 6 May 2020 06:43:51 -0400
Received: from NAM12-DM6-obe.outbound.protection.outlook.com (64.101.32.56) by xhs-rtp-003.cisco.com (64.101.210.230) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Wed, 6 May 2020 06:43:51 -0400
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j2UK4t+vgigTOMAWbPjapuZLBDsDAPqIo+aHRzfr0nayu71892suJ+aO/Y9rud7Kf7ZNfmxXJ19BE9FbMJJclmCqwsLY4WJD1NQwg67QtE9FWdfqr5t93EeRqQlnzppwkWl5c+T6mtylwBziJogb7ve7oUQEi8g4KGwvj9ih9iKVDEJrCDt5HIW/jvwrVFhhjuf19SMnCBOqOKqsLAx2e0tDeBnrtIfd02nBCLX1rykeWeMZfoMkEvkTvVlM51DLZAs+Xsf2L4lMWVfYjxDx8kXCKL7ehNbgqWjRRhN/p5MXASJKNOIKsRRi7CWxO5hzwWt6rH8WtZPJifqgKk9Gng==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2hyN6Ks8An4SFJGsZ8VcrVMhbwt17RuVX7fPpfygCKo=; b=ATUfiS74xQ7DMdCbFrUrJX9VyG+yXhJdBt1s1iqYfPVSNtZurIqlP7PinzudxsurLA4tj2AZr4hNAQMKOL+0SsBxYFVK9nWP5QmjcF45OCaTlI8rq0zy4q+nscjJVw+k+gZvy028QSjqUBD5fNIu/aIkQrzb7kcjOhcPmsmzBdlx/8SVTlr19noHHZ6QlL+HEiwXf6QG6Gev5BNQXPe2Qai3+LlpmGo+/d1+G5uOsDvD1ko/TAOe2x4T2ljXpfUQbY4c6ZLpKv7Sg/BlYmwrCyaEGx9sHeGI/li+VNJG2P/I6i7OK7omsPYHQ0Smssc+zuA8o5iblpbZcwqk6R0/6A==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cisco.com; dmarc=pass action=none header.from=cisco.com; dkim=pass header.d=cisco.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.onmicrosoft.com; s=selector2-cisco-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2hyN6Ks8An4SFJGsZ8VcrVMhbwt17RuVX7fPpfygCKo=; b=og6tyKwFDrSWzW3t4y56vaiBLxyivmTlfUm1+kL633JosWKKz8Y6PypLmNDZFXfncbgYhh1kis5tEBBZrR71eONH8K0Pjxz2/vZAo5eKbMl944qB4XzmdE/Pb9Ymf8WpBjl5HXeTUc996/AJfQfIIu3NGl5tq+ObKLFLWc4kFEk=
Received: from BY5PR11MB4355.namprd11.prod.outlook.com (2603:10b6:a03:1c3::13) by BY5PR11MB4338.namprd11.prod.outlook.com (2603:10b6:a03:1c8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20; Wed, 6 May 2020 10:43:50 +0000
Received: from BY5PR11MB4355.namprd11.prod.outlook.com ([fe80::6911:81bd:3157:eeff]) by BY5PR11MB4355.namprd11.prod.outlook.com ([fe80::6911:81bd:3157:eeff%7]) with mapi id 15.20.2979.028; Wed, 6 May 2020 10:43:50 +0000
From: "Rob Wilton (rwilton)" <rwilton@cisco.com>
To: "core@ietf.org" <core@ietf.org>, "netmod@ietf.org" <netmod@ietf.org>, "draft-ietf-core-yang-cbor@ietf.org" <draft-ietf-core-yang-cbor@ietf.org>
Thread-Topic: CBOR YANG encoding of union & bits [draft-ietf-core-yang-cbor-12]
Thread-Index: AdYjjRJSrAgzJqA0Rj+Yt5Eb1SoE2w==
Date: Wed, 06 May 2020 10:43:49 +0000
Message-ID: <BY5PR11MB4355C26250C9CF46713C9956B5A40@BY5PR11MB4355.namprd11.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: ietf.org; dkim=none (message not signed) header.d=none;ietf.org; dmarc=none action=none header.from=cisco.com;
x-originating-ip: [82.15.79.32]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 2f0c66cd-6326-4c80-3f64-08d7f1aa5d19
x-ms-traffictypediagnostic: BY5PR11MB4338:
x-microsoft-antispam-prvs: <BY5PR11MB43386EA7D5BBDA1DBD99FDA8B5A40@BY5PR11MB4338.namprd11.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:10000;
x-forefront-prvs: 03950F25EC
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: 3nnNQjf9o7kwodAugClrycZ0KvXfbbYrjoE15Gpl8vCAJl/EH7XYAdynYUdMND7nPqCuhKPVhhulQdXlR2q3Xa/qQCmmXD2irj8gB/u+H4ASy5nDNGKQnafhqqLmYR997Murqk4N0zx/nStnL1nRkmp7KvMdW618MqsMLLH9Wm6N+/uSlfYcwGI20cFUICKE3BDOO382vkBXI19eweuhWIKRND2NgD7IFcnv/DiVwXzckjDj6kIUxRFJBtczXoH2EGTYUTiNavlQv1FpL/gAnga4vUcjhX8aqVPawZ8uRuAHM1AiSIv0jvaxvxuv3SzhN0cjkE8KInSGF/hZXWuxdQbwp+fmDh2AcZgnK8Nl1eDjy24/wyDVqj5qFLUGP7HN+1IK4I4FPDZY5q24cr52wVUprfq+7HyQ/2GTTOAw7UwtEgUt5xSJntolsOyb+8WJ87frB49qx1wwpSleOju5Sf9+q5RCThLCZzwwf9/F0qZ5HkrTMShXNO9DTN1kdLlo8IpjTpVRdpQG/s1+bouNzQ==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR11MB4355.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(396003)(39860400002)(346002)(136003)(366004)(33430700001)(9686003)(66446008)(8676002)(5660300002)(64756008)(7696005)(2906002)(66946007)(71200400001)(66556008)(26005)(66476007)(55016002)(86362001)(76116006)(186003)(110136005)(478600001)(316002)(8936002)(450100002)(6506007)(52536014)(33440700001)(33656002); DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata: mQwzJutiLwj2p6RXBcxX7atMw7bKOyMDUCShQaDEsNMfEA4qpxZtlukyg/eKgyWMi2UxrPayWjJyydpi4fVQnO537TXWGGJtq45BEfkogI6Av8iWibRTgQj1mIPX+KMZsAa0p7rDmkxdDNX3Fo4S/bLcNb72QOYZX4yq+LUzC4okhAfYTMiueq0rJuRe1wVx+WwaRZmSUbpM8KUCuzuL0jyh4tp1XPsub+GJRiX0TeczTMXXmL39Sd8SwNqm4LKlh8SeH3jX4zx4pcULclv5YPCYgz3Fm4+zNlZ8y4NVpYhf6M1a6sldqh/6yMN23Eca51rCAiL4GG5R899/e5h8EapiULyZJ2gq7HNUcTdTHz/UMkrX0NSOhhLnnOD5MWyMGrdmOkyV4GrDgDbTNHEMRnmrKXN4UMSI0B0K7xF43ipGSSSOgOtdyiZss61Ev1a+XSQYi4Ag0kjESsf3C9Gv8dYDyMwe6ElkT4Wv00iCbiJL13zHn/kjuKGr2mrZHA90llr37iRkk4A3pOOz1Q6p2w1rKIhLBNPaJ1Lsvi9owwFv8/WdXfPPac2SjFETXkJxJ/60WEtb4MsL8qazQXVLQ4u5oSsnqVJ8WOeOMNEHktSsiTiTHyxscq+rqCl0Vb256RTjVqckYo5g2xKhgTS+m2t7wasj3nAvoIoH5Ff/UtaY5LU2k+whhVMQHSSddaom7kF8yierNUTYjE70fJTFkhlCYr38gGbKEvn9ic962R/nzi1Jwt54l/GlAXcKCBRd4z9K5Ab4Z92mV5aqy0s25SRY14NyGkI6Nkl4NE711cU=
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-Network-Message-Id: 2f0c66cd-6326-4c80-3f64-08d7f1aa5d19
X-MS-Exchange-CrossTenant-originalarrivaltime: 06 May 2020 10:43:49.9617 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 5ae1af62-9505-4097-a69a-c1553ef7840e
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: +tY5AnCKFfnkizA66lVuEHBbLDuyJUo9uA6NydJCS9uf2LYFqKVPDICMTYI4Sri3bNkAjoTzqUCh/iW38EW8xw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4338
X-OriginatorOrg: cisco.com
X-Outbound-SMTP-Client: 173.36.7.15, xch-aln-005.cisco.com
X-Outbound-Node: alln-core-5.cisco.com
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/zaAtN5l8NuXUT1u3oj3qy9UG_m8>
Subject: [netmod] 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: Wed, 06 May 2020 10:43:58 -0000

Hi,

[Cross posting to Netmod for wider YANG expertise.]

I had a couple of questions on the CBOR YANG encoding of bits and unions (based on draft-ietf-core-yang-cbor-12).  Apologies if these have already been discussed/closed in the WGLC.

1) Regarding the encoding of the bits datatype:
[draft-ietf-core-yang-cbor-12, section 6.7]

The CBOR YANG encoding of the bits datatype is defined as a byte string encoding of a bitfield.  However, my concern here is that YANG bit positions are allowed to be up 2^32-1.

E.g. the following, pathologically bad, bits definition would seem to have a very inefficient encoding in CBOR:

   typedef alarm-state {
     type bits {
       bit unknown {
         position 4000000000;
       }
       bit under-repair;
       bit critical;
       bit major;
       bit minor;
       bit warning;
       bit indeterminate;
     }
   }


How much should we be concerned about this pathological case?  Would it be reasonable for implementations to reject bitfields larger than a small set size (e.g. perhaps 256 bits)?

Or, if it is supported by the language then is it reasonable that implementation SHOULD support it?  In which case I think that we might need a second encoding of bits that supports this pathological case.  Perhaps an array of 'set' bit positions, or alternatively the union string encoding of bits could be used.


2) Regarding the encoding of unions:

I was questioning whether the special encoding of bits type within a union was required in CBOR [draft-ietf-core-yang-cbor-12, section 6.7].  Am I right to presume that this is to ensure that the CBOR encoding of unions is always at least as specific as XML?  If so, this seems like a reasonable design choice.  But that leads on to these general YANG questions:

Should the value encoding of a YANG union type behave the same way regardless of whether the encoding is XML/JSON/CBOR?  Or is it reasonable for there to be differences in the case of conflicting values?  Perhaps this is already answered by RFC 7951 that can behave differently from the XML encoding of unions.

Longer term, should YANG be looking for a discriminated-union type?  Or perhaps it would be sufficient for tooling to flag up potentially ambiguous union definitions, particularly those that may be encoding dependent.


Regards,
Rob

[As an individual contributor]