Recent submissions

Comment · 1 year ago
With GSoC approaching, I wrote an article on how to extend Lua with kernel APIs and embed the Lua interpreter into Linux subsystems using Lunatik—an in-kernel Lua runtime that enables dynamic scripting inside the Linux kernel without requiring recompilation.

The post covers key aspects of Lunatik bindings, including runtime management, integration into the framework, and practical examples like Xtables and kfifo.

Whether you're considering a GSoC project or just interested in kernel scripting with Lua, this article might be a useful reference!

Comment · 1 year ago
Lunatik v3.6 Released

We are pleased to announce the release of Lunatik v3.6, introducing new features and improvements for in-kernel Lua scripting.

What is Lunatik?

Lunatik is an in-kernel Lua runtime that enables dynamic scripting within the Linux kernel, allowing extensions and modifications without recompilation. It provides a flexible way to develop networking features, security enhancements, and system automation.

What's New in v3.6?

New kernel bindings:

- Netfilter & Xtables – Packet filtering and firewall extensions

- Completion – Efficient synchronization primitives

- FIFO – Kernel-level queue management

Broader Kernel Support – Now compatible with Linux 5.x series

OpenWRT & OpenWiFi support – Expanding Lunatik to embedded and networking environments OpenWRT feed: https://github.com/luainkernel/openwrt_feed/tree/openwrt-23....

MoonScript support – A more expressive scripting option

New Examples:

- DNS Blocking – Filtering unwanted domains

- DNS Doctoring – Modifying DNS responses dynamically Bug Fixes & Stability Improvements

Acknowledgments

We would like to thank our contributors: @sav and @marcelstanley from Ring-0 Networks, @sheharyaar, @jperon, @vincentmli, @rustedusted, @glk0 – your contributions made this release possible.

We also appreciate the support from Google Summer of Code and Firas from 80211 Networks.

Join the Discussion

To discuss or contribute, join our Matrix room: https://matrix.to/#/#lunatik:matrix.org

Full release notes: https://github.com/luainkernel/lunatik/releases/tag/v3.6

Best regards, The Lunatik Team

Comment · 2 years ago
It has been a while since we have introduced XDPLua, a Lua binding for running scripts inside the XDP (eXpress Data Path) environment using the Lunatik framework. Since then both XDP and Lunatik have evolved quite a bit. Especially, now it is possible to expose kernel functions (kfuncs) to eBPF programs, instead of relying only on eBPF Helpers. This feature finally allowed us to get rid of the hard requirement of running our Lua binding as built-in in the kernel and enabled us to run it as a kernel module. Moreover, Lunatik has also evolved towards a modular framework. Now we can develop new bindings for kernel subsystems as Lua libraries and link them as loadable kernel modules. Thus, leveraging these two features, we have created a new Lua binding for the XDP subsystem. We are glad to introduce in this article the new LuaXDP library!
Comment · 2 years ago
Thanks for sharing this! Is it open source?
Comment · 2 years ago
Potentially, yes. However, I didn't try it. You could even disable GC completely. Lunatik provides some facilities that could be useful in this scenario as well, such as RCU tables and shared objects. For instance, you could pre-allocate the entire memory to be used by your Lua states and treat them as volatile. In this case, you could persist state on the shared objects stored and synchronized through a RCU table. Of course, you could implement your own GC or tune the existent GC modes as well.
Comment · 2 years ago
Comment · 2 years ago
Please refer to Section 3 from [1], this was extensively discussed there.

[1] https://www.netbsd.org/~lneto/dls14.pdf

However, giving you a short answer, we use Lua mainly because it's easy both to extend and to embed. It's implemented as an almost "freestanding" C library. Moreover, it has a considerable small footprint (~250 KB) in comparison to other scripting languages (e.g., Python has a few MB). Moreover, Lua has automatic memory management, fully isolated execution states, protected calls, among other features.

Comment · 2 years ago
Comment · 2 years ago
the most explored use case is for scripting networking, please see:

[1] https://legacy.netdevconf.info/0x14/session.html?talk-linux-... [2] https://netdevconf.info/0x17/sessions/talk/scripting-the-lin... [3] https://www.netbsd.org/~lneto/dls14.pdf [4] https://www.slideshare.net/eurobsdcon/lneto-npf-scripting [5] https://2018.eurobsdcon.org/static/slides/Fast,%20Flexible%2...

However, it was conceived for extensibility and flexibility in general, in the spirit of [6]. It has been used also for scripting CPU frequency scaling, debugging, application sandboxing among others [7,8].

[6] https://web.stanford.edu/~ouster/cgi-bin/papers/scripting.pd... [7] https://drive.google.com/file/d/1TJ50IEbRXlBz-TxheGdkO-b4vLS... [8] https://youtu.be/-ufBgy044HI?si=IT4FOqeldA-jsg2r (Portuguese only)

ZFS also has its own kernel Lua version (I'd love to unify them, BTW).

Moreover, we have some simplified examples on our repository [9].

[9] https://github.com/luainkernel/lunatik?tab=readme-ov-file#ex...

Comment · 2 years ago
Perhaps when we have a fully scriptable operating system, we might call it Lunatix =).

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton