Re: [PATCH net-next] tools: ynl-gen: use big-endian netlink attribute types

From: Jakub Kicinski
Date: Sun Sep 15 2024 - 11:23:21 EST


On Sat, 14 Sep 2024 19:03:38 +0000 Asbjørn Sloth Tønnesen wrote:
> > We could just swap the type directly here?
>
> That could work too, WDYT?
>
> diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
> index 717530bc9c52e..e8706f36e5e7b 100755
> --- a/tools/net/ynl/ynl-gen-c.py
> +++ b/tools/net/ynl/ynl-gen-c.py
> @@ -157,7 +157,10 @@ class Type(SpecAttr):
> return '{ .type = ' + policy + ', }'
>
> def attr_policy(self, cw):
> - policy = c_upper('nla-' + self.attr['type'])
> + policy = f'NLA_{c_upper(self.type)}'
> + if self.attr.get('byte-order', '') == 'big-endian':
> + if self.type in {'u16', 'u32'}:
> + policy = f'NLA_BE{self.type[1:]}'

LGTM!