Skip to content

Commit

Permalink
netlink: dump_attrs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
svinota committed Mar 20, 2024
1 parent f70b7a3 commit 3880505
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions pyroute2/netlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,16 +1393,23 @@ def dump_attrs(self, attrs):
for i in attrs:
if isinstance(i, nlmsg_base):
ret.append(i.dump())
elif isinstance(i[1], nlmsg_base):
# catch nlmsg
ret.append([i[0], i[1].dump()])
elif isinstance(i[1], (set, list, tuple)):
# catch iterables
ret.append([i[0], self.dump_attrs(i[1])])
elif isinstance(i[1], bytes):
ret.append([i[0], hexdump(i[1])])
elif isinstance(i, (set, list, tuple, nla_slot)):
if isinstance(i[1], nlmsg_base):
# catch nlmsg
ret.append([i[0], i[1].dump()])
elif isinstance(i[1], (set, list, tuple)):
# catch iterables
ret.append([i[0], self.dump_attrs(i[1])])
elif isinstance(i[1], bytes):
ret.append([i[0], hexdump(i[1])])
else:
ret.append([i[0], i[1]])
elif isinstance(i, dict):
if 'attrs' in i:
i['attrs'] = self.dump_attrs(i['attrs'])
ret.append(i)
else:
ret.append([i[0], i[1]])
ret.append(i)
return ret

def dump(self):
Expand Down

0 comments on commit 3880505

Please sign in to comment.