4 ms·
I made a Terrible decision of a project at Netflix. The idea was that you could swap out an IPv4 (AF_INET/SOCK_STREAM) socket with an AF_INET6 one. Turns out a
by sargun 3y ago
I made a Terrible decision of a project at Netflix. The idea was that you could swap out an IPv4 (AF_INET/SOCK_STREAM) socket with an AF_INET6 one.
Turns out actually doing this with the Linux kernel is exceptionally difficult. You can swap out the underlying sk, but doing it safely is damn near impossible because the two data structures aren’t really built like that.
One day, I’d love if someone added the ability to swap Unix sockets for TCP sockets at runtime to the kernel — for other reasons.
- endre 3y agoTell us more about Netflix experimental projects like this.
- dezgeg 3y agoDid you try just dup2()'ing a new socket file descriptor over the old socket file descriptor? Probably it bring other kinds of problems, but would be interesting to hear what they are.
- sargun 3y agoYep. You lose sockopts (trivially restorable), async ownership (less trivially restorable, but with some kernel patches, it’s possible), and epoll registration (which omg, wtf.). The other problem is that we found runtimes that would immediately send data after a non blocking connect (or receive data), and you needed a way to kick these off again. It was really a nightmare to restore all that state in a running socket. The real solution was to add a new address family, and patch the kernel (as opposed to a module), that could dynamically switch back and forth (think AF_KCM). Unfortunately, I never got around to that.