Skip to content

Commit cecbc52

Browse files
donaldhkuba-moo
authored andcommitted
tools/net/ynl: Fix extack decoding for netlink-raw
Extack decoding was using a hard-coded msg header size of 20 but netlink-raw has a header size of 16. Use a protocol specific msghdr_size() when decoding the attr offssets. Signed-off-by: Donald Hunter <donald.hunter@gmail.com> Link: https://lore.kernel.org/r/20240306231046.97158-2-donald.hunter@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 62a1e41 commit cecbc52

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/net/ynl/lib/ynl.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ def get_mcast_id(self, mcast_name, mcast_groups):
353353
raise Exception(f'Multicast group "{mcast_name}" not present in the spec')
354354
return mcast_groups[mcast_name].value
355355

356+
def msghdr_size(self):
357+
return 16
358+
356359

357360
class GenlProtocol(NetlinkProtocol):
358361
def __init__(self, family_name):
@@ -378,6 +381,8 @@ def get_mcast_id(self, mcast_name, mcast_groups):
378381
raise Exception(f'Multicast group "{mcast_name}" not present in the family')
379382
return self.genl_family['mcast'][mcast_name]
380383

384+
def msghdr_size(self):
385+
return super().msghdr_size() + 4
381386

382387

383388
class SpaceAttrs:
@@ -721,7 +726,7 @@ def _decode_extack(self, request, op, extack):
721726
return
722727

723728
msg = self.nlproto.decode(self, NlMsg(request, 0, op.attr_set))
724-
offset = 20 + self._struct_size(op.fixed_header)
729+
offset = self.nlproto.msghdr_size() + self._struct_size(op.fixed_header)
725730
path = self._decode_extack_path(msg.raw_attrs, op.attr_set, offset,
726731
extack['bad-attr-offs'])
727732
if path:

0 commit comments

Comments
 (0)