]> www.infradead.org Git - users/jedix/linux-maple.git/commit
tools: ynl: fix mixing ops and notifications on one socket
authorJakub Kicinski <kuba@kernel.org>
Wed, 18 Jun 2025 17:17:46 +0000 (10:17 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 19 Jun 2025 15:37:39 +0000 (08:37 -0700)
commit9738280aae592b579a25b5b1b6584c894827d3c7
treea23ddcd803d9415b70ab04817d463195268332c4
parent664f1b854f63e0bedba96a8f5d896c7ce5fd167f
tools: ynl: fix mixing ops and notifications on one socket

The multi message support loosened the connection between the request
and response handling, as we can now submit multiple requests before
we start processing responses. Passing the attr set to NlMsgs decoding
no longer makes sense (if it ever did), attr set may differ message
by messsage. Isolate the part of decoding responsible for attr-set
specific interpretation and call it once we identified the correct op.

Without this fix performing SET operation on an ethtool socket, while
being subscribed to notifications causes:

 # File "tools/net/ynl/pyynl/lib/ynl.py", line 1096, in _op
 # Exception|     return self._ops(ops)[0]
 # Exception|            ~~~~~~~~~^^^^^
 # File "tools/net/ynl/pyynl/lib/ynl.py", line 1040, in _ops
 # Exception|     nms = NlMsgs(reply, attr_space=op.attr_set)
 # Exception|                                    ^^^^^^^^^^^

The value of op we use on line 1040 is stale, it comes form the previous
loop. If a notification comes before a response we will update op to None
and the next iteration thru the loop will break with the trace above.

Fixes: 6fda63c45fe8 ("tools/net/ynl: fix cli.py --subscribe feature")
Fixes: ba8be00f68f5 ("tools/net/ynl: Add multi message support to ynl")
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/20250618171746.1201403-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/net/ynl/pyynl/lib/ynl.py