netlink.rt.routeModule
Kernel routing table interface.
A netlink.session specialization over theNETLINK_ROUTE protocol: create an instance with netlink.rt.route(), then
add, delete and list routes; the underlying socket is closed by close()
(or the to-be-closed __close). All methods block and require a sleepable
runtime.
See also
Class route
| route:__call ([pid]) | Opens a session, calling the class: netlink.rt.route([pid]). |
| route:add (opts) | Adds a route to the kernel routing table. |
| route:del (opts) | Deletes a route from the kernel routing table. |
| route:list ([opts]) | Lists all routes from the kernel routing tables. |
| route:new ([o]) | Wraps a table in the class, or derives a class from it. |
Class route in detail
- route:__call ([pid])
-
Opens a session, calling the class:
netlink.rt.route([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
-
route
a new route object;
niland"ESRCH"if no task has that pid, or the task has exited.Raises
EOPNOTSUPPon a kernel whose sockets cannot hold a namespace of their own.See also
- route:add (opts)
-
Adds a route to the kernel routing table.
Parameters
- opts
table
route parameters: optional
family(defaultAF_INET),dst_len,dst,gateway,oif, table,protocol,scope, type.dstandgatewayare the address bytes in network byte order, e.g.string.pack(">I4", net.aton("192.0.2.0")), never an integer.
Raises
the name of the errno a netlink error reply carries,EEXISTwhen the route exists. - opts
table
route parameters: optional
- route:del (opts)
-
Deletes a route from the kernel routing table.
Parameters
- opts
table
route parameters: optional
family(defaultAF_INET),dst_len,dst,oif, table, as add takes them.
Raises
the name of the errno a netlink error reply carries,ESRCHwhen no route matches. - opts
table
route parameters: optional
- route:list ([opts])
-
Lists all routes from the kernel routing tables.
Parameters
- opts
table
list options:
family, the address family of the records listed (defaultAF_UNSPEC, every family). (optional)
Returns
-
table
list of route tables, each with
family,dst_len,src_len,tos, table,protocol,scope, type,flags,dst,gateway,oifandpriority;dstandgatewayare the address bytes in network byte order; table is the header’s when the reply lacks theTABLEattribute, and any other field whose attribute the reply lacks is nil. - opts
table
list options:
- route:new ([o])
-
Wraps a table in the class, or derives a class from it. It opens no socket: calling the class
does,
netlink.rt.route().Parameters
- o table an initial object table. (optional)
Returns
-
route
the wrapped table or the derived class.
See also