Skip to content

Commit

Permalink
Fixed header type when there are multiple array to encode
Browse files Browse the repository at this point in the history
TCA_EMATCH_TREE_LIST is using type as an index value for nested
elements.

Since we can not override this value from upper classes, I increment the
type value without warranty it would work for other classes that use
this code.
  • Loading branch information
Vic063 committed Jul 5, 2018
1 parent 3db590a commit 254fc3e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyroute2/netlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,12 +1007,15 @@ def encode(self):

# handle the array case
if self._nla_array:
header_type = 1
for value in self.getvalue():
cell = type(self)(data=self.data,
offset=offset,
parent=self)
cell._nla_array = False
cell['header']['type'] = 1
cell['header']['type'] = header_type
header_type += 1

if cell.cell_header is not None:
cell.header = cell.cell_header
cell.setvalue(value)
Expand Down

0 comments on commit 254fc3e

Please sign in to comment.