Development discussion of WireGuard
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Daniel Lenski <dlenski@gmail.com>,"Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: Duplicate IP address, and permissions problems on Windows
Date: Thu, 08 Apr 2021 09:46:43 +0100	[thread overview]
Message-ID: <5D336E0F-1A42-4692-8597-6A035C4FA699@infradead.org> (raw)
In-Reply-To: <CAOw_LSEasJuHDPXGkVQnYh_aHd+nOY53D0LRUXuH+pN45ynz2w@mail.gmail.com>



On 8 April 2021 00:00:46 BST, Daniel Lenski <dlenski@gmail.com> wrote:
>On Tue, Apr 6, 2021 at 5:17 PM Jason A. Donenfeld <Jason@zx2c4.com>
>wrote:
>> It's pretty typical behavior on Windows for IP addresses to be
>> exclusive per interface. WireGuard for Windows does something
>similar:
>>
>https://git.zx2c4.com/wireguard-windows/tree/tunnel/addressconfig.go#n22
>
>Thank you! That's very interesting.
>
>Following David's initial implementation, I wrote something for
>OpenConnect that's pretty much the same as yours:
>https://gitlab.com/openconnect/openconnect/-/compare/5e6e9b850756157164f83cd4fedafb747fbbd50f...0bca5b32ac478b5d03b6e88f96bf29c6556610a5
>
>1. Uses GetAdaptersAddresses to list all the addresses
>2. If/when it finds a clashing address, it uses
>GetUnicastIpAddressTable to determine the up/down state of the other
>interface
>3. Only delete the address from the other interface if it's non-UP.
>
>I was also annoyed that the GetAdaptersAddresses return structure
>doesn't provide the adapter state, and that I had to go for this
>convoluted O(n^2) design.
>
>I guess this reassures me that there isn't an obviously-better way to
>do it.

Unless netsh will do it for us when we ask *it* to set the IP address? OpenConnect doesn't normally bother itself with administrivia like setting IP addresses; its job is to pass packets.

When I first wrote it, I just usurped the vpnc-script from vpnc which does all the routing/DNS/etc configuration for every platform under the sun, so all we do generally in OpenConnect is set the environment variables up and spawn the script.

The only reason we ever set a Legacy IP directly in C for Tap-Windows was to make it do all the fake ARP nonsense correctly. (And ISTR we didn't need to do anything for IPv6 as it just needs to use a known lladdr as the route gw). We don't need that with Wintun.

I preserved it in the first cut of Wintun support because the existing vpnc-script for Windows actually depends on it... but purely for waiting for the interface to come up. Can we ditch that, let the script set the address for us, and forget we ever saw that O(n²) code because netsh handles the conflicting interfaces for us?



-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

  reply	other threads:[~2021-04-08  8:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06 11:29 David Woodhouse
2021-04-07  0:17 ` Jason A. Donenfeld
2021-04-07  8:18   ` David Woodhouse
2021-04-07 23:05     ` Daniel Lenski
2021-04-12 17:50       ` Jason A. Donenfeld
2021-04-07 23:00   ` Daniel Lenski
2021-04-08  8:46     ` David Woodhouse [this message]
2021-04-08 16:09       ` Daniel Lenski
2021-04-08 16:59     ` David Woodhouse
2021-04-08 17:53       ` Daniel Lenski
2021-04-10  9:25         ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5D336E0F-1A42-4692-8597-6A035C4FA699@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=Jason@zx2c4.com \
    --cc=dlenski@gmail.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).