Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lost src and src_len in ndb.routes.create #1199

Open
Tsvetk opened this issue Jun 7, 2024 · 0 comments
Open

lost src and src_len in ndb.routes.create #1199

Tsvetk opened this issue Jun 7, 2024 · 0 comments

Comments

@Tsvetk
Copy link

Tsvetk commented Jun 7, 2024

pyroute2 0.7.12

from pyroute2 import NDB

ndb = NDB(log='debug', auto_netns=True)

ndb.sources.add(netns='testns')  # connect to a namespace
print(ndb.sources.summary())

with ( ndb.interfaces.create(ifname='veth0', kind='veth',
           peer={'ifname':'eth0', 'net_ns_fd':'testns', }, state='up',)) as veth0:
    veth0.set(state='up')
    veth0.add_ip(address='10.0.0.1', prefixlen=24)

with ndb.interfaces.wait(target='testns', ifname='lo') as peer:  # wait for the peer
    peer.set(state='up')  # bring it up

with ndb.interfaces.wait(target='testns', ifname='eth0') as peer:  # wait for the peer
    peer.set(state='up')  # bring it up
    peer.add_ip('10.0.0.2', prefixlen=24)  # add address

ndb.routes.create(target='testns', dst='10.0.0.0/24', src='10.0.0.2/24',  oif=2 ).commit()

When create namespace : "lo" is down and in the namespace no routers from eth0 and need to create route like
10.0.0.0/24 dev veth0 proto kernel scope link src 10.0.0.1

We have next errors : src and src_len lost in line 2024-06-07 22:25:19,393

2024-06-07 22:25:19,390 DEBUG pyroute2.ndb.140716529876704.rtnl_object: ignore error 17 for {'multipath': [], 'metrics': {}, 'deps': 0, 'target': 'testns', 'dst': '10.0.0.0', 'family': <AddressFamily.AF_INET: 2>, 'dst_len': 24, 'src': '10.0.0.2', 'src_len': 24, 'oif': 2}
2024-06-07 22:25:19,391 DEBUG pyroute2.ndb.140716529876704.rtnl_object: run fallback <function fallback_add at 0x7ffb1e9a68c0> ({'target': 'testns', 'family': <AddressFamily.AF_INET: 2>, 'dst_len': 24, 'dst': '10.0.0.0', 'oif': 2, 'src': '10.0.0.2', 'src_len': 24, 'multipath': [], 'metrics': {}, 'deps': 0})
2024-06-07 22:25:19,391 DEBUG pyroute2.ndb.140716529876704.rtnl_object: ignore incomplete idx_req in the fallback
2024-06-07 22:25:19,391 DEBUG pyroute2.ndb.140716529876704.rtnl_object: stats: apply add {objid 140716492323024, wtime 0.1, mqsize 1, nqsize 0}
2024-06-07 22:25:19,393 DEBUG pyroute2.ndb.140716529876704.rtnl_object: load_sql load: ('testns', 0, 2, 24, 0, 0, 254, 4, 0, 1, 0, '10.0.0.0', None, None, 2, None, 0, None, None, None, 254, None, '', '', None, None, None, None, 0)
2024-06-07 22:25:19,393 DEBUG pyroute2.ndb.140716529876704.rtnl_object: load_sql names: ['target', 'tflags', 'family', 'dst_len', 'src_len', 'tos', 'table', 'proto', 'scope', 'type', 'flags', 'dst', 'src', 'iif', 'oif', 'gateway', 'priority', 'prefsrc', 'protoinfo', 'flow', 'table', 'mark', 'via', 'newdst', 'pref', 'encap_type', 'route_id', 'gc_mark', 'deps']
None
Traceback (most recent call last):
File "/home/tsvetkov/tests/ssl_clnt_srv_ndb.py", line 25, in
ndb.routes.create(target='testns', dst='10.0.0.0/24', src='10.0.0.2/24', oif=2 ).commit() #
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/auth_manager.py", line 67, in guard
return f(obj, *argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 721, in commit
raise e_i
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 710, in commit
return self.apply(mode='commit')
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/auth_manager.py", line 67, in guard
return f(obj, *argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/route.py", line 743, in apply
return super(Route, self).apply(rollback, req_filter, mode)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/auth_manager.py", line 67, in guard
return f(obj, *argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 957, in apply
if self.check():
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 772, in check
self.load_sql()
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/route.py", line 746, in load_sql
super(Route, self).load_sql(*argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 1136, in load_sql
self.update_from_sql(spec)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 1076, in update_from_sql
self.load_value(key, value)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 1094, in load_value
elif key in self.fields_cmp and self.fields_cmp[key](self, value):
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/route.py", line 571, in _cmp_target
right = [MPLSTarget(x) for x in json.loads(right)]
File "/usr/lib/python3.10/json/init.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant