Networking in Merry › Configurable networking for Merry [slirp]
Last week I talked about adding a pasta-backend to void. At the start of this week, I committed to exploring writing a new slirp implementation in OCaml. I have some experience of this when I've worked on VPNKit and, in some ways, I do not need this to be as portable -- it can aim at being highly configurable and for Linux-only.
Establishing a rootless proxy network for a container requires a fair bit of low-level Linux programming. In particular, there is the initial setup of the TAP device inside the new network namespace. I found Thomas's netlink libraries that allowed me to configure the TAP device by bringing it up, adding an address for the device, and establishing a default route for all traffic.
After that, I focused on getting some of the more simple protocols up and running and set a goal to get a container to be able to ping the server you are currently reading this from. This required bridging the Ipv4-ICMP packets and everything else I just dropped on the floor.
To send out ICMP packets, you can use a datagram socket (otherwise you would need higher priveleges to open a raw socket). Again, I searched around online and found Thomas's nox-icmp-eio package. After getting the ping to work, I had a bit of worried feeling. Why did these packages exist... is there an existing slirp tool. Yes, sigh.
It turns out, after some out-of-band dicussion, there are no less than four slirp-like tools in OCaml.