Subject: Re: [PATCH net-next v2 1/4] tools: ynl: support byte-order in cli

From: Jakub Kicinski <[email-masked]>
Date: Fri, 24 Mar 2023 20:33:40 -0700

On Fri, 24 Mar 2023 15:56:53 -0700 Stanislav Fomichev wrote:
> @@ -250,7 +258,7 @@ genl_family_name_to_id = None
>                                  if entry_attr.type == Netlink.CTRL_ATTR_MCAST_GRP_NAME:
>                                      mcast_name = entry_attr.as_strz()
>                                  elif entry_attr.type == Netlink.CTRL_ATTR_MCAST_GRP_ID:
> -                                    mcast_id = entry_attr.as_u32()
> +                                    mcast_id = entry_attr.as_u32(None)

I wonder if it's worth using a default value for the argument:

	def as_u32(self, byte_order=None):

the number of Nones is very similar to number of meaningful args.
And only spec-based decoding needs the arg so new cases beyond
the 4 x2 are unlikely.

> -                decoded = attr.as_u64()
> +                decoded = attr.as_u64(attr_spec.get('byte-order'))

Could you add a field in class SpecAttr, like is_multi and read 
a field instead of the get? I'm trying to avoid raw YAML access
outside of nlspec.py classes as much as possible.