[netmod] Should an empty enumeration be allowed within a union?

Nick Hancock <nick.hancock@adtran.com> Mon, 17 January 2022 15:08 UTC

Return-Path: <nick.hancock@adtran.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 323723A0B56 for <netmod@ietfa.amsl.com>; Mon, 17 Jan 2022 07:08:14 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.902
X-Spam-Level:
X-Spam-Status: No, score=-6.902 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=adtran.onmicrosoft.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 z35fCX806qsi for <netmod@ietfa.amsl.com>; Mon, 17 Jan 2022 07:08:12 -0800 (PST)
Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2104.outbound.protection.outlook.com [40.107.237.104]) (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 557F73A0B53 for <netmod@ietf.org>; Mon, 17 Jan 2022 07:08:12 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RLhYb+gRlj5EVyqqozTwSyMsMwID5dRPaCNCfxQdP2vwbP79RGL2jHB3rtwZqYhVxeJwe6O30GBZuJnHfMbvk6X7iGVvL8ZrJyEonTagbhzmAU7NOo+4W/3F1pwxceKyG+ELoryHlfZK7mSY1oEgAohL6r6teSeFWAUYlpRcL8GujElw4a5/c3Qpbz+vCTfOu4iWpWPwumdPVf8kq1sc/SGLLNbeYGrua03hTgDd9UXSNYhD6ibA8disHGzNYbFDzVvFqcRhSXymXTEvmnZp8JC3CHZ1WzHQqKpdYPzCs8KsPtHmvn/9Djr8sNJiIhI4dCgjSGI3bcujhOwCmmEfIA==
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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i4NDAJ9/YYVRuDAHVQFDsJTNuglbo0cZqLoW7XGUwQQ=; b=c8ICBo6VL0BnxTr4nfX2LfBgvAQvJf1vjnIiwVw8Qn3FA+dLH65nDe/lRTGsWdyPA+4lBSJAVlYNWcW0aqE5XFfBCeFnSFRP9tnZ9SlsKs4Q5Nt3qyessIbxjLSVFIUYmENOhmvTysHW8tKP+Tcj995Jx0FbBFoxi7adNPmffOQFHSGRMLqP+AZ2IMAZC5SqkUyHbP5jZND7xNArHOow0EgWcdDp+FyVB1ZxXULCEV170tdm29o/qNHD8dG/GyRUv1wi15ca0W36v3Qs2fqSK2XOPam5buuzMle1rtoUdhJMjVUGE2C38aaoVSMxElcP2OQ3uwdLeLeZQ5GRC84LBg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=adtran.com; dmarc=pass action=none header.from=adtran.com; dkim=pass header.d=adtran.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ADTRAN.onmicrosoft.com; s=selector2-ADTRAN-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i4NDAJ9/YYVRuDAHVQFDsJTNuglbo0cZqLoW7XGUwQQ=; b=YSzD++VtASgbvoDSQLo/QiJNaD5BJ3Y4l5gAOHJrlmvLO5UJagbEq7sdK23rpUIF9o16jEiGI6iS/f4ZxLQDnUbsWiGs9I5a4Xpmnjzl8WIdRXpPVaLorI6BsW7tHO/NHBmcyqU/C8fBfFu+lLrd3lyo09YPpXkgCu5NEoJLpOIT0JoBGR41CPjStshFgmdrDAT3r6O2pfCZinzKfzDboR6zZJz2f9AIHMz6/8mieWTlN/csJ/LMeCdkB9/mFXVQZY/uEiXFa4EtpLWaHqQqx6URKtvXc/c2qSUBrL7j+O6BYDS+SQpflb6JPmW+dmD+py52L8KUyfcpB4mFqREwLg==
Received: from DS7PR19MB4392.namprd19.prod.outlook.com (2603:10b6:5:2c4::15) by MWHPR19MB0925.namprd19.prod.outlook.com (2603:10b6:300:a3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Mon, 17 Jan 2022 15:08:07 +0000
Received: from DS7PR19MB4392.namprd19.prod.outlook.com ([fe80::95c6:51c4:4bfc:7f13]) by DS7PR19MB4392.namprd19.prod.outlook.com ([fe80::95c6:51c4:4bfc:7f13%6]) with mapi id 15.20.4888.014; Mon, 17 Jan 2022 15:08:06 +0000
From: Nick Hancock <nick.hancock@adtran.com>
To: "netmod@ietf.org" <netmod@ietf.org>
Thread-Topic: Should an empty enumeration be allowed within a union?
Thread-Index: AdgLtAMcHo8dsM7iTEiXY0Vbp8YIDw==
Date: Mon, 17 Jan 2022 15:08:06 +0000
Message-ID: <DS7PR19MB43928885E912C2D229BB5A36FB579@DS7PR19MB4392.namprd19.prod.outlook.com>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=adtran.com;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: f69108c7-358d-4907-2a2b-08d9d9cb2abe
x-ms-traffictypediagnostic: MWHPR19MB0925:EE_
x-microsoft-antispam-prvs: <MWHPR19MB092575B9234B2B9136ED4056FB579@MWHPR19MB0925.namprd19.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:10000;
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: QS6z+NffrT45qOwb4yKi3liLS3mfABEuhl2DENuWSQfrsFWmvjafZiM01D5Z7b6WTpJwFFGBZ+KN/Chtpfzdy8wSCK8gT5p62JxhQS9UfaThVKH0YNI6GgdhmKH7BQol5sLvwrzBqjmb+WZBaQ7JTrWB9ijxKaEX1Uy70mDYhk+L/KTH4ATZY4GvdzSGaRwaE4JodexBGDi9TahO+bz81n1rVZJ11W1+/LisU3AlnZ5n+MRXm6e1VtDKZvkFlTIhTA5P3ZxtdneHNUPHa0+bYWvo4RJvEPcL83xn89MDMGuxxazS6W2qMGGtDdwWWL6gv9Ee6zVCpzNcMWUMTuLxJ5ZIFyOFqHHVrNuqyKNkdanXhxJ/89SeIu7m3+26yBzwweaU3VCh0h/Rv6EibaQyO6Xr5e80NxMdUjKXElO8t4WMw4ZqiA03UUFDArLryBY4zQm9QFfgAqYhRj0iEtANlf0hB+WyrkktnChKO7pV3lsCib3hyhqJucz+IfeGmXP9F3WKRtBrGyCBfO3Ygn1AkhlfUH32lcMwJyO1KhG7vSQ737dgfN7myxXuxobHNDojVrEEHEYJhKaCg+e02x6krzt/TLW2CVChs6grLd8B23b+Ow3fkJ3lpKgCOfYKwDR+zBpZbQs3AQUXLPXj8p7LUiPPQy4mBQOxD7JpEG2Ev++vpzt93iRc0NMKZ7mZwf4CDb4O71CmAscdBDrXCqKxhA==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR19MB4392.namprd19.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(508600001)(186003)(38070700005)(33656002)(44832011)(71200400001)(8936002)(316002)(8676002)(6506007)(66446008)(26005)(7696005)(66476007)(52536014)(66946007)(86362001)(76116006)(6916009)(38100700002)(55016003)(122000001)(5660300002)(2906002)(9686003)(66556008)(64756008); DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: LbB3HTcu56MprggrHzBhYWgInfN1DEXV8bk8Da2JumnpPOWZn4YQRYxoYeCSev2mCr7UTxnSEG0uQ27blREEqsctLqxNcEP5yBWnhqKVroNz+CPBUR1jJJB5RbboMXxcUw3fo+QO1pE3L6zTB81cAv0hLal2RMu7Fs6JQFpn0etifo0tj80ln3awt9RokMg5ch3aDQac5b6SifATflAUjz94uvrn3JzWJ/hLZmznUCZLV4f7xnjW7yoTzA3SBYeXisAw97jCp2ZwcyOX/CPyKwvDtDMgEYVGHsenqbwRtsrl/EYB4qOl1PD3DFB0Uu5XRZHITfybEOHvA1qv5xZjSwGLVpuw0jKQev1JqsmBFNIWfCuzhk8JAWZyVDFEZQhuwYTenvfLtQldQC5lVf/5lwqkRJQWCpX/ZK2HdxcFmQSrC01kKWqxEG4k4lqeC66Oj7PS9dziOcnekcRAvKQG36586eXFFcLILZPhJiFytBtOR4RG164XQ4xFqpqCCAMRxMyAkIj2YX2n6EL+Jb/9JLDmSDuwyhtLQfwNdcWyLu/BUeKCUzhK2Dz/On+R7Qav1AgEDyacl6bcNI9r9ZRTKiC6ev61sx0q3YPqxhFUZui5BFRGr87T8Li4iMzNlz3+YZJCEXS6rzjexH5MMGAXLi2/Ydy1+8+6b8Rif4+P1aoZ2RP/EW6gXg6Mwh/wjIpmKTHKSMQqYdCqePlUimXV2ybuu+Wi8jp2EBn+WqPNl5hmWhQK0EMowxSxxMsymYnZTGo0EzRWB6w7w0hyJwa/D8Du5XdniWDYU11ZLXfuQYVhg4Mn9eLETUCcepHoEDtjLewr8H175Cy9z/gQpui84dHFQJM5M7v02spZ5DFQygihUurfiPQDmaJ5t9Vee6q33n0ZAHBgq88gLHumN1EVun8Wu0AR/WyR3Id5a4AaiEdyMkEE8uEbXyDMniKtcyYqce75DG1187LkUys73W4XuU+7fxTCVlQK4pQkOJQrXOcAWzNw3Yrf6Un39LQfkLuKi/6hfBBCfMpca3Lop3OJU2NFXDJMWPiulsSUv88Kq+bpqpSlrVXJLbrwDZFcM5iRI3GabPpmSAcdF2GWAv6MSbvzPmGhn9L07rXOZAB11R+rpM8GPjJtP5aJi60MBbLX1sO6HZ5T58eVLVht3GRYayAOQh5rJkRwrQxA79kci9Zu/aS9oUatnXvr7LXIkMXQewH6e5Rnanll5PprP8U36BjAhJ7j73UqNVPNhDfNPNFbxXZmbcvj2PIKV6hPYUaxzqcJKMbylIOnK4H+lL0pwiI3VwK6evaNc4K3yDLUxoTK+BkphU7SX5OuwqCLpXtOIojZTryAuRFxDptVKGJg8UxPgcrT/zJPrxeT6ZrgpBnF4Ptvk5AVQ2b9sJm2Jn3Y4uKejeS14i7G0de+ebMzf/Yh6MuAS32DH7WSbT2qtPUziN8ddwmLieTSu1SshN3PtJ0Z7f2ZHjX4IjV02pmESsm8XC2WXVoUr+uE5ImQxkwVkfQSxoxOKeG+NLoJJd92DDr6AE0e0uMm+4iS0dKv9soA5l4LNDsK9DWEcbqCKt8lbhljVxS1lBKGtv0NsHgCMqTeO0Z/6uo3LiWMG+BRcw==
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: adtran.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DS7PR19MB4392.namprd19.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: f69108c7-358d-4907-2a2b-08d9d9cb2abe
X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2022 15:08:06.6289 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 423946e4-28c0-4deb-904c-a4a4b174fb3f
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: E+W3KTt9f3S5PY8WGVxA2M495ARaWazt+mtNbWrI7n2HKu0+df3RvDMxXa2g3hJNohxu/emqZ3tsR9kYn3WSHA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR19MB0925
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/_E9Rg6G7g-KSbnC9lPVlWWYkJf4>
Subject: [netmod] Should an empty enumeration be allowed within a union?
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, 17 Jan 2022 15:08:14 -0000

Hi,

We need some advice on whether the following can be considered as 
valid YANG syntax and whether the behavior is that which we expect.

We have a use case (simplified in the example below) where a client is
required to define a certain concrete integer value for a server to 
use for some purpose, which is represented by the leaf 'foo' in the 
example below. 

On some servers we want to offer an additional option of an automatic 
assignment of this value by the server. To this end, we defined a 
union of an integer type and an enumeration with one enum 
'auto-select', as shown below. Since the support of 'auto-select' is 
optional, it is tagged with an if-feature statement. Note that there 
will also be additional data nodes in the schema tree that are 
associated with this configuration and will also be dependent on this 
feature.
      
      leaf foo {
        type union {
          type uint8;
          type enumeration {
            enum auto-select {
              if-feature "auto-select-foo";
              description
                "The server automatically selects a value for foo.";
            }
          }
        }
        mandatory true;
        description
          "The value of foo.";
      }
      
According to RFC 7950 section 9.6.4, an enum statement must be 
present within an enumeration definition. If the feature 'auto-select-
foo' is not supported by a server, does the enumeration still comply 
with this requirement given that there is an enum statement present? 

According to yanger it does not. Is yanger wrong? 

If the YANG is compiled without the feature, yanger currently reports 
the following error:
  "error: a type enumeration must have at least one enum statement".

The requirement that an enumeration must have at least one enum
would make sense, if the type for a leaf was just an enumeration, 
because otherwise a client would not be able to configure a valid 
value. 

However, it could be argued that in the case of the union, there would
be no issue with the enumeration being an empty set as the client 
would nevertheless be able to define a valid value and fulfill the 
'mandatory' requirement as a result of the other types in the union, 
in the example above the uint8.

What is NETMOD's opinion on this? Could the above example be seen as 
valid YANG syntax?

If this is not the case, then we have an issue as we would have to 
remove the if-feature statement from the enum. Having done this, a 
client would then be able to configure the value 'auto-select' on 
servers that do not support the feature, which is of course is
undesirable.

Assuming that the use of an empty enumeration is valid, if the feature
'auto-select-foo' is not supported, is it true that only an integer of
type unit8 would then be allowed?

Regards
Nick