diff options
author | Donald Hunter <donald.hunter@gmail.com> | 2023-03-19 20:37:58 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-03-23 04:40:04 +0100 |
commit | 758d29fb3a8b3c756b4e4e0aa9b32ca8cfaf3feb (patch) | |
tree | ec0cdf6347b4c23c06f2fcaf37977d0fad9a2ebc /tools/net | |
parent | net: enetc: fix aggregate RMON counters not showing the ranges (diff) | |
download | linux-758d29fb3a8b3c756b4e4e0aa9b32ca8cfaf3feb.tar.xz linux-758d29fb3a8b3c756b4e4e0aa9b32ca8cfaf3feb.zip |
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: 4e4480e89c47 ("tools: ynl: move the cli and netlink code around")
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20230319193803.97453-1-donald.hunter@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net')
-rw-r--r-- | tools/net/ynl/lib/ynl.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 90764a83c646..32536e1f9064 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -200,7 +200,7 @@ def _genl_msg(nl_type, nl_flags, genl_cmd, genl_version, seq=None): if seq is None: seq = random.randint(1, 1024) 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 @@ -264,7 +264,7 @@ class GenlMsg: self.hdr = nl_msg.raw[0: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) @@ -358,7 +358,7 @@ class YnlFamily(SpecFamily): raw >>= 1 i += 1 else: - value = enum['entries'][raw - i] + value = enum.entries_by_val[raw - i].name rsp[attr_spec['name']] = value def _decode(self, attrs, space): |