luainkernel / lunatik

Lunatik is a framework for scripting the Linux kernel with Lua.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Monitoring socket states

elimisteve opened this issue · comments

How awesome would it be to if we could have systemd's socket activation functionality without the bloat of systemd? What if we just needed lunatik to listen for socket connections on certain ports then spin up the appropriate process to handle that request?!

I would love to see this!

We'd need to monitor netlink and eBPF events, it sounds like? Details: https://chat.openai.com/share/1b9e204d-14ad-493d-9ba3-cd54162aaa74

hi @elimisteve, I'm not that familiar with systemd, but if I got it correctly you want something like an in-kernel inetd, right? I think it would be quite possible and the missing part for being able to doing this on Lunatik is the ability to spawn a process. We could even have an init.lua (something that I've though in the past actually). I think a good starting point would be to bind fork/clone. However, if you want to spawn the process from the user space itself, we just lack the ability to dup the socket's fd and attribute it to the service process. I can help you (or anyone else that would like to tackle this); however, I don't have time now to do this by myself.

We'd need to monitor netlink and eBPF events, it sounds like?

I don't think we would need neither; we could use AF_UNIX, which is already supported by Lunatik.