[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAF=yD-L1XE=a4OfxXBgfEPxc-3XfPmyz=E5PUc_Vxptp0tKJ1Q@mail.gmail.com>
Date: Mon, 16 Oct 2023 15:07:41 -0400
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Stanislav Fomichev <sdf@...gle.com>, davem@...emloft.net, netdev@...r.kernel.org,
edumazet@...gle.com, pabeni@...hat.com, lorenzo@...nel.org,
willemb@...gle.com
Subject: Re: [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags
On Mon, Oct 16, 2023 at 2:46 PM Jakub Kicinski <kuba@...nel.org> wrote:
>
> On Mon, 16 Oct 2023 13:43:07 -0400 Willem de Bruijn wrote:
> > > Jakub, Willem hit an issue with this commit when running cli.py:
> > >
> > > ./cli.py --spec $KDIR/Documentation/netlink/specs/netdev.yaml --dump dev-get --json='{"ifindex": 12}'
> > >
> > > Traceback (most recent call last):
> > > File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 60, in <module>
> > > main()
> > > File "/usr/local/google/home/sdf/net-next/tools/net/ynl/./cli.py", line 51, in main
> > > reply = ynl.dump(args.dump, attrs)
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 729, in dump
> > > return self._op(method, vals, [], dump=True)
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 714, in _op
> > > rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name)
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 540, in _decode
> > > decoded = self._decode_enum(decoded, attr_spec)
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > File "/usr/local/google/home/sdf/net-next/tools/net/ynl/lib/ynl.py", line 486, in _decode_enum
> > > value = enum.entries_by_val[raw].name
> > > ~~~~~~~~~~~~~~~~~~~^^^^^
> > > KeyError: 127
> >
> > Indeed. The field is now interpreted as a value rather than a bitmap.
> >
> > More subtly, even for requests that do not fail, all my devices now
> > incorrectly report to support xdp feature timestamp, because that is
> > enum 0.
>
> Sorry about that. This should fix it, right?
>
> diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
> index 13c4b019a881..28ac35008e65 100644
> --- a/tools/net/ynl/lib/ynl.py
> +++ b/tools/net/ynl/lib/ynl.py
> @@ -474,7 +474,7 @@ genl_family_name_to_id = None
>
> def _decode_enum(self, raw, attr_spec):
> enum = self.consts[attr_spec['enum']]
> - if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']:
> + if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
> i = 0
> value = set()
> while raw:
Mostly. The "set()" output is unintentional?
# ./cli.py --spec netdev.yaml --dump dev-get
[{'ifindex': 1, 'xdp-features': set(), 'xdp-rx-metadata-features': set()},
{'ifindex': 2,
'xdp-features': {'redirect', 'basic', 'rx-sg'},
'xdp-rx-metadata-features': set()},
{'ifindex': 3, 'xdp-features': set(), 'xdp-rx-metadata-features': set()}]
Contrast with netdev sample:
# ./netdev
Select ifc ($ifindex; or 0 = dump; or -2 ntf check): 0
lo[1] xdp-features (0): xdp-rx-metadata-features (0):
xdp-zc-max-segs=0
eth0[2] xdp-features (23): basic redirect rx-sg
xdp-rx-metadata-features (0): xdp-zc-max-segs=0
sit0[3] xdp-features (0): xdp-rx-metadata-features (0):
xdp-zc-max-segs=0
Powered by blists - more mailing lists