On Mon, Oct 3, 2022 at 12:41 PM Jeffrey Haas <jh...@pfrc.org> wrote: > [I had promised Mahesh that I'd take my comments here, but I realize that > this > is a topic that likely will result in no short term solutions. It may also > result in no action whatsoever.] > > YANG strings are bounded in length, theoretically, but that length limit > isn't small. > > When strings are used solely as leaf values, the length limit largely isn't > a matter of concern, in my opinion. However, when they're used as keys, it > introduces some code practicalities that may be worth discussing. > > One item of practicality is simply the length and its impact on underlying > data structures. If you were storing such things in something like a > PATRICIA tree, many implementations behave better when the key is of a > bounded length.* > > A secondary consideration is that since unicode is used, character lengths > in terms of storage may vary. Implementations that internally store > strings > as UTF-8 have to be wary of truncation considerations. > > A tertiary consideration is that in mechanisms like gNMI, long keys end up > bloating PDUs. > > Loosely framing this as a very old English joke: YANG Doctor, it hurts when > I do this! YANG Doctor: Well... don't do that! > > For many things that have naturally short string names (e.g. interface > names), this mostly isn't an issue. However, for things that may take > user-supplied strings as their key in configuration, this is somewhat more > problematic.* > > Most implementations likely don't take unbounded inputs to the maximum > length of a YANG string for such things. Technically in such situations, > they're non-conformant if that's the case, or if they don't provide a > deviation specifying the length of the string. > > Why raise this? While I only coincidentally participate in YANG module > implementation at the moment, I remember similar headaches in MIBs making > the lives of implementors problematic. > > What should be done, if anything? It seems like those with deeper > expertise > may want to recommend a reasonable length limit for strings that will be > used as keys. Perhaps define a specific typedef for such things. And, > once > defined, the YANG doctors might consider recommending them in their > reviews. > > I think other SDOs like BBF have defined some constrained string types. SMIv2 defines a DisplayString (max size 255). IMO the use of plain 'string' is far too prevalent in YANG modules. It is often used even though a zero-length string is not accepted by the server (nor intended by the designer).
Perhaps ietf-yang-types should define a small number of bounded length string types so designers are more likely to avoid plain 'string'. E.g.: - yang-identifier64 (length 1..64) - admin-string (length 0..255) Such things may already be good practice, but perhaps I'm not aware of it. > > -- Jeff > > * As a matter of fact, it was performing a code review against exactly this > point that raised this consideration. > > Andy > _______________________________________________ > yang-doctors mailing list > yang-doct...@ietf.org > https://www.ietf.org/mailman/listinfo/yang-doctors >
_______________________________________________ netmod mailing list netmod@ietf.org https://www.ietf.org/mailman/listinfo/netmod