Skip to contentSkip to conversation

cstp: Add workaround for 255.255.255.255 netmask on windows

PATCH David Woodhouse 2 participants 2 messages Jun 23, 2014 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 2 lines · Aleksandar Kanchev

inet_aton("255.255.255.255") would fail on windows which would result of the script variable INTERNAL_IP4_NETMASK not being set.

That should be fixed by
http://git.infradead.org/users/dwmw2/openconnect.git/commitdiff/d8b7da1a

What is the config you get from the server? You have a VPN address/netmask of a single Legacy IP address and 255.255.255.255, which would basically leave you routing *nothing* to the VPN, and then you have a set of routes to add to that?

Quoted 3 lines

Another side effect is that if the TAP Windows driver is being initialized with 255.255.255.255 netmask then there's no way to convince windows to route packets through that interface.

If this isn't considered a bug in the Windows tap driver, (and I suspect it isn't, because they're working around some true horridness in the Windows network stack), then I think it's better to localise it to our tun-win32.c with something like the following:

tun-win32.c +4 -0
index 102a7d0..b9ac163 100644
@@ -169,6 +169,10 @@ static intptr_t open_tun(struct openconnect_info *vpninfo, char *guid, char *nam
 
 	data[0] = inet_addr(vpninfo->ip_info.addr);
 	data[2] = inet_addr(vpninfo->ip_info.netmask);
+	/* Ick. The Windows tap driver (or network stack) cannot cope with a netmask
+	   of 255.255.255.255. */
+	if (data[2] == 0xffffffff)
+		data[2] = htonl(0xfffffffe);
 	data[1] = data[0] & data[2];
 
 	if (!DeviceIoControl(tun_fh, TAP_IOCTL_CONFIG_TUN,
Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]...                              Intel Corporation
#2 lore raw

Hi,

Quoted 7 lines · David Woodhouse
Quoted 3 lines

Another side effect is that if the TAP Windows driver is being initialized with 255.255.255.255 netmask then there's no way to convince windows to route packets through that interface.

If this isn't considered a bug in the Windows tap driver, (and I suspect it isn't, because they're working around some true horridness in the Windows network stack),

Well, for Windows, a tap interface is an ethernet interface in good standing - and not a point-to-point thing like a tun on other platforms where there really is no "subnet" but "my IP, and what's on the other side".

So, as you can't put 255.255.255.255 on normal ethernet interfaces, you can't do that on the tap driver either. I'm not sure whether .254 would work - which is why OpenVPN's net30 always wasted a /30 in the old days, or uses a larger subnet now.

There is not very much we can do to "fix" that in the tap driver, especially as the ifconfig is done outside the driver in the generic IP part of the stack...

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]...