Urgent: Limitation to 100 virtual tunnel devices??
We are running into trouble with more than 100 virtual tunnel devices . The reported problem is as follows:
Reported Failure in /var/log/syslog
Jul 1 06:30:19 1100PRVC001 openvpn[15520]: OpenVPN 1.5.0 i386-rpm-linux [SSL] [LZO] [PTHREAD] built on Mar 4 2004 Jul 1 06:30:19 1100PRVC001 openvpn[15520]: Note: Cannot ioctl TUNSETIFF tun: Too many open files in system (errno=23) Jul 1 06:30:19 1100PRVC001 openvpn[15520]: Note: Attempting fallback to kernel 2.2 TUN/TAP interface Jul 1 06:30:19 1100PRVC001 openvpn[15520]: Cannot allocate TUN/TAP dev dynamically Jul 1 06:30:19 1100PRVC001 openvpn[15520]: Exiting
max file-handles ist set to 16384
You can reproduce the failure by starting openvpn with:
openvpn --dev-node /dev/net/tun --port 5000& openvpn --dev-node /dev/net/tun --port 5001& openvpn --dev-node /dev/net/tun --port 5002&
....
....
openvpn --dev-node /dev/net/tun --port 5099& openvpn --dev-node /dev/net/tun --port 5100&
Distribution ist Debian Woody 3.0 r2 (Kernel 2.4.18)
openvpn 1.5.0-2 (rpm-Package, converted via alien to
deb-package)
Is there any known Limitation to 100 TUN-Devices or how can we break that limitation?
Thanks
Jürg von Büren
IT Systeme
AMAG Automobil- und Motoren AG, Informatik, Dällikerstr. 34, CH-8107 Buchs [email protected]...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 2 lines · On Thursday 01 July 2004 18:18, [email protected]... wrote:
Is there any known Limitation to 100 TUN-Devices or how can we break that limitation?
This is a limitation in the Linux kernel code not in OpenVPN.
The limitation is in net/core/dev.c
You can change this by modifying the value and kernel recompile.
See in net/core/dev.c:
- --------------
/*
* If you need over 100 please also fix the algorithm...
*/
for (i = 0; i < 100; i++) {
snprintf(buf,sizeof(buf),name,i);
if (__dev_get_by_name(buf) == NULL) {
strcpy(dev->name, buf);
return i;
}
}
return -ENFILE; /* Over 100 of the things .. bail out! */
}- --------------
Note that performance will be bad when going beyond about 200 or 300 devices on a modern pc.
It is better to replace the code by a hashed device lookup. I found out that this is the case in my debian 2.6. kernel. I haven't checked when this was introduced and whether this is a debian patch or present in the vanilla kernel code.
I can send you a patch by mail for the 2.4.26 kernel which also should apply back to 2.4.18 or lower. This was written by Ben Greer for VLAN support and I modified it to apply cleanly to 2.4.18 and higher. Linus rejected this patch for the 2.4 series. It works for me on more than 30 servers without any problems.
A linux distro including this patch is Adamantix (www.adamantix.org)
Torge
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFA5EPSosmtDiD9dbIRAt/uAJ9gI/O6SQX4+XLmJcPtut/KNQEoewCaAlJt UR6wuo9p1IFCUakA1coyLA4=
=eOGl
-----END PGP SIGNATURE-----
Quoted 3 lines · --Am Donnerstag, 1. Juli 2004 17:18 +0100 [email protected]... schrieb:
We are running into trouble with more than 100 virtual tunnel devices . The reported problem is as follows:
Jul 1 06:30:19 1100PRVC001 openvpn[15520]: Note: Cannot ioctl TUNSETIFF
I assume you need the following patch:
net/core/dev.c +0 -0
@@ -619,8 +619,12 @@
/* * If you need over 100 please also fix the algorithm...
+ *
+ * Maybe it's never needed but just to be sure we allow
+ * up to 1000 tun/tap devices.
+ *
*/
- for (i = 0; i < 100; i++) {
+ for (i = 0; i < 1000; i++) {
snprintf(buf,sizeof(buf),name,i);
if (__dev_get_by_name(buf) == NULL) {
strcpy(dev->name, buf);Signature · 2 lines
Claas Hilbrecht http://www.jucs-kramkiste.de
Is this only specific to Linux?
how about others using BSD systems?
sam
Quoted 29 lines · Claas Hilbrecht
--Am Donnerstag, 1. Juli 2004 17:18 +0100 [email protected]...
Quoted 3 lines · schrieb:
We are running into trouble with more than 100 virtual tunnel devices . The reported problem is as follows:
Jul 1 06:30:19 1100PRVC001 openvpn[15520]: Note: Cannot ioctl TUNSETIFFI assume you need the following patch:
diff -urN
linux-2.4.26.org/net/core/dev.clinux-2.4.26/net/core/dev.cnet/core/dev.c Thu Apr 15 18:54:01 2004 renamed from net/core/dev.c Wed Apr 14 15:05:41 2004 +5
-1@@ -619,8 +619,12 @@ /* * If you need over 100 please also fix the algorithm... + * + * Maybe it's never needed but just to be sure we allow + * up to 1000 tun/tap devices. + * */ - for (i = 0; i < 100; i++) { + for (i = 0; i < 1000; i++) { snprintf(buf,sizeof(buf),name,i); if (__dev_get_by_name(buf) == NULL) { strcpy(dev->name, buf);
Quoted 6 lines · sam
Is this only specific to Linux?
how about others using BSD systems?
samClaas Hilbrecht wrote:
I just looked at the code in FreeBSD 5 CURRENT, it handles 1000 tunnel by default:
case MOD_LOAD:
/* intitialize device */
mtx_init(&tapmtx, "tapmtx", NULL, MTX_DEF);
SLIST_INIT(&taphead);
clone_setup(&tapclones);
eh_tag = EVENTHANDLER_REGISTER(dev_clone, tapclone, 0,
1000);
if (eh_tag == NULL) {
clone_cleanup(&tapclones);
mtx_destroy(&tapmtx);
return (ENOMEM);
}
return (0);Sit back and relax. :)
sam
Quoted 32 lines
Quoted 30 lines
--Am Donnerstag, 1. Juli 2004 17:18 +0100 [email protected]...
Quoted 3 lines · schrieb:
We are running into trouble with more than 100 virtual tunnel devices . The reported problem is as follows:
Jul 1 06:30:19 1100PRVC001 openvpn[15520]: Note: Cannot ioctl TUNSETIFFI assume you need the following patch:
diff -urN
linux-2.4.26.org/net/core/dev.clinux-2.4.26/net/core/dev.cnet/core/dev.c Thu Apr 15 18:54:01 2004 renamed from net/core/dev.c Wed Apr 14 15:05:41 2004 +5
-1@@ -619,8 +619,12 @@ /* * If you need over 100 please also fix the algorithm... + * + * Maybe it's never needed but just to be sure we allow + * up to 1000 tun/tap devices. + * */ - for (i = 0; i < 100; i++) { + for (i = 0; i < 1000; i++) { snprintf(buf,sizeof(buf),name,i); if (__dev_get_by_name(buf) == NULL) { strcpy(dev->name, buf);