Skip to contentSkip to conversation

make ipv6_payload compile under windowze ( feat_ipv6_payload branch )

PATCH Gert Doering 7 participants 13 messages Feb 21, 2010 – Mar 8, 2010 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi,

Quoted 2 lines · JuanJo Ciarlante?

This patch makes ipv6_payload successfully cross *compile* (and just that :) under my mingw32msvc setup on Linux.

Oh, cool! Thanks a lot for that.

I'll try to figure out how to setup a cross-compile environment during next week, and then I'll try to figure out how to get the IPv6 ifconfig & IPv6 route stuff done (if nothing else helps, run "netsh" commands to do the work...).

Quoted 3 lines

Because same syshead.h changes are already included in feat_ipv6_transport, it may merge-conflict applying it over allmerged once the latter includes ipv6_transport.

Shouldn't git sort this out, if it's exactly the same change?

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#2 lore raw
Quoted 2 lines · Gert Doering

I'll try to figure out how to setup a cross-compile environment during next week,

Some Linux distributions have premade mingw packages.

In Gentoo building a toolchain for mingw is as simple as:

emerge crossdev && crossdev -t i686-mingw32

On other distributions you might benefit from Dan Kegel's crosstool:

http://kegel.com/crosstool/

Then run ./configure --host=i686-mingw32 && make in the OpenVPN source tree to build using the cross-toolchain.

//Peter

#3 lore raw

Hi,

Quoted 8 lines · Peter Stuge
Quoted 2 lines · Gert Doering

I'll try to figure out how to setup a cross-compile environment during next week,

Some Linux distributions have premade mingw packages.

In Gentoo building a toolchain for mingw is as simple as:

Quoted 8 lines

emerge crossdev && crossdev -t i686-mingw32

On other distributions you might benefit from Dan Kegel's crosstool:

http://kegel.com/crosstool/

Then run ./configure --host=i686-mingw32 && make in the OpenVPN source tree to build using the cross-toolchain.

Thanks for that. I was googling in parallel, and that's exactly what is going on in the background here right now (crossdev building the mingw environment) :-)

I saw a note here on the list a few weeks ago pointing to the opensc "build" tool, and I'll try that, as soon as the cross-tools are done.

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#12 lore raw
In reply to a message not in the archive
Quoted 10 lines · JuanJo Ciarlante☀

This patch makes ipv6_payload successfully cross *compile* (and just that :) under my mingw32msvc setup on Linux.

Because same syshead.h changes are already included in feat_ipv6_transport, it may merge-conflict applying it over allmerged once the latter includes ipv6_transport.

Patch follows
(also at http://github.com/jjo/openvpn-ipv6/commit/b7e46bd5ebfd4b55146299129e8b9813fab91b5e
):

Thank you very much, applied to my gert-ipv6 branch (at least I hope so).

David, please pull gert-ipv6 from git://git.birkenwald.de/openvpn.git to receive that change.

Bernhard

#13 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 13 lines · Bernhard Schmidt
Quoted 10 lines · JuanJo Ciarlante☀

This patch makes ipv6_payload successfully cross *compile* (and just that :) under my mingw32msvc setup on Linux.

Because same syshead.h changes are already included in feat_ipv6_transport, it may merge-conflict applying it over allmerged once the latter includes ipv6_transport.

Patch follows
(also at http://github.com/jjo/openvpn-ipv6/commit/b7e46bd5ebfd4b55146299129e8b9813fab91b5e
):

Quoted 6 lines

Thank you very much, applied to my gert-ipv6 branch (at least I hope so).

David, please pull gert-ipv6 from git://git.birkenwald.de/openvpn.git to receive that change.

Pulled and merged into allmerged

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkuCRuoACgkQDC186MBRfrpKlACeIz+74E4sESJbB13DqjVSZg7X WBIAoK2JYgnThZsoHNgG5VG56y89paDf
=2290
-----END PGP SIGNATURE-----

#4 lore raw
In reply to Gert Doering

Hi,

to follow up on this...

