Skip to contentSkip to conversation

TAP-adapter iftype question

Openvpn-devel Karl Mueller 3 participants 7 messages Jul 26, 2017 – Jul 27, 2017

lore
Share & tools
lore
#0 lore raw

I’m hoping this is the right place to bring this issue, i’ve had no luck with searching or bodging a solution on my own, and may need some help with a slightly-modified TAP adapter driver.

I’m running into an issue between the TAP adapter and Windows 10 ‘soft disconnect’ behavior for wireless connections causing recursive routing when connected to a redirect-gateway VPN. The service/feature in Windows is called Windows Connection Manager service, poorly documented here: https://docs.microsoft.com/en-us/windows-hardware/drivers/mobilebroadband/understanding-and-configuring-windows-connection-manager <https://docs.microsoft.com/en-us/windows-hardware/drivers/mobilebroadband/understanding-and-configuring-windows-connection-manager> In a nutshell it silently redirects traffic to the more ‘reliable’ Ethernet OpenVPN adapter, overriding my /32 route and causing all traffic to fail as it recursively routes my traffic.

Microsoft makes some suggestion to disable the ‘prevent multiple connections to the Internet’ setting, but doing this does not seem to change the behavior when weak (but still functional) wireless signal is detected on the WLAN adapter. Microsoft see this as a problem with OpenVPN and refuse to do anything about it.
https://support.microsoft.com/en-us/help/2919900/windows-connection-manager-disconnects-wlan-if-a-vpn-connection-is-est <https://support.microsoft.com/en-us/help/2919900/windows-connection-manager-disconnects-wlan-if-a-vpn-connection-is-est>

The upshot is that if Windows detected the TAP adapter as something other than iftype 0x6 EthernetCSMACD it wouldn’t exhibit this behavior, and Microsoft suggest 0x53 ‘virtual’ or 0x83 ’tunnel’ as the VPN adapter’s iftype (I’d suggest 0x84 for the comedy option).

I’ve found someone who’s successfully hacked this to work https://forums.openvpn.net/viewtopic.php?t=14942 <https://forums.openvpn.net/viewtopic.php?t=14942> but I’m not able to reproduce it on my own, but it seems reasonable that it should work. I’m wondering if it makes sense to change the underlying TAP driver (or make the if type an option) since Windows seems to be getting “smarter” about interfaces and making routing or even security policy decisions based on the interface type presented.

The reason I’m posting this to the Dev list is I’ve no idea what the ramifications of changing the iftype, maybe someone’s looked in to this, but I haven’t seen any mention on this list about it. It seems reasonable that the change should be relatively minor, but again i’m not aware of all the corner cases that might rely on the if type being Ethernet for Windows to work properly.

Thanks for listening

Karl Mueller
[email protected]...

#1 lore raw

Hi,

Quoted 1 line · Karl Mueller

The reason I???m posting this to the Dev list is I???ve no idea what the ramifications of changing the iftype, maybe someone???s looked in to this, but I haven???t seen any mention on this list about it. It seems reasonable that the change should be relatively minor, but again i???m not aware of all the corner cases that might rely on the if type being Ethernet for Windows to work properly.

I have no idea what the effect would be ("will it stop doing ethernet framing? no more ARP?"), but it's an interesting idea to try.

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 5 lines

I have no idea what the effect would be ("will it stop doing ethernet framing? no more ARP?"), but it's an interesting idea to try.

Thanks, seems OpenVPN is not the only VPN client that may recognize this as an issue and change their iftype. https://quickview.cloudapps.cisco.com/quickview/bug/CSCut51057 The Cisco adapter previously used 0x6 judging by an old Cisco VPN installation I had access to.

Is it possible to have someone create a signed test build of the TAP adapter with iftype 131 in the oemvista.inf?

Karl Mueller
[email protected]...

#3 lore raw

Hi,

Quoted 6 lines · Karl Mueller
Quoted 5 lines

I have no idea what the effect would be ("will it stop doing ethernet framing? no more ARP?"), but it's an interesting idea to try.

