FS#15049 - [netcfg] manage tun/tap interfaces
Attached to Project:
Arch Linux
Opened by Lisa Denia (eiffel56) - Wednesday, 10 June 2009, 23:42 GMT
Last edited by Rémy Oudompheng (remyoudompheng) - Sunday, 19 June 2011, 21:53 GMT
Opened by Lisa Denia (eiffel56) - Wednesday, 10 June 2009, 23:42 GMT
Last edited by Rémy Oudompheng (remyoudompheng) - Sunday, 19 June 2011, 21:53 GMT
|
Details
It is requested that netcfg supports setting up persistent
tun/tap devices. iproute2 can be used to do this (see
comment by Thomas below).
Orgignal bug report: ==================== The Arch Linux initscripts lack support of defining virtual network interfaces using tun/tap. As it is very annoying to write own scripts every time, or even place them in /etc/rc.local or whatever, I think it should be possible to define tun/tap interfaces using our init scripts. We should also add a file in /etc/conf.d where the tun/tap configuration can be separately held and which explains the usage, similar to the one included in bridge-utils. Attached are two patches. The first(initscripts_network_add_tuntap_support.patch) shows how it could be implemented. It applies to latest initscripts source from git. The second one adds a configuration/explanation file in /etc/conf.d and applies to the latest uml_utilities PKGBUILD from ABS. Any suggestions appreciated ;). |
This task depends upon
Closed by Rémy Oudompheng (remyoudompheng)
Sunday, 19 June 2011, 21:53 GMT
Reason for closing: Implemented
Additional comments about closing: In version 2.6.1
Sunday, 19 June 2011, 21:53 GMT
Reason for closing: Implemented
Additional comments about closing: In version 2.6.1
This replaces initscripts_network_add_tun_tap_support2.patch.
1) It doesn't abstract the tunctl stuff, but uses its exact syntax. We did this with ifconfig in rc.conf and are now unable to properly switch to /sbin/ip. We should rather have the possibility to specify a tap interface and a user who owns it and build the command ourselves.
2) If we do this, we should split tunctl from uml_utilities. In fact, uml_utilities is completely worthless (UML doesn't even work from what I see) and the only reason to install it is because you want tunctl. And people always try pacman -S tunctl, nobody even has the idea of looking into uml_utilities.
We could parse one single string, or use different variables for storing the options. I think the last option is the better one.
Another thing is that hardcoding the user in the configuration is somewhat unclean. But what to do instead?
Well, one possibility could be to add a new group, lets just call it "tap", and assign all tap devices to that group by default. If one wishes to assign an individual tap interface to another user/group, he'll use seperate variables.
A sample configuration would look like this:
tap_tap1_user="foo_user"
tap_tap1_group="" #Optional, just for clarification
tap_tap2_user="" #Optional, just for clarification
tap_tap2_group="foo_group"
TAP_INTERFACES=(tap0 tap1 tap2)
Which would create 3 tap interfaces. Everyone in the "tap" group would have full access to tap0(the default setting). The user "foo_user" would have full access to tap1, and the group "foo_group" would have full access to tap2.
Thats easy to use, and can be extended without breaking something. Adding a tap0 interface will be just a
TAP_INTERFACES=(tap0)
for the most users.
Using this method, we could also easily add a new network interface configuration:
eth0_ip="192.168.0.123"
eth0_netmask="255.255.255.0"
eth0_broadcast="192.168.0.255"
eth2="eth2 192.168.0.124 netmask 255.255.255.0 broadcast 192.168.0.255"
INTERFACES=(eth0 eth1 eth2)
This would configure the 3 network interfaces eth0, eth1 and eth2. eth0 is manually configured, eth1 uses dhcp(default) and eth2 is configured using the old method. We can easily add new fields, and it allows us a smooth transition from the old network interface configuration scheme to the possibly new one. But well, thats another thing.
So I made an example implementation for the tun/tap stuff. Its divided into 3 parts:
uml_utilities_notuntap.patch:
Disables building of tunctl in extra/uml_utilities. Applies to the latest PKGBUILD from ABS.
tunctl.tar.gz:
A new package which just contains tunctl. It also adds the tun/tap configuration file in /etc/conf.d, and creates the "tap" group. Conflicts with old uml_utilities(which contains tunctl by itself).
initscripts_network_add_tun_tap_support4.patch:
Adds tun/tap functionality to the network initscript. Applies to the latest initscripts source from GIT.
tunctl.tar.gz (1.2 KiB)
initscripts_network_add_tun_t... (1.4 KiB)
Actually there is even a copy of this tunctl command in the vde package too, it's called vde_tunctl, but I would prefer a separate package, as Lisa did.
Will we see this released?
so, if we could provide a package for it and some "intelligence" into netcfg to manage a tun/tap interface, then using netcfg would be fine for me (I'd also expect to see the tunctl package set as dependency for netcfg)
if the suggestion is instead to use netcfg with some custom commands for the interface initialization and to install manually the tunctl command from an external source, then having netcfg installed would just force me to also install a bunch of other unneeded packages, the I won't use netcfg for it
I'm a bit hesitant to add this to initscripts, would it be possible to create a small "daemon" (script) that could be pakaged together with tunctl which would read a config file and set up / tear down the tuntap devices? Or is there a reason why this should be integrated with the initscripts/netcfg?
btw yes, having tunctl packaged would be a first step and I would be more than happy to maintain it if needed
a "daemon" bundled with the package that creates/deletes the tun/tap interfaces at startup would allow us to configure them via the standard INTERFACES parameter of rc.conf; that looks to me better than forcing the ysers to install netcfg
* ip tuntap add dev $NAME mode tap user $USER
* ip tuntap del dev $NAME mode tap
$ ip tuntap help
Usage: ip tuntap { add | del } [ dev PHYS_DEV ]
[ mode { tun | tap } ] [ user USER ] [ group GROUP ]
[ one_queue ] [ pi ] [ vnet_hdr ]
Where: USER := { STRING | NUMBER }
GROUP := { STRING | NUMBER }
2) I hope I said this already, but this belongs in netcfg, not in initscripts.
1) It doesn't abstract the tunctl stuff, but uses its exact syntax. We did this with ifconfig in rc.conf and are now unable to properly switch to /sbin/ip. We should rather have the possibility to specify a tap interface and a user who owns it and build the command ourselves.
2) If we do this, we should split tunctl from uml_utilities. In fact, uml_utilities is completely worthless (UML doesn't even work from what I see) and the only reason to install it is because you want tunctl. And people always try pacman -S tunctl, nobody even has the idea of looking into uml_utilities.
Like you, I'd like to see rc.conf to switch from ifconfig to ip and, if I understand correctly, you would prefer to manage the tap interfaces with 'ip' too, instead of having a special "tunctl" package.
We could then manage the tap interfaces from rc.conf, without having to install netcfg.
So, would it be via a special "tunctl" package or via the standard "iproute2" package, I think that the management of tap interfaces should be left against the initscripts, not netcfg.
In conclusion: tun/tap should be handled by netcfg.
Maybe someone who knows better could clarify?
I do set the ip address on a tap interface using the standard ifconfig/ip commands and after it's created I plug it into a VDE switch where also a number of QEMU network interfaces are plugged.
One of the reasons why I do this is that VDE can build a virtual switch across different physical hosts; this provides me the capability of spawning a VM on different hosts having it always connected to the same virtual network.