Commit 0a966d60 authored by Donald Hunter's avatar Donald Hunter Committed by Jakub Kicinski

tools/net/ynl: Fix extack decoding for directional ops

NetlinkProtocol.decode() was looking up ops by response value which breaks
when it is used for extack decoding of directional ops. Instead, pass
the op to decode().
Signed-off-by: default avatarDonald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20240418104737.77914-3-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 1ee73168
...@@ -386,12 +386,9 @@ class NetlinkProtocol: ...@@ -386,12 +386,9 @@ class NetlinkProtocol:
def _decode(self, nl_msg): def _decode(self, nl_msg):
return nl_msg return nl_msg
def decode(self, ynl, nl_msg): def decode(self, ynl, nl_msg, op):
msg = self._decode(nl_msg) msg = self._decode(nl_msg)
fixed_header_size = 0 fixed_header_size = ynl._struct_size(op.fixed_header)
if ynl:
op = ynl.rsp_by_value[msg.cmd()]
fixed_header_size = ynl._struct_size(op.fixed_header)
msg.raw_attrs = NlAttrs(msg.raw, fixed_header_size) msg.raw_attrs = NlAttrs(msg.raw, fixed_header_size)
return msg return msg
...@@ -797,7 +794,7 @@ class YnlFamily(SpecFamily): ...@@ -797,7 +794,7 @@ class YnlFamily(SpecFamily):
if 'bad-attr-offs' not in extack: if 'bad-attr-offs' not in extack:
return return
msg = self.nlproto.decode(self, NlMsg(request, 0, op.attr_set)) msg = self.nlproto.decode(self, NlMsg(request, 0, op.attr_set), op)
offset = self.nlproto.msghdr_size() + self._struct_size(op.fixed_header) offset = self.nlproto.msghdr_size() + self._struct_size(op.fixed_header)
path = self._decode_extack_path(msg.raw_attrs, op.attr_set, offset, path = self._decode_extack_path(msg.raw_attrs, op.attr_set, offset,
extack['bad-attr-offs']) extack['bad-attr-offs'])
...@@ -922,7 +919,8 @@ class YnlFamily(SpecFamily): ...@@ -922,7 +919,8 @@ class YnlFamily(SpecFamily):
print("Netlink done while checking for ntf!?") print("Netlink done while checking for ntf!?")
continue continue
decoded = self.nlproto.decode(self, nl_msg) op = self.rsp_by_value[nl_msg.cmd()]
decoded = self.nlproto.decode(self, nl_msg, op)
if decoded.cmd() not in self.async_msg_ids: if decoded.cmd() not in self.async_msg_ids:
print("Unexpected msg id done while checking for ntf", decoded) print("Unexpected msg id done while checking for ntf", decoded)
continue continue
...@@ -979,7 +977,7 @@ class YnlFamily(SpecFamily): ...@@ -979,7 +977,7 @@ class YnlFamily(SpecFamily):
done = True done = True
break break
decoded = self.nlproto.decode(self, nl_msg) decoded = self.nlproto.decode(self, nl_msg, op)
# Check if this is a reply to our request # Check if this is a reply to our request
if nl_msg.nl_seq != req_seq or decoded.cmd() != op.rsp_value: if nl_msg.nl_seq != req_seq or decoded.cmd() != op.rsp_value:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment