All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Stanislav Fomichev <sdf@google.com>,
	davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, lorenzo@kernel.org, willemb@google.com
Subject: Re: [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags
Date: Mon, 16 Oct 2023 11:46:24 -0700	[thread overview]
Message-ID: <20231016114624.3662b10b@kernel.org> (raw)
In-Reply-To: <CAF=yD-Lx7eWLHwNaTwarBPmZEJZ-H=QJVcwpcrgMUXDSkc6V3A@mail.gmail.com>

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:

  reply	other threads:[~2023-10-16 18:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03 15:34 [PATCH net-next 0/3] ynl Makefile cleanup Jakub Kicinski
2023-10-03 15:34 ` [PATCH net-next 1/3] ynl: netdev: drop unnecessary enum-as-flags Jakub Kicinski
2023-10-16 17:34   ` Stanislav Fomichev
2023-10-16 17:43     ` Willem de Bruijn
2023-10-16 18:46       ` Jakub Kicinski [this message]
2023-10-16 19:07         ` Willem de Bruijn
2023-10-16 19:31           ` Willem de Bruijn
2023-10-16 19:08         ` Stanislav Fomichev
2023-10-03 15:34 ` [PATCH net-next 2/3] tools: ynl: don't regen on every make Jakub Kicinski
2023-10-03 15:34 ` [PATCH net-next 3/3] tools: ynl: use uAPI include magic for samples Jakub Kicinski
2023-10-03 16:00 ` [PATCH net-next 0/3] ynl Makefile cleanup Stanislav Fomichev
2023-10-05  0:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231016114624.3662b10b@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@google.com \
    --cc=willemb@google.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.