pyroute2
pyroute2 copied to clipboard
lost src and src_len in ndb.routes.create
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