UMNET modules
Contents |
umnetnull
This module implements the null network: msocket and socket calls fail returning -1, errno EAFNOSUPPORT for all the protocols families. No networking is possible using umnetnull thus this submodule is used to deny networking.
$ mount -t umnetnull none /dev/net/null $ mstack /dev/net/null ip link Cannot open netlink socket: Address family not supported by protocol $ mstack /dev/net/null telnet my.host.somedomain.it Trying 10.20.30.40 telnet: Unable to connect to remote host: Address family not supported by protocol $ mstack /dev/net/null nc -u -l Can't get socket : Address family not supported by protocol
umnetcurrent
The umnetnative network submodule provides a stack special file to access the same network stack of the calling process.
$ ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:1e:8c:b1:88:6f brd ff:ff:ff:ff:ff:ff $ mount -t umnetnative none /dev/net/native $ mstack /dev/net/native ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:1e:8c:b1:88:6f brd ff:ff:ff:ff:ff:ff
umnetlwipv6
Mounting a umnetlwipv6 stack means to start a lwipv6 stack and to associate the stack to a specific stack special file.
$ mount -t umnetlwipv6 none /dev/net/myip $ mstack /dev/net/myip ip link 1: lo0: <LOOPBACK,UP> mtu 0 link/loopback 2: vd0: <BROADCAST> mtu 1500 link/ether 02:02:20:63:ef:06 brd ff:ff:ff:ff:ff:ff
Without any option, umnetlwip sets up one vde interface (provided there is a vde_switch running on the standard socket).
It is possible to start a lwipv6 stack with several interfaces. lwipv6 supports vde, tun or tap interfaces. The number, kind, and parameters for interfaces can be set by mount options (-o). Here are some examples:
$ mount -t umnetlwipv6 -o "vd0=/tmp/myswitch[4]" none /dev/net/yourip $ mstack /dev/net/yourip ip link 1: lo0: <LOOPBACK,UP> mtu 0 link/loopback 2: vd0: <BROADCAST> mtu 1500 link/ether 02:02:62:84:74:06 brd ff:ff:ff:ff:ff:
vd0 is connected to the port number 4 of the switch /tmp/myswitch
$ mount -t umnetlwipv6 -o tn0=mytun none /dev/net/yourip $ mstack /dev/net/yourip ip link 1: lo0: <LOOPBACK,UP> mtu 0 link/loopback 2: tn0: <> mtu 0 link/generic
The umnetlwipv6 stack defined by the special file /dev/net/yourip has a tun interface connected to mytun. A user can open a tun interface only if prviously authorized by the command:
# tunctl -u renzo -t mytun
where renzois an example of username and mytun is the name of the tun interface used in our example.
Several mount options separated by commas allow to define multiple interfaces:
$ mount -t umnetlwipv6 -o "tn0=mytun,vd0=/tmp/myswitch[4]" none /dev/net/yourip $ mstack /dev/net/yourip ip link 1: lo0: <LOOPBACK,UP> mtu 0 link/loopback 2: vd0: <BROADCAST> mtu 1500 link/ether 02:02:0b:d3:b2:06 brd ff:ff:ff:ff:ff:ff 3: tn0: <> mtu 0 link/generic
umnetlink
This umnet submodule can be used to rename modules. It is named umnetlink as it recalls the idea of symbolic links when applied to stacks instead of files.
$ mount -t umnetnative none /dev/net/native $ mstack /dev/net/native ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:1e:8c:b1:88:6f brd ff:ff:ff:ff:ff:ff $ mount -t umnetlink /dev/net/native /dev/net/kstack $ mstack /dev/net/kstack ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:1e:8c:b1:88:6f brd ff:ff:ff:ff:ff:ff
In the example above /dev/net/kstack becomes a symbolic umnetlink of /dev/net/native.
It is possible to link some some address families. When the target of a mount is already an already existing stack special file, it is possible to use the previous stack for the other families (not linked by the current mount) by the option o, override. This example loads an lwipv6 stack on /dev/net/ourip redefines the default network as a native network and links ourip to the default network just for protocol families IPV4, IPV6, netlink and packet. With the option o all the other families gets inherited by the previous default stack i.e. native.
$ um_add_service umnet $ mount -t umnetlwipv6 none /dev/net/ourip $ mount -t umnetnative none /dev/net/default $ mount -t umnetlink -o 4,6,p,n,o /dev/net/ourip /dev/net/default $ ip link 1: lo0: <LOOPBACK,UP> mtu 0 link/loopback 2: vd0: <BROADCAST> mtu 1500 link/ether 02:02:11:fb:67:06 brd ff:ff:ff:ff:ff:ff
umnetlink uses the following options:
- 4 or ipv4IPv4 (PF_INET)
- 6 or ipv6 IPv6 (PF_INET6)
- u or unixUnix/Local (PF_UNIX)
- n or netlink Netlink (PF_NETLINK)
- p or packet Packet (PF_PACKET)
- i or irda Irda (PF_IRDA)
- b or bluetooth Bluetooth (PF_BLUETOOTH)
- ip all ip related protocols: ipv4, ipv6, packet and netlink
- other protocols can be specified by their code by the # option, e.g. -o ....#33...
- it is possible to prefix the protocols by + or - to add or remove protocols. -o +all,-unix
- o override: inherit the remaining families from the stack we are overriding.