aboutsummaryrefslogtreecommitdiffstats
path: root/driver (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Allow packet over-allocation on sendsr/api-improvementsSimon Rozman2021-04-131-5/+9
| | | | | | | | | | | Should client desire to prepare packets for Wintun inside the ring memory (e.g. to reduce memory copying), the final sending packet size is not always known at the WintunAllocateSendPacket() time. This commit modifies Wintun to calculate the packet size on delivery to NDIS. The packet size is derived from IPv4/IPv6 packet header. Signed-off-by: Simon Rozman <simon@rozman.si>
* Allow optional padding before and after layer 3 packetsSimon Rozman2021-04-131-41/+89
| | | | | | | | | | To avoid additional packet memory allocation and copy when sending or receiving packets, this commit introduces additional available space before and after layer 3 IPv4 or IPv6 packet in the Wintun rings. Wintun will ignore data in those areas. Requested-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Simon Rozman <simon@rozman.si>
* Fix © in resourcesSimon Rozman2021-03-191-0/+2
| | | | | | | | The \xa9 is © on Windows-125x code pages. When Wintun was compiled on a Windows computer using UTF-8 as default code page (for "non-Unicode" programs), the Copyright notice in resources was wrong. Signed-off-by: Simon Rozman <simon@rozman.si>
* project: add support for intermediate versioningSimon Rozman2021-03-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | While the Wintun driver is typically released only at <major>.<minor> milestones, the wintun.dll did see some intermediate releases. To make MSI logic correctly decide to upgrade local wintun.dll file, the version inscribed in wintun.dll file resources should increment in those intermediate releases. MSI ignores file timestamps. One could use REINSTALLMODE=emus Installer property to force copying wintun.dll when its version doesn't change. But REINSTALLMODE applies to all files in the MSI session and would be an additional requirement when authoring MSI packages with wintun.dll. Bumping only the final ZIP filename version is not sufficient. Therefore, a <major>.<minor> or <major>.<minor>.<build> versioning is introduced. Furthermore, we no longer distinguish between WintunVersion and WintunVersionStr. All our releases used strictly numeric <major>.<minor> notation, making WintunVersion and WintunVersionStr always the same. When the driver didn't change, just bump the version in wintun.proj and run `msbuild wintun.proj /t:Zip` to rebuild the wintun.dll and make the new ZIP file. Signed-off-by: Simon Rozman <simon@rozman.si>
* global: bump copyrightJason A. Donenfeld2021-01-304-5/+5
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* driver: use IoAllocateMdl without being too cleverJason A. Donenfeld2020-12-151-8/+17
| | | | | | | | | | | | Windows 7 doesn't like our trick of sticking MDLs into the NBL context area. So we do things more traditionally, by allocating an MDL with IoAllocateMdl and freeing it with IoFreeMdl. This means that we have to keep track of the MDL between allocation and free time, and we don't have any more miniport reserved pointers left in the NBL. So instead we walk the MdlChain field of the first NB, and free the one that has an address living inside of the non-partial MDL. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* driver: use partial MDL for slicing ring, rather than NB's DataOffsetJason A. Donenfeld2020-12-131-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Providing the DataOffset member of the NBL allocation function or setting that member in the NB header indicates to NDIS not only that the data starts at that offset, but that there's that amount of space *available for it to use as it wants* before that offset. This meant that NDIS was allowed to scribble data before the packet. This was bounded by the size of the ring, so there was never any risk of memory corruption, and since the ring is shared by userspace as well as the rest of the kernel, we've always taken care of reading from it closely, checking all values, and erroring out on corruption of the ring. So, if NDIS wrote before the first packet, this would wind up corrupting the RingTail and Alertable fields of the ring. The receiver thread would then notice this, error out, and set the RingHead to MAXULONG on its way out the door, so that userspace can detect it. And indeed wintun.dll then started returning EOF from its write function. Mostly this was not an issue, because we're not expecting for data to be pushed on the head of a packet on ingress. But WSL2's Hyper-V driver is actually pushing an ethernet header onto the front of the packet before passing it off to Linux. Practically speaking, this manifested itself in the RingTail and Alertable fields having Linux's MAC address! And then the adapter would be EOF'd. This was reported as happening after WSL2 sends the *first* packet, but not others, which makes sense, because it has to be at the beginning in order to corrupt those fields. This fixes the problem by simply using a new MDL for the span we want, instead of using the misunderstood DataOffset field. In order to not need to keep track of memory allocations, we allocate the MDL as part of the NBL's context area. And in order to avoid additional mappings, we use IoBuildPartialMdl, which returns an MDL_PARTIAL, which does not have an additional mapping that needs to be freed or unmapped. After making this change, WSL2 no longer appears to halt the adapter, and all works well. Fixes: be8d2cb ("Avoid allocating second MDL") Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* driver: use localtime in inf2catStefan Rinkes2020-12-021-0/+1
| | | | | | | Otherwise the build fails at odd hours of the day. Signed-off-by: Stefan Rinkes <stefan.rinkes@gmail.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* driver: do not allow compiler to reload PacketSizeJason A. Donenfeld2020-11-091-1/+1
| | | | | | | | In theory, the compiler could reload PacketSize after the bounds check but before it's passed to NdisAllocateNetBufferAndNetBufferList. In practice, it's not actually doing that, but better safe than sorry. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* driver: move to subfolderSimon Rozman2020-11-066-0/+1831
Signed-off-by: Simon Rozman <simon@rozman.si>