Quoted 10 lines · Gert Doering
Quoted 9 lines · Peter Stuge
Quoted 2 lines · Gert Doering

I'll try to figure out how to setup a cross-compile environment during next week,

Some Linux distributions have premade mingw packages.

In Gentoo building a toolchain for mingw is as simple as:

emerge crossdev && crossdev -t i686-mingw32

[..]

Quoted 7 lines

Thanks for that. I was googling in parallel, and that's exactly what is going on in the background here right now (crossdev building the mingw environment) :-)

I saw a note here on the list a few weeks ago pointing to the opensc "build" tool, and I'll try that, as soon as the cross-tools are done.

I have been able to successfully build OpenVPN.exe from Linux, using the crossdev-provided "i586-mingw32msvc" environment. The resulting binary is compatible with the openvpn-gui from the "official" installer, as long as I install my cross-compiled .DLLs as well as openvpn.exe - the "shipped" DLLs don't work, but that's not really a problem right now.

My largest problem right now is that the tun/tap driver does not support IPv6 if in "tun" mode - the code is quite explicit about it...

tap-win32/tapdrvr.c, line 1568:

    //===============================================
    // In Point-To-Point mode, check to see whether
    // packet is ARP or IPv4 (if neither, then drop).
    //===============================================

(there's good reasons for what it does)

Now... is there someone who has worked on this before, and can help me a bit with it?

Initial questions:

- can it be cross-compiled? If yes, how? If no, what needs to be done on Windows to compile it? (I have *no* experience with Windows, but I can follow instructions and read documentation).

- what needs to be done to install the driver / replace the existing driver?

- how does one debug Windows drivers? Is there a printf() as in Linux that goes to console / syslog?

gert

PS: ifconfig + route work fine, and receiving packets also works (verified with wireshark). Just sending win->tun->openvpn doesn't

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#5 lore raw

Re: [Openvpn-devel] [PATCH] IPv6 support for TUN/TAP driver on windows

Hi,

Quoted 1 line · Gert Doering

to follow up on this...

Next round of "do things on windows" :-)

Quoted 10 lines

[ TUN / TAP driver on windows ]

Now... is there someone who has worked on this before, and can help me a bit with it?

Initial questions:

- can it be cross-compiled? If yes, how? If no, what needs to be done on Windows to compile it? (I have *no* experience with Windows, but I can follow instructions and read documentation).

It does not seem to be possible to cross-compile this.

For the archives:

Fairly detailed instructions how to compile on windows are contained in "domake-win" in the OpenVPN distribution - unfortunately, this is lacking some of the important details, like "what to do if Microsoft is not willing to ship WDK 6001* anymore, but you need to adjust to 7.1.0" or "don't even try to build this from a drive that is not C:".

Anyway:

- get MinGW and MSYS
- get the Windows Driver Kit (WDK) from Microsoft
- put everything on C:, not on different drive letters(!!)
- follow the instructions in domake-win
- adjust install-win32/settings.in if you use a different WDK version
- adjust install-win32/maketap, "w2ktarget=..." for current WDK versions
- build, pray, curse, fix scripts, ...

So far, I have been successful in building the tap driver, and ignored all the rest. I will give this another fight on a machine with enough disk space on C: next week.

Quoted 2 lines

- what needs to be done to install the driver / replace the existing driver?

If you have OpenVPN installed in the normal location, just copy the driver sources (tap0901.sys, tap0901.cap, OemWin2k.inf) to C:\...\openvpn\driver and run "deltapall.bat" and "addtap.bat" from ...\openvpn\bin.

Make sure OpenVPN isn't active while replacing the driver, because you might end up using the driver that's still in memory.

Quoted 2 lines

- how does one debug Windows drivers? Is there a printf() as in Linux that goes to console / syslog?

I have not yet figured out that part. I did my debugging with Wireshark ("see what packets move back and forth and stare at the packet details").

Attached below is the patch to the TUN/TAP driver that is required to make OpenVPN work with IPv6 in TUN mode on windows. The magic for IPv6 is modelled similar to the way ARP is handled for IPv4:

