-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
NDB: lost sync in apply() (due 'File exists'?) when trying to bring up an interface inside a network namespace #628
Comments
Sorry for the delay. Please try # notice "target" instead of "net_ns_fd" here:
peer_dict = {"target": nsname, "ifname": peer_ns_if} Regarding the question:
must be OK, if not — pls open a ticket |
@svinota for me this still happens with your suggested change ( |
Any news here? I run into the same error if I try to execute the following: #!/usr/bin/python3
from pyroute2 import NDB
ndb = NDB(debug=True,log="on")
ndb.sources.add(netns="ns1")
# move interface to namespace "ns1"
dev = ndb.interfaces[{"ifname": "enp0s3"}]
dev = dev.set("target", "ns1").commit()
# add ip address
dev = dev.add_ip("192.168.42.21/24")
dev = dev.commit() |
(/me back from long absence) Found the issue, will be fixed on Thursday. |
A proper fix is on the way. Bug-Url: #628
Workaround is merged, pls check if it helps. But the proper fix is on the way. |
Seems still to be broken:
Log:
|
Thanks, analyzing the log |
@mawiegand may I look at the code you run? I believe you tried to move a real interace between netns, but for me it works. Probably it's not a bug but a poor documentation that should be updated. |
I used this code snippet:
And yes it is a real interface. Do I need to move real interfaces differently? |
Pls try that. # dev = dev.set("target", "ns1").commit()
dev = dev.set("net_ns_fd", "ns1").commit() |
I have to finally do something with that explicit |
No, actually it already works on the master branch. Could you please check that you run the code on the master and tell me which kernel and Python versions do you use. |
Sorry, for the late response. I was very busy last weeks. I am using Kernel 5.5.1 and Python 3.8.1. I changed my test code from #!/usr/bin/python3
from pyroute2 import NDB
ndb = NDB(debug=True,log="on")
ndb.sources.add(netns="ns1")
# move interface to namespace "ns1"
dev = ndb.interfaces[{"ifname": "enp0s3"}]
dev = dev.set("target", "ns1").commit()
# add ip address
dev = dev.add_ip("192.168.42.21/24")
dev = dev.commit() to #!/usr/bin/python3
from pyroute2 import NDB
ndb = NDB(debug=True,log="on")
ndb.sources.add(netns="ns1")
# move interface to namespace "ns1"
dev = ndb.interfaces[{"ifname": "enp0s3"}]
dev = dev.set("target", "ns1").commit()
# get updated interface
dev = ndb.interfaces[{"ifname": "enp0s3"}]
# add ip address
dev = dev.add_ip("192.168.42.21/24")
dev = dev.commit() Now it's working. But calling |
Got it. Thanks a lot for the case, fixing. |
Creating a route inside a namespace with ndb.routes.create(target=nsname, dst=target_network, gateway=next_hop).commit() leads to same behavior. But the route is created on the system (verified via |
A bunch of fixes has arrived. |
Thanks!
Seems to be working for 'normal' routes now. ndb.routes.create(target=nsname, dst='default', gateway=next_hop).commit() still leads to same behavior. |
It's weird but I have to confirm. There is something really broken. Fixing Thanks for your patience and thanks for reporting. |
Thanks for your hard work. If I can assist you somehow please let me know!
In the default namespace it works without problems. |
On the assignment step:: # 'default', '0/0', '0.0.0.0/0' → self['dst'] = '' self['dst_len'] = 0 Bug-Url: #628
Just to notify that the next chunk of fixes has arrived. The functional tests are not ready yet, working on it. |
Make Basic class work both in the main and a custom netns transparently, thus applying same tests for the 'localhost' target as well as for netns targets. Bug-Url: #628
Closing the ticket. Feel free to reopen it or to create a new one in the case you hit further issues. |
https://build.opensuse.org/request/show/785076 by user dirkmueller + dimstar_suse - update to 0.5.10: * general: don't use pkg_resources <svinota/pyroute2#677> * iproute: fix Windows support * netlink: provide the target field * ndb: use the target field from the netlink header * ndb: multiple SQL fixes, transactions fixed with the PostgreSQL backend * ndb: multiple object cache fixes <svinota/pyroute2#683> * ndb.schema: drop DB triggers * ndb.objects: fix object management within a netns <svinota/pyroute2#628> * ndb.objects.route: support route metrics * ndb.objects.route: fix default route syntax
Hi and thanks for the great library!
I have been experimenting with the NDB interface and network namespaces, and I'm currently struggling to make the network interface inside a netns to go up.
As similar procedure works fine with the "IPDB-way", I think it is a bug, but I couldn't figure out where should I start looking to fix it.
P.S. A quick side-question, is it safe to use multiple context managers, ala
with ndb.interfaces[peer_dict] as peer_veth, nbd.interfaces[root_ns_if] as root_veth:
?NDB
interface on main namespace
Interface inside the NS
Debug log
IPDB variant
Main namespace
Inside the namespace
Test script
ip -all netns delete
.The text was updated successfully, but these errors were encountered: