Module netlink

Generic netlink channel.

Exposes netlink.channel, a generic netlink family with one multicast group whose multicast/unicast are safe from softirq (netfilter hooks, XDP), for kernel-to-userspace delivery. The message body is built in Lua (e.g. with netlink.message) and sent as-is; request/response netlink is otherwise done in Lua over the socket module. Only this softirq-capable send path needs a dedicated kernel object.

Class netlink.channel

netlink.channel:multicast (cmd[, payload]) Multicasts a message to every subscriber of the channel's group.
netlink.channel:unicast (portid, cmd[, payload]) Unicasts a message to a single userspace subscriber by port id.

netlink

channel (name) Creates a generic netlink channel.


Class netlink.channel

A generic netlink channel. Returned by netlink.channel(). Backed by a generic netlink family with one multicast group; multicast and unicast are safe from softirq (netfilter hooks, XDP) and deliver to userspace subscribers of the family.
netlink.channel:multicast (cmd[, payload])
Multicasts a message to every subscriber of the channel's group. Safe to call from softirq.

Parameters:

  • cmd integer Generic netlink command.
  • payload string Message body (e.g. from netlink.message). (optional)

Returns:

    boolean whether it reached at least one subscriber.

Raises:

on an allocation error.
netlink.channel:unicast (portid, cmd[, payload])
Unicasts a message to a single userspace subscriber by port id. Safe to call from softirq.

Parameters:

  • portid integer Destination netlink port id.
  • cmd integer Generic netlink command.
  • payload string Message body (e.g. from netlink.message). (optional)

Returns:

    boolean whether it was queued to the port id (false if the port id is gone or its receive buffer is full).

Raises:

if portid is 0, or on an allocation error.

netlink

channel (name)
Creates a generic netlink channel. Registers a generic netlink family name with a single multicast group; userspace resolves the family by name (e.g. via netlink.genl) to learn the group it must join. Like a netfilter hook, it must be created at script load (process context); the returned channel lives for the runtime and its multicast/unicast may then be called from softirq.

Parameters:

  • name string Generic netlink family name (up to GENL_NAMSIZ-1 bytes).

Returns:

    netlink.channel A new channel object.

Raises:

if the name is empty or too long, or family registration fails.
generated by LDoc 1.5.0 Last updated 2026-07-04 13:06:33