You can run Lua scripts inside the kernel using the Lunatik project!
Lunatik has been previously used for scripting Netfilter and XDP
subsystems, allowing users to create complex network filters using
Lua. For instance, it has been used for filtering L7 traffic such as
HTTP and HTTPS inside the kernel.
In this talk, Lourival Vieira Neto, Marcel Moura, Ana Lúcia de Moura
and Roberto Ierusalimschy present the evolution of this framework and
illustrate a sample use case implementing a kernel-level adaptive
routing service. This service allows the system to monitor the
reliability of a network route and adjust its routing table
dynamically in case of failure. For instance, a home router might use
such service to fall back to the cellular network using a mobile phone
as a gateway. Lourival et al also spice this service up by
implementing a protocol that allows nodes to advertise themselves as
alternative gateways and for the router to notify nodes when elected
as the new gateway.
Lourival et al will describe the kernel details and associate
infrastructure interaction ( netdevice notification chain, kthread,
socket, RCU and FIB, etc).
cheers,
jamal