- all routes are set up with a next-hop of fe80::8
- if the tapdrvr notices a neighbor-discovery packet for fe80::8, it will grab the packet and synthesize a neighbor-advertisement response
- windows is happy and sends the data packets to the tap driver :-)

(The patch is 175e17a5abd5969f6803a9cc9587b7959e1100ae in my git tree
- David, could you please git-pull to feat_ipv6_payload?)

What needs to happen next?

- "someone who understands" needs to look at the diff, and ACK it (or tell me where i misunderstood things, and what to fix)

- it whould be highly appreciated if Samuli could get OpenVPN Tech to provide Windows binaries for the "openvpn-testing" tree, so that we can get decent testing by the windows user base

- if someone is willing to risk the stability of his system, you can test my binaries:

    http://www.greenie.net/ipv6/tap0901-ipv6-20100307.tar.gz
    http://www.greenie.net/ipv6/openvpn-win-ipv6-20100307.tgz

(extract in ...\openvpn\driver and ...\openvpn\bin, respectively, then run deltapall.bat / addtap.bat)

DO NOT DO THIS ON A PRODUCTION SYSTEM. Really. This has been tested on two different Windows XP systems, and no adverse effects have been observed - but this is my first attemt at Windows driver programming, and I would not trust that yet.

gert

install-win32/settings.in +2 -2
index 643ef99..202f782 100644
@@ -42,8 +42,8 @@
 !define PRODUCT_TAP_DEVICE_DESCRIPTION  "TAP-Win32 Adapter V9"
 !define PRODUCT_TAP_PROVIDER            "TAP-Win32 Provider V9"
 !define PRODUCT_TAP_MAJOR_VER           9
-!define PRODUCT_TAP_MINOR_VER           6
-!define PRODUCT_TAP_RELDATE             "06/22/2009"
+!define PRODUCT_TAP_MINOR_VER           7
+!define PRODUCT_TAP_RELDATE             "07/03/2010"
 
 # TAP adapter icon -- visible=0x81 or hidden=0x89
 !define PRODUCT_TAP_CHARACTERISTICS     0x81
tap-win32/proto.h +60 -0

79 lines not on this page · raw message

tap-win32/tapdrvr.c +193 -4

248 lines not on this page · raw message

tap-win32/types.h +1 -0
index 48bdff7..312fe92 100755
@@ -143,6 +143,7 @@ typedef struct _TapAdapter
   IPADDR m_remoteNetmask;
   ETH_HEADER m_TapToUser;
   ETH_HEADER m_UserToTap;
+  ETH_HEADER m_UserToTap_IPv6;		// same as UserToTap but proto=ipv6
   MACADDR m_MAC_Broadcast;
 
   // Used for DHCP server masquerade
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#6 lore raw

Re: [Openvpn-devel] [PATCH] IPv6 support for TUN/TAP driver on windows

Quoted 2 lines · Gert Doering

-!define PRODUCT_TAP_RELDATE "06/22/2009"
+!define PRODUCT_TAP_RELDATE "07/03/2010"

Seems month/date are swapped.

//Peter

#7 lore raw

Re: [Openvpn-devel] [PATCH] IPv6 support for TUN/TAP driver on windows

Hi,

Quoted 5 lines · Peter Stuge
Quoted 2 lines · Gert Doering

-!define PRODUCT_TAP_RELDATE "06/22/2009"
+!define PRODUCT_TAP_RELDATE "07/03/2010"

Seems month/date are swapped.

Stupid american date formats. In my build tree, this is actually correct, but the commit was done on the unix host.

Thanks for pointing this out - change to "03/07/2010" committed.

(Not that *this* would really matter, as I assume that OpenVPN Tech is going to keep their hand on defining release dates and driver versions :-) ).

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#8 lore raw

Re: [Openvpn-devel] [PATCH] IPv6 support for TUN/TAP driver on windows

In reply to Gert Doering
Quoted 7 lines

What needs to happen next?

- it whould be highly appreciated if Samuli could get OpenVPN Tech to provide Windows binaries for the "openvpn-testing" tree, so that we can get decent testing by the windows user base

