Lunatik

netlink.rt.linkModule

Network interface (link) management.

A netlink.session specialization over the NETLINK_ROUTE protocol: create an instance with netlink.rt.link() to list the kernel’s interfaces and set their up state; the underlying socket is closed by close() (or the to-be-closed __close). All methods block and require a sleepable runtime.

See also

link:__call ([pid]) Opens a session, calling the class: netlink.rt.link([pid]).
link:list ([opts]) Lists all network interfaces from the kernel.
link:new ([o]) Wraps a table in the class, or derives a class from it.
link:set (opts) Sets an interface’s administrative up state.
link:__call ([pid])
Opens a session, calling the class: netlink.rt.link([pid]).

Parameters

  • pid integer a task whose network namespace the session talks to, as socket.new takes it; the initial network namespace when absent. (optional)

Returns

    link a new link object; nil and "ESRCH" if no task has that pid, or the task has exited.

Raises

EOPNOTSUPP on a kernel whose sockets cannot hold a namespace of their own.

See also

link:list ([opts])
Lists all network interfaces from the kernel.

Parameters

  • opts table list options, of which a link takes none. (optional)

Returns

    table list of link tables, each with family, type, ifindex, flags, change, name and mtu; a field whose attribute the reply lacks is nil.
link:new ([o])
Wraps a table in the class, or derives a class from it. It opens no socket: calling the class does, netlink.rt.link().

Parameters

  • o table an initial object table. (optional)

Returns

    link the wrapped table or the derived class.

See also

link:set (opts)
Sets an interface’s administrative up state.

Parameters

  • opts table link parameters: ifindex and up (boolean).

Raises

on a netlink error.