Skip to content

Commit 287c59f

Browse files
committed
refactor(network_namespace): replace ip commands with rtnetlink for host-side network setup
1 parent c26efbb commit 287c59f

4 files changed

Lines changed: 352 additions & 25 deletions

File tree

Cargo.lock

Lines changed: 268 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ authors = ["pan-ic <dev@pan.fr>"]
99
[dependencies]
1010
anyhow = "1.0.103"
1111
clap = { version = "4.6.1", features = ["derive"] }
12+
futures = "0.3"
1213
libc = "0.2.186"
1314
nix = { version = "0.31.3", features = ["fs", "hostname", "mount", "process", "sched", "signal"] }
15+
rtnetlink = "0.21.0"
1416
thiserror = "2.0.18"
17+
tokio = { version = "1.53.1", features = ["rt", "rt-multi-thread"] }

DEVLOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ stack working: container namespace with veth pair, IP assignment,
5252
loopback, default route, MASQUERADE NAT, internet access from inside
5353
the namespace. Next: implement in Rust using rtnetlink then raw netlink.
5454

55-
## 2026/07/24 Hard session
55+
## 2026/07/23 Hard session
5656
To understand how veth network, ip and netns tools works I had to create manually first then, using std::process::Command I replicated by code
5757
the manual steps. During the manual experiment a net namespace has been created manually. Thing that differs and bring some trouble with the
5858
container is that the clone call with the CLONE_NEWNET flag creates an anonymous namespace that cannot be used with netns so I had to use nsenter.
5959
The next steps are to change Command() use to rtnetlink; which is only a transition to understand the framework because that would need to switch
6060
the actual code to async only for network creation so, the last step is to use directly unix socks to create the network.
61+
62+
## 2026/07/24 Quiet session
63+
Apparently netlink_packet_route::link::LinkMessage exist behind packet::route::LinkMessage inside rtnetlink, had to check public re-exports.
64+
Implementation using rtnetlink blocks on child setup because of AsyncSockets, in theory it could be implemented to finish the experiment but I use
65+
raw socket as final implementation so I've mixed rtnetlink for parent + nsenter for child. Child would use exactly the same init step than parent but
66+
after calling new_connection_with_socket() that is the remote connection to the child network.

0 commit comments

Comments
 (0)