Quoted 8 lines

Thanks, seems OpenVPN is not the only VPN client that may recognize this as an issue and change their iftype. https://quickview.cloudapps.
cisco.com/quickview/bug/CSCut51057 The Cisco adapter previously used 0x6 judging by an old Cisco VPN installation I had access to.

Is it possible to have someone create a signed test build of the TAP adapter with iftype 131 in the oemvista.inf?

This should be easy to test by editing the installed OemVista.inf (in C:\Program Files\Tap-Windows\driver\ by default) and running addtap to create a new adapter with the required iftype. The resulting interface will most likely not show up in the adapter list in control panel, but should show in 'openvpn --show-adapters'

But I do not think it will work: with iftype = 0x83 (131) the interface will not get a physical address (MAC) etc. Further, the tap-windows driver source sets the iftype as IF_TYPE_ETHERNET_CSMACD (=0x06) which is supposed to match the value in the inf file.

I have a couple of wifi only win10 machines on which I have not seen this disconnection behaviour. Is it because I do not use redirect-gateway? Does the wifi disconnection happen only when default route is overwritten or is even "--redirect-gateway def1" not immune to it?

Selva

#4 lore raw
Quoted 3 lines

This should be easy to test by editing the installed OemVista.inf (in C:\Program Files\Tap-Windows\driver\ by default) and running addtap to create a new adapter with the required iftype. The resulting interface will most likely not show up in the adapter list in control panel, but should show in 'openvpn --show-adapters’

Well, Win10 has very strict signing requirements and I have all secure boot enabled machines, so I’m not able to easily break them to test :)

Quoted 2 lines

But I do not think it will work: with iftype = 0x83 (131) the interface will not get a physical address (MAC) etc. Further, the tap-windows driver source sets the iftype as IF_TYPE_ETHERNET_CSMACD (=0x06) which is supposed to match the value in the inf file.

That would explain why editing the registry after it’s installed to change the iftype does not work, if the driver itself is looking for the specific iftype. So I suppose there will have to be some further modification of the driver code to accommodate this.

Quoted 2 lines

I have a couple of wifi only win10 machines on which I have not seen this disconnection behaviour. Is it because I do not use redirect-gateway? Does the wifi disconnection happen only when default route is overwritten or is even "--redirect-gateway def1" not immune to it?

I think it is due to the redirect-gateway, and def1 does not change the behavior. I believe it’s because Windows sends NCSI internet probes to determine if an adapter has “Internet” access. If you’re not redirecting your gateway, those probes will probably fail via the VPN interface so it won’t consider the VPN interface as a viable alternative.

A frustrating part of the problem is that Windows overrides the routing table by *silently* directing new connections to the “better” Ethernet interface (in anticipation of the WiFi losing signal altogether, I suppose). The only way to observe this is to use the powershell command ‘find-netroute -remote <ip>’ which tells you where Windows will *really* send the packet. Also the effect of the redirection isn’t immediate, Windows waits from 30-120 seconds to start redirecting traffic to the VPN interface once it detects weak WiFi signal.

Some more details of my setup: I use the Windows service-based VPN connection rather than user-initiated by way of openvpnserv2.exe. We are using build 1511 of Windows 10. I posted my configs here: https://forums.openvpn.net/viewtopic.php?f=4&t=24499

Thank you for taking the time to look at this.

Karl Mueller
[email protected]...

#5 lore raw

Hi,

Quoted 7 lines · Karl Mueller

I think it is due to the redirect-gateway, and def1 does not change the behavior. I believe it’s because Windows sends NCSI internet probes to determine if an adapter has “Internet” access. If you’re not redirecting your gateway, those probes will probably fail via the VPN interface so it won’t consider the VPN interface as a viable alternative.

If so just redirecting msftncsi.com through VPN will trigger this?

Quoted 10 lines

