summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
2016-08-08ratelimiter: do not require IPv6Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-08-08tests: use makefile and expand greatlyJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-08-08persistent-keepalive: change range to [1,65535]Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-08-03Kbuild: move module deps out of tests/Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-08-02selftest: move to subfolderJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-08-02contrib: move patchers to contrib/kernel-treeJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-08-02Makefile: check tools as part of make checkJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-08-02uapi: typeof is not necessaryJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-08-02c: specify static array size in function paramsJason A. Donenfeld
The C standard states: A declaration of a parameter as ``array of type'' shall be adjusted to ``qualified pointer to type'', where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation. If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as many elements as specified by the size expression. By changing void func(int array[4]) to void func(int array[static 4]), we automatically get the compiler checking argument sizes for us, which is quite nice. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-08-02timers: use more clear pow macroJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-23ratelimiter: correct commentJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-23timers: upstream removed the slack conceptJason A. Donenfeld
No longer do we specify slack ourselves. Instead we need to add it directly in the main scheduling. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-22tools: Use seqpacket instead of dgramJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-22index hashtable: run random indices through siphashJason A. Donenfeld
If /dev/urandom is a NOBUS RNG backdoor, like the infamous Dual_EC_DRBG, then sending 4 bytes of raw RNG output over the wire directly might not be such a great idea. This mitigates that vulnerability by, at some point before the indices are generated, creating a random secret. Then, for each session index, we simply run SipHash24 on an incrementing counter. This is probably overkill because /dev/urandom is probably not a backdoored RNG, and itself already uses several rounds of SHA-1 for mixing. If the kernel RNG is backdoored, there may very well be bigger problems at play. Four bytes is also not so many bytes. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-22cookie: do not expose csprng directlyJason A. Donenfeld
It may not be wise to directly publish the output of the CSPRNG, so we run the output through a round of Blake2s first. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-22socket: fix compat for 4.1 v6 socketsJason A. Donenfeld
It turns out 4.1 is even more broken than expected. While both 4.1 and 4.2 need to jigger the sysctl nob temporarily, it turns out that in 4.1 it's looking in the wrong namespace for the nob value. So, we have to account for the different namespace semantics in the different versions. Super ugly. But, all this code goes away once we upstream. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-21socket: reset IPv4 socket to NULL after freeJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-21socket: simpler debug messageJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-21Kconfig: select IP6_NF_IPTABLES if using IPV6Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-20tools: first additions of userspace integrationJason A. Donenfeld
This is designed to work with a server that follows this: struct sockaddr_un addr = { .sun_family = AF_UNIX, .sun_path = "/var/run/wireguard/wguserspace0.sock" }; int fd, ret; ssize_t len; socklen_t socklen; struct wgdevice *device; fd = socket(AF_UNIX, SOCK_DGRAM, 0); if (fd < 0) exit(1); if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) exit(1); for (;;) { /* First we look at how big the next message is, so we know how much to * allocate. Note on BSD you can instead use ioctl(fd, FIONREAD, &len). */ len = recv(fd, NULL, 0, MSG_PEEK | MSG_TRUNC); if (len < 0) { handle_error(); continue; } /* Next we allocate a buffer for the received data. */ device = NULL; if (len) { device = malloc(len); if (!device) { handle_error(); continue; } } /* Finally we receive the data, storing too the return address. */ socklen = sizeof(addr); len = recvfrom(fd, device, len, 0, (struct sockaddr *)&addr, (socklen_t *)&socklen); if (len < 0) { handle_error(); free(device); continue; } if (!len) { /* If len is zero, it's a "get" request, so we send our device back. */ device = get_current_wireguard_device(&len); sendto(fd, device, len, 0, (struct sockaddr *)&addr, socklen); } else { /* Otherwise, we just received a wgdevice, so we should "set" and send back the return status. */ ret = set_current_wireguard_device(device); sendto(fd, &ret, sizeof(ret), 0, (struct sockaddr *)&addr, socklen); free(device); } } Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-18build system: revamp building and configurationJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-18tests: improve test suite and add qemu testerJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-10receive: assume we usually succeed with userspaceJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-10receive: no need to test for !lenJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-10timers: apply slack to hotpath timersJason A. Donenfeld
For timers in the hotpath, we don't want them to be rescheduled so aggressively, and since they don't need to be that precise, we can set a decent amount of slack. With the persistent keepalive timer, we have something of a special case. Since the timeout isn't fixed like the others, we don't want to make it more often than the kernel ordinarily would. So, instead, we make it a minimum. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-10timers: move timer calls out of hot loopJason A. Donenfeld
We sacrifice a little bit of precision here, but this avoids jockeying around the timers for every packet, when we're sending in bundles anyway to minimize cache misses. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-10timers: document conditions for callingJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-10persistent keepalive: use unsigned long to avoid multiplication in hotpathJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-10persistent keepalive: use authenticated keepalivesJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-08keepalives: only queue keepalive when queue is emptyJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-08timers: do not consider keepalives to be data sentJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-08timers: rename *authorized* functions to *authenticated*Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-08persistent keepalive: start sending immediatelyJason A. Donenfeld
Rather than only start sending the persistent keepalive packets when the device first sends data, this changes it to send the packets immediately on `ip link set up`. This makes things generally seem more stateless, since the administrator does not have to manually ping the endpoint. Of course, if you have a lot of peers and all of them have persistent keepalive enabled, this could cause a lot of unwanted immediate traffic. On the other hand, if all of those peers are at some point going to be sending packets, this would happen anyway. I suppose the moral of the story is that persistent keepalive is a feature really just for clients behind NAT, not for servers, and it should be used sparingly, which is why we've set it off by default in the first place. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-08persistent keepalive: add kernel mechanismJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-07curve25519: unneeded zeros variableJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-05device: move unlikely check to if clauseJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-03receive: protect against impossible conditionsJason A. Donenfeld
It should never be the case that skb->head + skb->transport_header - skb->data is greater than 2^16, but in case the kernel network stack borks this at some point in the future, we don't want this to slyly introduce a vulnerability into WireGuard. Further, really smart compilers might be able to make deductions about data_offset, and optimize accordingly. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-02tai64n: don't forget to add 2^62, to be in specJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-07-01receive: error conditions are unlikelyJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-30Readme: the documentation moved to .ioJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-30Readme: use https instead of httpDaniel Kahn Gillmor
For the websites referenced that offer https instead of http, use https. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-30Makefile: Add more verbose dependency errorsJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-30device init: free wq after padataJason A. Donenfeld
The padata free functions make reference to their parent workqueue, so it's important that we wait to free the workqueue after the padata. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-29chacha20poly1305: use more standard way of testing FPU featuresJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-29device: remove updating of trans_startJason A. Donenfeld
Per http://lists.openwall.net/netdev/2016/05/03/87 dev->trans_start has been removed, and updates are now supposed to be handled with netif_trans_update, which now updates the particular txqueue's trans_start instead. However, netdev_start_xmit already updates this member after calling ndo_start_xmit, so the new netif_trans_update function smartly makes the comment that for drivers that don't use LLTX, it's not neccessary to call netif_trans_update. Except we do use LLTX, so it would seem again that we do need to be calling netif_trans_update. However, glancing at drivers like vxlan and other similar virtual tunnels, this doesn't seem to be the case. I suspect the reason is that we both also set IFF_NO_QUEUE, so we aren't even using a txqueue for updating. Thus, this patch removes updating of trans_start all together. I believe this should be okay for older kernels too. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-29Kconfig patching: do not match on NETFILTERJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-29Kconfig: more fully select dependenciesJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-25tests: make fatalJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-25nonce: switch to RFC6479 to better support packet reorderingJason A. Donenfeld
With packets hitting multiple cores, a 64bit backtrack was too small. This algorithm increases our backtrack to 1984bits. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2016-06-25Initial commitJason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>