pyroute2
pyroute2 copied to clipboard
ValueError: too many values to unpack (expected 2) when creating/deleting rules
Rules are created despite the error being thrown, and the same for deletion.
Step to reproduce, with pyroute2 0.6.9 version:
import pyroute2 from socket import AF_INET6 ndb = pyroute2.NDB() rule = {'dst': '2001:db8::f816:3eff:fe14:ce99', 'table': 79, 'dst_len': 128, 'family': 10} ndb.rules[rule]
Traceback (most recent call last):
File "
As expected the rule is not there, but when trying to create it:
ndb.rules.create(rule).commit()
Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/pr2modules/ndb/objects/init.py", line 876, in apply (self.sources[self['target']].api(self.api, method, **req)) File "/usr/lib/python3.9/site-packages/pr2modules/ndb/source.py", line 285, in api return getattr(self.nl, name)(*argv, **kwarg) File "/usr/lib/python3.9/site-packages/pr2modules/iproute/linux.py", line 2244, in rule ret = tuple(ret) File "/usr/lib/python3.9/site-packages/pr2modules/netlink/nlsocket.py", line 908, in nlm_request for msg in self.get( File "/usr/lib/python3.9/site-packages/pr2modules/netlink/nlsocket.py", line 734, in get raise msg['header']['error'] pr2modules.netlink.exceptions.NetlinkError: (17, 'File exists')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
Though the rule gets actually created: $ ip -6 rule 0: from all lookup local 1000: from all lookup [l3mdev-table] 32000: from all to 2001:db8::f816:3eff:fe14:ce99 lookup br-ex 32766: from all lookup main
And listing it now is present on NDB:
ndb.rules[rule] {'dst': '2001:db8::f816:3eff:fe14:ce99', 'table': 79, 'dst_len': 128, 'family': 10, 'target': 'localhost', 'tflags': None, 'src_len': 0, 'tos': 0, 'action': 1, 'flags': 0, 'src': None, 'iifname': None, 'goto': None, 'priority': 32000, 'fwmark': None, 'flow': None, 'tun_id': None, 'suppress_ifgroup': None, 'suppress_prefixlen': 4294967295, 'fwmask': None, 'oifname': None, 'l3mdev': None, 'uid_range': None, 'protocol': None, 'ip_proto': None, 'sport_range': None, 'dport_range': None, 'res1': 0, 'res2': 0}
Sometimes it also happens the other direction:
ndb.rules[rule] {'dst': '2001:db8::f816:3eff:fe14:ce89', 'table': 79, 'dst_len': 128, 'family': 10, 'target': 'localhost', 'tflags': None, 'src_len': 0, 'tos': 0, 'action': 1, 'flags': 0, 'src': None, 'iifname': None, 'goto': None, 'priority': 32000, 'fwmark': None, 'flow': None, 'tun_id': None, 'suppress_ifgroup': None, 'suppress_prefixlen': 4294967295, 'fwmask': None, 'oifname': None, 'l3mdev': None, 'uid_range': None, 'protocol': None, 'ip_proto': None, 'sport_range': None, 'dport_range': None, 'res1': 0, 'res2': 0} ndb.rules[rule].remove().commit() Traceback (most recent call last): File "
", line 1, in File "/usr/lib/python3.9/site-packages/pr2modules/ndb/auth_manager.py", line 68, in guard return f(obj, *argv, **kwarg) File "/usr/lib/python3.9/site-packages/pr2modules/ndb/main.py", line 546, in getitem ret = self.template(key, table) File "/usr/lib/python3.9/site-packages/pr2modules/ndb/main.py", line 388, in template return iclass( File "/usr/lib/python3.9/site-packages/pr2modules/ndb/objects/rule.py", line 65, in init super(Rule, self).init(*argv, **kwarg) File "/usr/lib/python3.9/site-packages/pr2modules/ndb/objects/init.py", line 366, in init raise KeyError('object does not exists') KeyError: 'object does not exists' ndb.rules[rule] Traceback (most recent call last): File " ", line 1, in File "/usr/lib/python3.9/site-packages/pr2modules/ndb/auth_manager.py", line 68, in guard return f(obj, *argv, **kwarg) File "/usr/lib/python3.9/site-packages/pr2modules/ndb/main.py", line 546, in getitem ret = self.template(key, table) File "/usr/lib/python3.9/site-packages/pr2modules/ndb/main.py", line 388, in template return iclass( File "/usr/lib/python3.9/site-packages/pr2modules/ndb/objects/rule.py", line 65, in init super(Rule, self).init(*argv, **kwarg) File "/usr/lib/python3.9/site-packages/pr2modules/ndb/objects/init.py", line 366, in init raise KeyError('object does not exists') KeyError: 'object does not exists'
That's for the version 0.6.9, but could be a version upgrade an option in your case?
'Cause this issue is fixed in the master / 0.7.2, as I can see
If not, then we can try to find a workaround, but I would start with a version upgrade.
Ok! thanks!