<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-go/device/device_test.go, branch js/sample-api</title>
<subtitle>Go implementation of WireGuard</subtitle>
<id>https://git.zx2c4.com/wireguard-go/atom/device/device_test.go?h=js%2Fsample-api</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-go/atom/device/device_test.go?h=js%2Fsample-api'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/'/>
<updated>2020-12-17T00:16:26Z</updated>
<entry>
<title>device: fix races from changing private_key</title>
<updated>2020-12-17T00:16:26Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-15T23:02:13Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=4bced36d327754ad9567eba450413c07ff80da72'/>
<id>urn:sha1:4bced36d327754ad9567eba450413c07ff80da72</id>
<content type='text'>
Access keypair.sendNonce atomically.
Eliminate one unnecessary initialization to zero.

Mutate handshake.lastSentHandshake with the mutex held.

Co-authored-by: David Anderson &lt;danderson@tailscale.com&gt;
Signed-off-by: Josh Bleecher Snyder &lt;josh@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: fix persistent_keepalive_interval data races</title>
<updated>2020-12-16T00:57:09Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-14T23:28:52Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=e739ff71a58599b0e8b2f41a5031ef3cfdde4f89'/>
<id>urn:sha1:e739ff71a58599b0e8b2f41a5031ef3cfdde4f89</id>
<content type='text'>
Co-authored-by: David Anderson &lt;danderson@tailscale.com&gt;
Signed-off-by: Josh Bleecher Snyder &lt;josh@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: use channel close to shut down and drain encryption channel</title>
<updated>2020-12-16T00:57:09Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-14T23:07:23Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=71ef21087e9f3d7154f003289ea297641d71e723'/>
<id>urn:sha1:71ef21087e9f3d7154f003289ea297641d71e723</id>
<content type='text'>
The new test introduced in this commit used to deadlock about 1% of the time.

I believe that the deadlock occurs as follows:

* The test completes, calling device.Close.
* device.Close closes device.signals.stop.
* RoutineEncryption stops.
* The deferred function in RoutineEncryption drains device.queue.encryption.
* RoutineEncryption exits.
* A peer's RoutineNonce processes an element queued in peer.queue.nonce.
* RoutineNonce puts that element into the outbound and encryption queues.
* RoutineSequentialSender reads that elements from the outbound queue.
* It waits for that element to get Unlocked by RoutineEncryption.
* RoutineEncryption has already exited, so RoutineSequentialSender blocks forever.
* device.RemoveAllPeers calls peer.Stop on all peers.
* peer.Stop waits for peer.routines.stopping, which blocks forever.

Rather than attempt to add even more ordering to the already complex
centralized shutdown orchestration, this commit moves towards a
data-flow-oriented shutdown.

The device.queue.encryption gets closed when there will be no more writes to it.
All device.queue.encryption readers always read until the channel is closed and then exit.
We thus guarantee that any element that enters the encryption queue also exits it.
This removes the need for central control of the lifetime of RoutineEncryption,
removes the need to drain the encryption queue on shutdown, and simplifies RoutineEncryption.

This commit also fixes a data race. When RoutineSequentialSender
drains its queue on shutdown, it needs to lock the elem before operating on it,
just as the main body does.

The new test in this commit passed 50k iterations with the race detector enabled
and 150k iterations with the race detector disabled, with no failures.

Signed-off-by: Josh Bleecher Snyder &lt;josh@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: add a helper to generate uapi configs</title>
<updated>2020-12-15T17:08:24Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-14T22:12:56Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=ae6b17f7595e3d425f7b63e470d159327018ef04'/>
<id>urn:sha1:ae6b17f7595e3d425f7b63e470d159327018ef04</id>
<content type='text'>
This makes it easier to work with configs in tests.
It'll see heavier use over upcoming commits;
this commit only adds the infrastructure.

Signed-off-by: Josh Bleecher Snyder &lt;josh@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: increase timeout in tests</title>
<updated>2020-12-15T17:08:24Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-14T22:11:33Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=77f55458962a763b3b2d7f76973ef9043c183145'/>
<id>urn:sha1:77f55458962a763b3b2d7f76973ef9043c183145</id>
<content type='text'>
When running many concurrent test processing using
https://godoc.org/golang.org/x/tools/cmd/stress
the processing sometimes cannot complete a ping in under 300ms.
Increase the timeout to 5s to reduce the rate of false positives.

Signed-off-by: Josh Bleecher Snyder &lt;josh@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: make test setup more robust</title>
<updated>2020-12-10T21:37:10Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-09T03:23:56Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=a5a9c0db00261b50ef790eb7bb318fc9c1a56aa5'/>
<id>urn:sha1:a5a9c0db00261b50ef790eb7bb318fc9c1a56aa5</id>
<content type='text'>
Picking two free ports to use for a test is difficult.
The free port we selected might no longer be free when we reach
for it a second time.

On my machine, this failure mode led to failures approximately
once per thousand test runs.

Since failures are rare, and threading through and checking for
all possible errors is complicated, fix this with a big hammer:
Retry if either device fails to come up.

Also, if you accidentally pick the same port twice, delightful confusion ensues.
The handshake failures manifest as crypto errors, which look scary.
Again, fix with retries.

To make these retries easier to implement, use testing.T.Cleanup
instead of defer to close devices. This requires Go 1.14.
Update go.mod accordingly. Go 1.13 is no longer supported anyway.

With these fixes, 'go test -race' ran 100,000 times without failure.

Signed-off-by: Josh Bleecher Snyder &lt;josh@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: get free port when testing</title>
<updated>2020-07-31T14:18:53Z</updated>
<author>
<name>Sina Siadat</name>
<email>siadat@gmail.com</email>
</author>
<published>2020-07-30T16:20:49Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=bc3f505efa9f4f780d21165311df34ca0e8d7e20'/>
<id>urn:sha1:bc3f505efa9f4f780d21165311df34ca0e8d7e20</id>
<content type='text'>
Signed-off-by: Sina Siadat &lt;siadat@gmail.com&gt;
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>global: update header comments and modules</title>
<updated>2020-05-02T08:08:26Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2020-05-02T08:08:26Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=db0aa39b765243c6a4ac9a2e348311df9517c0bf'/>
<id>urn:sha1:db0aa39b765243c6a4ac9a2e348311df9517c0bf</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>tuntest: split out testing package</title>
<updated>2020-05-02T07:46:42Z</updated>
<author>
<name>David Crawshaw</name>
<email>crawshaw@tailscale.com</email>
</author>
<published>2020-01-07T15:43:17Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=1a1c3d096888816c94cf1eb7c2747e83f008549f'/>
<id>urn:sha1:1a1c3d096888816c94cf1eb7c2747e83f008549f</id>
<content type='text'>
This code is useful to other packages writing tests.

Signed-off-by: David Crawshaw &lt;crawshaw@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: test packets between two fake devices</title>
<updated>2019-10-16T09:38:28Z</updated>
<author>
<name>David Crawshaw</name>
<email>crawshaw@tailscale.io</email>
</author>
<published>2019-10-12T16:44:05Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=540d01e54ae472aa395ff1869af9de91171cdd7b'/>
<id>urn:sha1:540d01e54ae472aa395ff1869af9de91171cdd7b</id>
<content type='text'>
Signed-off-by: David Crawshaw &lt;crawshaw@tailscale.io&gt;
</content>
</entry>
</feed>
