Open fisiognomico opened 1 month ago
Quick update: I continued to investigate this issue on my own, and it seems that it is not related to netlink at all, as the same code which calls directly a netlink socket created with the NETLINK_ROUTE
protocol works as expected.
It seems that is more related to how tokio spawn thread using the clone3
syscall, which at one point they all seem to hang in a deadlock.
Honestly this is just an assumption based on the output of strace, where every spawned thread is waiting in a futex
.
Given this premises it might be more appropriate to complete the NetworkNamespace
interface without using tokio at all, as the code that is present at the moment is doing, and extend its capabilities to manipulate network resources.
I will work on this on a side project, when I have a complete solution I might propose a PR, if you feel that this discussion is orthogonal to your project feel free to close this issue.
Thanks for the patience!
Hi everyone! I will briefly explain my issue: I need to configure the network interfaces inside a network namespace, in this example I will simply stick on how to set
lo
up. So my goal is to get the same outcome asip -n test link set lo up
. AsNetworkNamespace
does not offer a similar interface I tried to mimic both the functioning ofunshare_processing
and how iproute2 switches to a target namespace.Using
rtnetlink
to setlo
up I wrote this simple routine:And the main logic of the application of how the switch namespace is implemented in this function:
What I would expect is that the
lo
interface inside the namespace switches to up and that the function returns normally, instead it hangs indefinitely during the interface index retrieval:Also if instead of calling the set_lo_up() function I simply execute
ip link set lo up
, for example using thestd::process::Command
crate, it works as expected. If anyone wants to debug this bug or get a better idea of it, I create a minimal repository that reproduces it.I tried to look a bit using strace but besides some esoteric buffers returned from recv() I can not recognize anything that is much different from the behavior of iproute2, and unfortunately I do not have enough experience with the Netlink protocol to grasp much out of it. Anyway if anybody has some resources or tips on how to begin on how to better debug it from here I would surely invest some effort to propose an improvement to this project in the future!
Thanks.