<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wintun/api, branch master</title>
<subtitle>Layer 3 TUN Driver for Windows</subtitle>
<id>https://git.zx2c4.com/wintun/atom/api?h=master</id>
<link rel='self' href='https://git.zx2c4.com/wintun/atom/api?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/'/>
<updated>2026-03-18T17:49:30Z</updated>
<entry>
<title>driver: fix missed-wakeup race in ring buffer Alertable signaling</title>
<updated>2026-03-18T17:49:30Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon.rozman@amebis.si</email>
</author>
<published>2026-02-24T23:47:17Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=ec0a6b98456fe1ba52567bb2add4bbf5f64315a1'/>
<id>urn:sha1:ec0a6b98456fe1ba52567bb2add4bbf5f64315a1</id>
<content type='text'>
Add MemoryBarrier() between store-load pairs in the Dekker-style
synchronization used by the Receive ring's Alertable/Tail protocol.

On x86-64, WriteRelease/ReadAcquire only prevent compiler reordering and
provide acquire/release semantics, but do not emit MFENCE — the only
instruction that prevents store-load reordering across cores. Without a
full barrier, both the userspace producer and the kernel consumer can
simultaneously read stale values:

  Userspace: STORE(Tail)  ...  LOAD(Alertable) -&gt; sees FALSE (stale)
  Driver:    STORE(Alertable=TRUE) ... LOAD(Tail) -&gt; sees old tail

The driver then enters KeWaitForMultipleObjects with no pending
SetEvent, sleeping until a TCP retransmission (typically 4-5s later)
re-triggers the send path and wins the race.

The fix adds MemoryBarrier() (MFENCE on x86) on both sides:
- api/session.c WintunSendPacket: between WriteULongRelease(Tail) and
  ReadAcquire(Alertable)
- driver/twintun.c TunProcessReceiveData: between
  WriteRelease(Alertable, TRUE) and ReadULongAcquire(Tail)

This guarantees that at least one side always observes the other's
store, preventing the missed wakeup while preserving the Alertable
optimization that avoids unnecessary SetEvent syscalls.

Reported-by: Alexey Lapuka &lt;alexey@twingate.com&gt;
Reference: https://lists.zx2c4.com/pipermail/wireguard/2026-February/009523.html
Signed-off-by: Simon Rozman &lt;simon.rozman@amebis.si&gt;
</content>
</entry>
<entry>
<title>doc: fix WintunReceivePacket name</title>
<updated>2026-02-09T10:24:51Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon.rozman@amebis.si</email>
</author>
<published>2026-02-09T10:24:51Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=ce4940dce875c5ba93eb410dcd4427bb5e23c1ed'/>
<id>urn:sha1:ce4940dce875c5ba93eb410dcd4427bb5e23c1ed</id>
<content type='text'>
There is no `WintunReceivePackets`. Just `WintunReceivePacket`.

Signed-off-by: Simon Rozman &lt;simon.rozman@amebis.si&gt;
</content>
</entry>
<entry>
<title>api: header: silence MSVC warnings for MSVC only</title>
<updated>2021-12-03T08:17:19Z</updated>
<author>
<name>Simon Rozman</name>
<email>simon@rozman.si</email>
</author>
<published>2021-12-03T08:17:19Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=c2315570e08f52149c6c3878311aea661b9193ca'/>
<id>urn:sha1:c2315570e08f52149c6c3878311aea661b9193ca</id>
<content type='text'>
MinGW ignores unknown `#pragma warning` lines, but displays a warning
nevertheless.

Signed-off-by: Simon Rozman &lt;simon@rozman.si&gt;
</content>
</entry>
<entry>
<title>api: main: avoid excessive function cast</title>
<updated>2021-10-15T00:43:52Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-10-15T00:43:52Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=6e579cf4f840aa90d7315bbe279bfc91d92b5897'/>
<id>urn:sha1:6e579cf4f840aa90d7315bbe279bfc91d92b5897</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>api: header: fix typo</title>
<updated>2021-10-14T22:30:24Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-10-14T22:30:02Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=194f36f6c0ab6b2e658377a4228944ef0a19d0ef'/>
<id>urn:sha1:194f36f6c0ab6b2e658377a4228944ef0a19d0ef</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>api: use proper instance id bounds</title>
<updated>2021-10-14T06:51:22Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-10-14T06:37:50Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=470bdf3e26e433032fe7986f379cad797cdd94cd'/>
<id>urn:sha1:470bdf3e26e433032fe7986f379cad797cdd94cd</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>api: adapter: handle cases explicitly in dev query callback</title>
<updated>2021-10-14T05:28:09Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-10-14T05:27:13Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=80aab77c1987788561c3d60cb8eb7f7fe8dac829'/>
<id>urn:sha1:80aab77c1987788561c3d60cb8eb7f7fe8dac829</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>downlevelshim: remove in preparation for full WHQL</title>
<updated>2021-10-13T17:34:17Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-10-13T17:33:06Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=21958630ede7639386f4e69024b937b5834e0e8a'/>
<id>urn:sha1:21958630ede7639386f4e69024b937b5834e0e8a</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>driver: automatically close long-lived handle</title>
<updated>2021-10-12T18:55:24Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-10-12T18:44:42Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=d8fe1419fb480ec5fc4dd0c4bc49f1d1a1a90663'/>
<id>urn:sha1:d8fe1419fb480ec5fc4dd0c4bc49f1d1a1a90663</id>
<content type='text'>
There's only one handle that's likely to be open in a long lived way:
the tun registration handle. So we can force that closed automatically
when the device is about to close, if it's been improperly left open.
Other handles will indeed hold up closing, but if those exist, they're a
sign of a larger bug elsewhere that should be addressed. On the other
hand, tun registration handles might legitimately be open during driver
upgrades. This also saves us the trouble of dereferencing a freed
FileObject as in the general case.

Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
<entry>
<title>api: rewrite based on SwDevice</title>
<updated>2021-10-12T18:54:20Z</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2021-10-12T05:21:31Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wintun/commit/?id=544fdaaf8fb970d9657a59c1fc4c4569de4f2d3e'/>
<id>urn:sha1:544fdaaf8fb970d9657a59c1fc4c4569de4f2d3e</id>
<content type='text'>
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
</content>
</entry>
</feed>
