Bug#182020: openvpn needs dynamic choice on HAVE_LINUX_IF_TUN_H
Hi all,
Sorry for the delay forwarding this email, but I don't find time to breath lately (and thus Oxygen does not make it to my brain :)
Hope it's an easy one.
----- Forwarded message from Robert de Bath <[email protected]> -----
From: Robert de Bath <[email protected]>
Reply-To: Robert de Bath <[email protected]>, [email protected]...
To: [email protected]...
Subject: Bug#182020: openvpn needs dynamic choice on HAVE_LINUX_IF_TUN_H
Date: Sat, 22 Feb 2003 11:03:19 +0000 (GMT)
X-URL: <http://www.cix.co.uk/~mayday>
X-Dev86-Version: 0.16.10
Reply-By: 01 jan 2001 00:00:00
X-Message-Flag: Linux: The choice of a GNU generation.
Return-Receipt-To: [email protected]...
X-Spam-Level:
X-SpamProbe: GOOD 0.0000000 f10cd08f2b096e6bf59bcfea5e2f80a4
X-Spam-Status: No, hits=-4.5 required=5.0 tests=SENT_BY_BTS,FORGED_RCVD_FOUND version=2.20 X-Spam-Level:
Package: openvpn
Version: 1.3.0-2
When compiled with 2.4.* kernel headers (libc6-dev 2.2.5-14.3 headers) it detects this header file and defines HAVE_LINUX_IF_TUN_H. This allow openvpn to work correctly with 2.4.18 kernels BUT it stops it working with 2.2.X kernels at all (with or without the tun kernel module from sourceforge)
Options are:
1) Seperate compiles for 2.2.X and 2.4+ kernels, both binaries in the .deb
2) Patch tun.c to first check if /dev/net/tun exists and works before falling back to the open_tun_generic(..) function if it doesn't.
I'm currently successfully using openvpn between a 2.2.19 and 2.4.18 kernel using the tun0 tunnel and the driver from sourceforge on the 2.2.19 machine. (No reboot required to install the tun0 driver) The 2.4.18 openvpn is standard, the 2.2.19 has HAVE_LINUX_IF_TUN_H undefined.
Both machines are woody with libc6/testing.
Signature · 13 lines
Rob. (Robert de Bath <robert$ @ debath.co.uk>)
<http://www.cix.co.uk/~mayday>
Google Homepage: http://www.google.com/search?btnI&q=Robert+de+Bath
----- End forwarded message -----
--
Alberto Gonzalez Iniesta | BOFH excuse #2:
agi@(agi.as|debian.org) | solar flares
Encrypted mail preferred |
Key fingerprint = 9782 04E7 2B75 405C F5E9 0C81 C514 AF8E 4BA4 01C3Quoted 10 lines · Alberto Gonzalez Iniesta
Hi all,
Sorry for the delay forwarding this email, but I don't find time to breath lately (and thus Oxygen does not make it to my brain :)
Hope it's an easy one.
----- Forwarded message from Robert de Bath <[email protected]> -----
Quoted 13 lines
From: Robert de Bath <[email protected]>
Reply-To: Robert de Bath <[email protected]>, [email protected]...
To: [email protected]...
Subject: Bug#182020: openvpn needs dynamic choice onHAVE_LINUX_IF_TUN_H
Date: Sat, 22 Feb 2003 11:03:19 +0000 (GMT)
X-URL: <http://www.cix.co.uk/~mayday>
X-Dev86-Version: 0.16.10
Reply-By: 01 jan 2001 00:00:00
X-Message-Flag: Linux: The choice of a GNU generation.
Return-Receipt-To: [email protected]...
X-Spam-Level:
X-SpamProbe: GOOD 0.0000000f10cd08f2b096e6bf59bcfea5e2f80a4
X-Spam-Status: No, hits=-4.5 required=5.0
tests=SENT_BY_BTS,FORGED_RCVD_FOUND version=2.20
Quoted 10 lines
X-Spam-Level:
Package: openvpn
Version: 1.3.0-2When compiled with 2.4.* kernel headers (libc6-dev 2.2.5-14.3 headers) it detects this header file and defines
HAVE_LINUX_IF_TUN_H. This allow openvpn to work correctly with 2.4.18 kernels BUT it stops it working with 2.2.X kernels at all (with or without the tun kernel module from sourceforge)
OpenVPN's config script assumes that if 2.4 headers are present (i.e. if_tun.h), then it should build for the 2.4 tun/tap driver.
I don't completely understand why one would want to put 2.4 kernel headers on a 2.2 machine, since that would tend to confuse things, and break apps that depend on the userspace <-> kernel interface as defined by the kernel header files.
But in any case, you can still build if you do the following.
(1) run ./configure
(2) edit config.h
(3) comment out this line: #define HAVE_LINUX_IF_TUN_H 1
(4) run make
This could be automatic if ./configure did a kernel version test, and only defined HAVE_LINUX_IF_TUN_H if (a) if_tun.h exists and (b) kernel version is 2.4.x.
James
Quoted 40 lines
Options are:
1) Seperate compiles for 2.2.X and 2.4+ kernels, both binaries in the .deb
2) Patch
tun.cto first check if/dev/net/tunexists and works before falling back to theopen_tun_generic(..)function if it doesn't.I'm currently successfully using openvpn between a 2.2.19 and 2.4.18 kernel using the tun0 tunnel and the driver from sourceforge on the 2.2.19 machine. (No reboot required to install the tun0 driver) The 2.4.18 openvpn is standard, the 2.2.19 has
HAVE_LINUX_IF_TUN_Hundefined.Both machines are woody with libc6/testing.
Signature · 24 lines
Rob. (Robert de Bath <robert$ @ debath.co.uk>) <http://www.cix.co.uk/~mayday> Google Homepage: http://www.google.com/search?btnI&q=Robert+de+Bath ----- End forwarded message ----- -- Alberto Gonzalez Iniesta | BOFH excuse #2: agi@(agi.as|debian.org) | solar flares Encrypted mail preferred | Key fingerprint = 9782 04E7 2B75 405C F5E9 0C81 C514 AF8E 4BA4 01C3 ------------------------------------------------------- Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara The only event dedicated to issues related to Linux enterprise solutions www.enterpriselinuxforum.com _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 8 lines · James Yonan
Quoted 5 lines · Alberto Gonzalez Iniesta
When compiled with 2.4.* kernel headers (libc6-dev 2.2.5-14.3 headers) it detects this header file and defines
HAVE_LINUX_IF_TUN_H. This allow openvpn to work correctly with 2.4.18 kernels BUT it stops it working with 2.2.X kernels at all (with or without the tun kernel module from sourceforge)
Quoted 7 lines
OpenVPN's config script assumes that if 2.4 headers are present (i.e.
if_tun.h), then it should build for the 2.4 tun/tap driver.I don't completely understand why one would want to put 2.4 kernel headers on a 2.2 machine, since that would tend to confuse things, and break apps that depend on the userspace <-> kernel interface as defined by the kernel header files.
The problem (again) is distributing binaries. I compile Debian's packages in my 2.4.x box, but those packages may be used in 2.2 boxes. I could find a 2.2 box (could I?) to compile them, but then the problem would be the other way around, wouldn't it?
So, and as the bug reported says, we have two choices:
a) I make two binaries in the package, and choose at installation time which one should be used. (will uname -r do? I guess so)
b) openvpn detects at run time which tun interface to use.
pros? cons?
Regards,
Alberto
Quoted 27 lines
But in any case, you can still build if you do the following.
(1) run ./configure
(2) editconfig.h
(3) comment out this line: #defineHAVE_LINUX_IF_TUN_H1
(4) run makeThis could be automatic if ./configure did a kernel version test, and only defined
HAVE_LINUX_IF_TUN_Hif (a)if_tun.hexists and (b) kernel version is 2.4.x.James
Quoted 14 lines
Options are:
1) Seperate compiles for 2.2.X and 2.4+ kernels, both binaries in the .deb
2) Patch
tun.cto first check if/dev/net/tunexists and works before falling back to theopen_tun_generic(..)function if it doesn't.I'm currently successfully using openvpn between a 2.2.19 and 2.4.18 kernel using the tun0 tunnel and the driver from sourceforge on the 2.2.19 machine. (No reboot required to install the tun0 driver) The 2.4.18 openvpn is standard, the 2.2.19 has
HAVE_LINUX_IF_TUN_Hundefined.Both machines are woody with libc6/testing.
Signature · 5 lines
Alberto Gonzalez Iniesta | BOFH excuse #99: agi@(agi.as|debian.org) | SIMM crosstalk. Encrypted mail preferred | Key fingerprint = 9782 04E7 2B75 405C F5E9 0C81 C514 AF8E 4BA4 01C3
Quoted 2 lines · James Yonan
OpenVPN's config script assumes that if 2.4 headers are present (i.e.
if_tun.h), then it should build for the 2.4 tun/tap driver.
This may not be true for build hosts of a distributor, who needs the most conservative code if he's still shipping 2.2 kernels (as Debian).
Quoted 4 lines
I don't completely understand why one would want to put 2.4 kernel headers on a 2.2 machine, since that would tend to confuse things, and break apps that depend on the userspace <-> kernel interface as defined by the kernel header files.
Think "binary package": built on a 2.4 machine, installed onto a different 2.2 machine.
Quoted 7 lines · Matthias Andree
Quoted 2 lines · James Yonan
OpenVPN's config script assumes that if 2.4 headers are present (i.e.
if_tun.h), then it should build for the 2.4 tun/tap driver.This may not be true for build hosts of a distributor, who needs the most conservative code if he's still shipping 2.2 kernels (as Debian).
The problem is that the code that opens the tun/tap device is different for 2.2 and 2.4. In 2.2 you open /dev/tunX where X is the unit number. In 2.4 you open /dev/net/tun and then use the TUNSETIFF ioctl.
One thing that has been done already to ease binary compatibility is that the failure of the TUNSETIFF ioctl is now non-fatal.
But more work may be required, perhaps even an explicit configure flag to build a binary that will build on 2.4 but work on either 2.2 or 2.4, or perhaps a run-time check that retries the open with 2.2 code if the TUNSETIFF ioctl fails (as was suggested in the Debian bug report).
Quoted 7 lines
Quoted 4 lines
I don't completely understand why one would want to put 2.4 kernel headers on a 2.2 machine, since that would tend to confuse things, and break apps that depend on the userspace <-> kernel interface as defined by the kernel header files.
Think "binary package": built on a 2.4 machine, installed onto a different 2.2 machine.
Right, but I think the reliance on the auto* tools creates some problems. While these tools are great for learning the capability of the target platform at build time by analyzing source and header files, and attempting lots of test compiles, the model breaks down when you try to move from source portability to binary portability, because that requires that many of the "learning the capability of the target platform" tests be performed at run time rather than build time.
James
Alberto,
Here is a patch against 1.4.0 that tries the 2.4 TUN/TAP interface then falls back to 2.2 if it fails. I don't have access to a 2.2 machine so I have not been able to test. Let me know if it works.
James
Quoted 28 lines · Alberto Gonzalez Iniesta
Quoted 8 lines · James Yonan
Quoted 5 lines · Alberto Gonzalez Iniesta
When compiled with 2.4.* kernel headers (libc6-dev 2.2.5-14.3 headers) it detects this header file and defines
HAVE_LINUX_IF_TUN_H. This allow openvpn to work correctly with 2.4.18 kernels BUT it stops it working with 2.2.X kernels at all (with or without the tun kernel module from sourceforge)Quoted 7 lines
OpenVPN's config script assumes that if 2.4 headers are present (i.e.
if_tun.h), then it should build for the 2.4 tun/tap driver.I don't completely understand why one would want to put 2.4 kernel headers on a 2.2 machine, since that would tend to confuse things, and break apps that depend on the userspace <-> kernel interface as defined by the kernel header files.
The problem (again) is distributing binaries. I compile Debian's packages in my 2.4.x box, but those packages may be used in 2.2 boxes. I could find a 2.2 box (could I?) to compile them, but then the problem would be the other way around, wouldn't it?
So, and as the bug reported says, we have two choices:
a) I make two binaries in the package, and choose at installation time which one should be used. (will uname -r do? I guess so)
b) openvpn detects at run time which tun interface to use.
Quoted 26 lines
pros? cons?
Regards,
Alberto
Quoted 19 lines
But in any case, you can still build if you do the following.
(1) run ./configure
(2) editconfig.h
(3) comment out this line: #defineHAVE_LINUX_IF_TUN_H1
(4) run makeThis could be automatic if ./configure did a kernel version test, and only defined
HAVE_LINUX_IF_TUN_Hif (a)if_tun.hexists and (b) kernel version is 2.4.x.James
Quoted 6 lines
Options are:
1) Seperate compiles for 2.2.X and 2.4+ kernels, both binaries in the .deb
2) Patch
tun.cto first check if/dev/net/tunexists and works before falling back to theopen_tun_generic(..)function if it doesn't.
Here is a patch against 1.4.0 that does this (attached). I don't have access to a 2.2 machine so I have not been able to test.
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
I'm currently successfully using openvpn between a 2.2.19 and 2.4.18 kernel using the tun0 tunnel and the driver from sourceforge on the 2.2.19 machine. (No reboot required to install the tun0 driver) The 2.4.18 openvpn is standard, the 2.2.19 has
HAVE_LINUX_IF_TUN_Hundefined.Both machines are woody with libc6/testing.
tun.c +18 -5
@@ -375,10 +375,14 @@ }else { -if (!dev_node) - dev_node ="/dev/net/tun" ; -if ((tt->fd =open (dev_node,O_RDWR )) <0 ) -msg (M_ERR ,"Cannot open TUN/TAP dev %s" , dev_node); +const char *node = dev_node; +if (!node) + node ="/dev/net/tun" ; +if ((tt->fd =open (node,O_RDWR )) <0 ) + { +msg (M_WARN |M_ERRNO ,"Note: Cannot open TUN/TAP dev %s" , node); + goto linux_2_2_fallback; + }CLEAR (ifr);if (!tt->ipv6)
@@ -401,7 +405,10 @@strncpynt (ifr.ifr_name, dev,IFNAMSIZ );if (ioctl (tt->fd,TUNSETIFF , (void *) &ifr) <0 ) -msg (M_WARN ,"Cannot ioctl TUNSETIFF %s" , dev); + { +msg (M_WARN |M_ERRNO ,"Note: Cannot ioctl TUNSETIFF %s" , dev); + goto linux_2_2_fallback; + }set_nonblock (tt->fd);set_cloexec (tt->fd);
@@ -433,6 +440,12 @@ } } } +return ; + + linux_2_2_fallback: +msg (M_INFO ,"Note: Attempting fallback to kernel 2.2 TUN/TAP interface" ); +close_tun_generic (tt); +open_tun_generic (dev, dev_node, dev_name, ipv6, false, true, tt); }#else