I'm on it. If this issue is not clear by Thursday, we should discuss it in the meeting.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
#9 lore raw

Re: [Openvpn-devel] [PATCH] IPv6 support for TUN/TAP driver on windows

Quoted 11 lines · Samuli Seppänen
Quoted 5 lines

What needs to happen next?

- it whould be highly appreciated if Samuli could get OpenVPN Tech to provide Windows binaries for the "openvpn-testing" tree, so

that

Quoted 2 lines

we can get decent testing by the windows user base

I'm on it. If this issue is not clear by Thursday, we should discuss it
in the meeting.

FYI I have submitted a patch that's related.

My patch produces OpenVPN windows binaries
as part of the build process but have not yet received feedback as to whether the project would release such binaries.

Unpackged Windows binaries? -- Problems building 2.1 rc15 on Windows XP
http://article.gmane.org/gmane.network.openvpn.devel/3171
http://thread.gmane.org/gmane.network.openvpn.devel/2566/focus=3171

Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

#10 lore raw

Re: [Openvpn-devel] [PATCH] IPv6 support for TUN/TAP driver on windows

In reply to Gert Doering
Quoted 5 lines
Quoted 2 lines

- how does one debug Windows drivers? Is there a printf() as in Linux that goes to console / syslog?

I have not yet figured out that part. I did my debugging with Wireshark ("see what packets move back and forth and stare at the packet details").

While Windows doesn't support "printf" in device drivers, the TAP driver defines the DEBUGP macro that tries to do the same thing.

First, build a debug version of the driver. This can be done by editing install-win32/settings.in (the domake-win configuration file) and uncommenting out this line:

;!define PRODUCT_TAP_DEBUG

If you look at the source code to the driver, you will see lots of DEBUGP macro references. This is how you want to code your debugging printfs.

Next, there are two possible ways to view the debugging output:

Get the WinDBG tool from MS. All of the DEBUGP calls will output log info in a form that can be received by WinDBG.

Use a special feature of OpenVPN on Windows that allows it to get the DEBUGP messages directly from the TAP driver and output them along with the normal OpenVPN log output. This feature is enabled at --verb level 6 and is internally referred to as D_TAP_WIN32_DEBUG in errlevel.h.

The disadvantage of the D_TAP_WIN32_DEBUG method is that it's only available after OpenVPN has successfully bound to a TAP adapter. For example, if there's an error on initial driver loading that precludes OpenVPN from opening the TAP device, then only WinDBG would be able to show the DEBUGP output from such a condition.

James

#11 lore raw

Re: [Openvpn-devel] [PATCH] IPv6 support for TUN/TAP driver on windows

Hi,

Quoted 5 lines · James Yonan
Quoted 2 lines

I have not yet figured out that part. I did my debugging with Wireshark ("see what packets move back and forth and stare at the packet details").

While Windows doesn't support "printf" in device drivers, the TAP driver defines the DEBUGP macro that tries to do the same thing.

I've seen these, but was missing the next steps - "how do I get to read these messages".

[..]

Quoted 4 lines

Next, there are two possible ways to view the debugging output:

Get the WinDBG tool from MS. All of the DEBUGP calls will output log info in a form that can be received by WinDBG.

Will check that. There are "some debuggers" as part of the WDK, but I have not yet looked into these in more detail.

Quoted 4 lines

Use a special feature of OpenVPN on Windows that allows it to get the DEBUGP messages directly from the TAP driver and output them along with the normal OpenVPN log output. This feature is enabled at --verb level 6 and is internally referred to as D_TAP_WIN32_DEBUG in errlevel.h.

Now THAT is seriously cool :-)

I have seen that the code writes the debug messages "to a buffer", but couldn't find out (yet) how to access the debug messages.

Thanks a lot for this. I will use this information to improve the debug printing of IPv6 packets (which is non-existant yet) and also add a bit of debug printing to the code that does neighbor discovery / neighbor advertisement spoofing, so it's visible in the logs what happens and why.

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...