<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-go/device, branch js/sample-api</title>
<subtitle>Go implementation of WireGuard</subtitle>
<id>https://git.zx2c4.com/wireguard-go/atom/device?h=js%2Fsample-api</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-go/atom/device?h=js%2Fsample-api'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/'/>
<updated>2020-12-22T19:29:28Z</updated>
<entry>
<title>device: add Device.ListenPort and Device.SetListenPort</title>
<updated>2020-12-22T19:29:28Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-22T19:12:54Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=4794021bb8c697f107e6a2689bb9096eabb17888'/>
<id>urn:sha1:4794021bb8c697f107e6a2689bb9096eabb17888</id>
<content type='text'>
This is a sample commit for a possible way to make
a Go API that lives alongside UAPI.

The general idea is to add Device and Peer methods
corresponding to UAPI directives, including a way to
look up a peer from a device based on a public key,
as in UAPI.

The UAPI code then deals with parsing and generating textual
input/output, and calls the Go methods to do the work.

This commit also contains a bug fix for a racy access of device.net.port
I will send an independently commit that fixes those directly in UAPI.
This commit is NOT meant to be merged as-is.

Signed-off-by: Josh Bleecher Snyder &lt;josh@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: add UAPI helper methods</title>
<updated>2020-12-22T13:30:57Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2020-12-22T13:30:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=60b271ff95405de2b36ef99b64bd42516218e2e8'/>
<id>urn:sha1:60b271ff95405de2b36ef99b64bd42516218e2e8</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>device: add missing colon to error line</title>
<updated>2020-12-18T19:18:47Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2020-12-18T10:52:13Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=85cb3597d05db8f7ac82460ef336563cc9d07d2d'/>
<id>urn:sha1:85cb3597d05db8f7ac82460ef336563cc9d07d2d</id>
<content type='text'>
People are actually hitting this condition, so make it uniform. Also,
change a printf into a println, to match the other conventions.

Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>device: fix error shadowing before log print</title>
<updated>2020-12-17T11:15:14Z</updated>
<author>
<name>Brad Fitzpatrick</name>
<email>bradfitz@tailscale.com</email>
</author>
<published>2020-09-21T22:17:16Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=9c4bcedf80ee12e737fb482e7972beb0b84c3361'/>
<id>urn:sha1:9c4bcedf80ee12e737fb482e7972beb0b84c3361</id>
<content type='text'>
Signed-off-by: Brad Fitzpatrick &lt;bradfitz@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: fix data race in peer.timersActive</title>
<updated>2020-12-17T00:16:26Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-16T01:44:21Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=26b0dca4f569ccd1fb02fe3742cbed8595b24728'/>
<id>urn:sha1:26b0dca4f569ccd1fb02fe3742cbed8595b24728</id>
<content type='text'>
Found by the race detector and existing tests.

To avoid introducing a lock into this hot path,
calculate and cache whether any peers exist.

Signed-off-by: Josh Bleecher Snyder &lt;josh@tailscale.com&gt;
</content>
</entry>
<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: always name *Queue*Element variables elem</title>
<updated>2020-12-17T00:16:26Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-16T00:00:52Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=7d88fbd2177caccef40ab60c927f9539e723903e'/>
<id>urn:sha1:7d88fbd2177caccef40ab60c927f9539e723903e</id>
<content type='text'>
They're called elem in most places.
Rename a few local variables to make it consistent.
This makes it easier to grep the code for things like elem.Drop.

Signed-off-by: Josh Bleecher Snyder &lt;josh@tailscale.com&gt;
</content>
</entry>
<entry>
<title>device: use channel close to shut down and drain outbound channel</title>
<updated>2020-12-17T00:16:26Z</updated>
<author>
<name>Josh Bleecher Snyder</name>
<email>josh@tailscale.com</email>
</author>
<published>2020-12-15T23:54:48Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-go/commit/?id=15af3e58ce918d4f68f3a85710e7252f5260d741'/>
<id>urn:sha1:15af3e58ce918d4f68f3a85710e7252f5260d741</id>
<content type='text'>
This is a similar treatment to the handling of the encryption
channel found a few commits ago: Use the closing of the channel
to manage goroutine lifetime and shutdown.
It is considerably simpler because there is only a single writer.

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>
</feed>