A frustrating part of the problem is that Windows overrides the routing table by *silently* directing new connections to the “better” Ethernet interface (in anticipation of the WiFi losing signal altogether, I suppose). The only way to observe this is to use the powershell command ‘find-netroute -remote <ip>’ which tells you where Windows will *really* send the packet. Also the effect of the redirection isn’t immediate, Windows waits from 30-120 seconds to start redirecting traffic to the VPN interface once it detects weak WiFi signal.

So to reproduce this the wifi signal has to go weak as well?

Quoted 5 lines

Some more details of my setup: I use the Windows service-based VPN connection rather than user-initiated by way of openvpnserv2.exe. We are using build 1511 of Windows 10. I posted my configs here:
https://forums.openvpn.net/viewtopic.php?f=4&t=24499

I suppose you mean the opposite: that is the connection is started at boot using OpenVPNService (i.e., openvpnserv2.exe). User initiated connections (using the GUI) are started by OpenVPNServiceInteractive (i.e., openvpnserv.exe).

Will try to reproduce, but being affected only when auto-started at boot is puzzling. In both cases the routes are set up the same way so it should not matter. Except for --redirect-gateway: the interactive service will force the use of def1, but again your config specifies def1 so the behaviour should be the same.

Selva

#6 lore raw
Quoted 11 lines · Selva Nair

Hi,

On Thu, Jul 27, 2017 at 2:01 PM, Karl Mueller <[email protected]... <mailto:[email protected]...>> wrote:

I think it is due to the redirect-gateway, and def1 does not change the behavior. I believe it’s because Windows sends NCSI internet probes to determine if an adapter has “Internet” access. If you’re not redirecting your gateway, those probes will probably fail via the VPN interface so it won’t consider the VPN interface as a viable alternative.

If so just redirecting msftncsi.com <http://msftncsi.com/> through VPN will trigger this?

Possibly, but I think there’s more (undocumented) complexity to it. I tried blocking msftncsi.com IP’s on VPN and it had no effect.

Quoted 5 lines

A frustrating part of the problem is that Windows overrides the routing table by *silently* directing new connections to the “better” Ethernet interface (in anticipation of the WiFi losing signal altogether, I suppose). The only way to observe this is to use the powershell command ‘find-netroute -remote <ip>’ which tells you where Windows will *really* send the packet. Also the effect of the redirection isn’t immediate, Windows waits from 30-120 seconds to start redirecting traffic to the VPN interface once it detects weak WiFi signal.

So to reproduce this the wifi signal has to go weak as well?

Yes, the connection is perfectly stable until wifi drops below some internal signal setting, or possibly until it drops a packet or two. get-netadapter shows that when the wifi speed drops below 7mb/s it almost always triggers the behavior. There’s no logging associated with the behavior that I can find, which makes it difficult to troubleshoot too.

Quoted 5 lines

Some more details of my setup: I use the Windows service-based VPN connection rather than user-initiated by way of openvpnserv2.exe. We are using build 1511 of Windows 10. I posted my configs here: https://forums.openvpn.net/viewtopic.php?f=4&t=24499 <https://forums.openvpn.net/viewtopic.php?f=4&t=24499>

I suppose you mean the opposite: that is the connection is started at boot using OpenVPNService (i.e., openvpnserv2.exe). User initiated connections (using the GUI) are started by OpenVPNServiceInteractive (i.e., openvpnserv.exe).

Yes, sorry I said that backwards.

Quoted 2 lines

Will try to reproduce, but being affected only when auto-started at boot is puzzling. In both cases the routes are set up the same way so it should not matter. Except for --redirect-gateway: the interactive service will force the use of def1, but again your config specifies def1 so the behaviour should be the same.

I am not sure about autostart being the culprit, but I think it’s another calculation in MS’s decision to drop the connection and maybe why this isn’t so widely reported.

The page below describes the decision making logic in Windows, but it’s obviously missing some specifics:
https://docs.microsoft.com/en-us/windows-hardware/drivers/mobilebroadband/understanding-and-configuring-windows-connection-manager

Karl Mueller
[email protected]...