Commit 758d29fb authored by Donald Hunter's avatar Donald Hunter Committed by Jakub Kicinski

tools: ynl: Fix genlmsg header encoding formats

The pack strings use 'b' signed char for cmd and version but struct
genlmsghdr defines them as unsigned char. Use 'B' instead.

Fixes: 4e4480e8 ("tools: ynl: move the cli and netlink code around")
Signed-off-by: default avatarDonald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20230319193803.97453-1-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c79493c3
...@@ -200,7 +200,7 @@ def _genl_msg(nl_type, nl_flags, genl_cmd, genl_version, seq=None): ...@@ -200,7 +200,7 @@ def _genl_msg(nl_type, nl_flags, genl_cmd, genl_version, seq=None):
if seq is None: if seq is None:
seq = random.randint(1, 1024) seq = random.randint(1, 1024)
nlmsg = struct.pack("HHII", nl_type, nl_flags, seq, 0) nlmsg = struct.pack("HHII", nl_type, nl_flags, seq, 0)
genlmsg = struct.pack("bbH", genl_cmd, genl_version, 0) genlmsg = struct.pack("BBH", genl_cmd, genl_version, 0)
return nlmsg + genlmsg return nlmsg + genlmsg
...@@ -264,7 +264,7 @@ class GenlMsg: ...@@ -264,7 +264,7 @@ class GenlMsg:
self.hdr = nl_msg.raw[0:4] self.hdr = nl_msg.raw[0:4]
self.raw = nl_msg.raw[4:] self.raw = nl_msg.raw[4:]
self.genl_cmd, self.genl_version, _ = struct.unpack("bbH", self.hdr) self.genl_cmd, self.genl_version, _ = struct.unpack("BBH", self.hdr)
self.raw_attrs = NlAttrs(self.raw) self.raw_attrs = NlAttrs(self.raw)
...@@ -358,7 +358,7 @@ class YnlFamily(SpecFamily): ...@@ -358,7 +358,7 @@ class YnlFamily(SpecFamily):
raw >>= 1 raw >>= 1
i += 1 i += 1
else: else:
value = enum['entries'][raw - i] value = enum.entries_by_val[raw - i].name
rsp[attr_spec['name']] = value rsp[attr_spec['name']] = value
def _decode(self, attrs, space): def _decode(self, attrs, space):
......
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