aboutsummaryrefslogtreecommitdiffstats
path: root/conn (follow)
Commit message (Collapse)AuthorAgeFilesLines
* conn: linux: protect read fdsJason A. Donenfeld2021-05-201-12/+18
| | | | | | | | | The -1 protection was removed and the wrong error was returned, causing us to read from a bogus fd. As well, remove the useless closures that aren't doing anything, since this is all synchronized anyway. Fixes: 10533c3 ("all: make conn.Bind.Open return a slice of receive functions") Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: windows: set count=0 on retryJason A. Donenfeld2021-05-111-0/+1
| | | | | | | | When retrying, if count is not 0, we forget to dequeue another request, and so the ring fills up and errors out. Reported-by: Sascha Dierberg <dierberg@dresearch-fe.de> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: windows: do not error out when receiving UDP jumbogramJason A. Donenfeld2021-04-261-2/+14
| | | | | | | | | | | | If we receive a large UDP packet, don't return an error to receive.go, which then terminates the receive loop. Instead, simply retry. Considering Winsock's general finickiness, we might consider other places where an attacker on the wire can generate error conditions like this. Reported-by: Sascha Dierberg <sascha.dierberg@gmail.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: reconstruct v4 vs v6 receive function based on symtabJason A. Donenfeld2021-04-123-13/+66
| | | | | | This is kind of gross but it's better than the alternatives. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: windows: reset ring to starting position after freeJason A. Donenfeld2021-04-091-0/+3
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: windows: compare head and tail properlyJason A. Donenfeld2021-04-091-1/+1
| | | | | | | | By not comparing these with the modulo, the ring became nearly never full, resulting in completion queue buffers filling up prematurely. Reported-by: Joshua Sjoding <joshua.sjoding@scjalliance.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* winrio: test that IOCP-based RIO is supportedJason A. Donenfeld2021-04-091-1/+9
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* all: make conn.Bind.Open return a slice of receive functionsJosh Bleecher Snyder2021-04-025-122/+126
| | | | | | | | | | | | | | | | | Instead of hard-coding exactly two sources from which to receive packets (an IPv4 source and an IPv6 source), allow the conn.Bind to specify a set of sources. Beneficial consequences: * If there's no IPv6 support on a system, conn.Bind.Open can choose not to return a receive function for it, which is simpler than tracking that state in the bind. This simplification removes existing data races from both conn.StdNetBind and bindtest.ChannelBind. * If there are more than two sources on a system, the conn.Bind no longer needs to add a separate muxing layer. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
* conn: winrio: pass key parameter into structJason A. Donenfeld2021-04-021-0/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: document retry loop in StdNetBind.OpenJosh Bleecher Snyder2021-03-301-0/+3
| | | | | | It's not obvious on a first read what the loop is doing. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
* conn: use local ipvN vars in StdNetBind.OpenJosh Bleecher Snyder2021-03-301-11/+9
| | | | | | | | | This makes it clearer that they are fresh on each attempt, and avoids the bookkeeping required to clearing them on failure. Also, remove an unnecessary err != nil. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
* conn: unify code in StdNetBind.SendJosh Bleecher Snyder2021-03-301-14/+13
| | | | | | | The sending code is identical for ipv4 and ipv6; select the conn, then use it. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
* conn: linux: unexport mutexJason A. Donenfeld2021-03-081-9/+9
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: implement RIO for fast Windows UDP socketsJason A. Donenfeld2021-02-255-60/+827
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* device: test up/down using virtual connJason A. Donenfeld2021-02-231-0/+136
| | | | | | This prevents port clashing bugs. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: make binds replacableJason A. Donenfeld2021-02-238-119/+137
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: bump to 1.16 and get rid of NetErrClosed hackJason A. Donenfeld2021-02-162-17/+4
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: close old fd before trying againJason A. Donenfeld2021-02-102-0/+2
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: use errors.Is for unwrappingJason A. Donenfeld2021-02-091-16/+4
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: try harder to have v4 and v6 ports agreeJason A. Donenfeld2021-02-092-0/+14
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: bump copyrightJason A. Donenfeld2021-01-288-8/+8
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: fix interface parameter name in Bind interface docsBrad Fitzpatrick2021-01-261-1/+1
| | | | Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
* device: allow compiling with Go 1.15Jason A. Donenfeld2021-01-202-4/+17
| | | | | | | | | Until we depend on Go 1.16 (which isn't released yet), alias our own variable to the private member of the net package. This will allow an easy find replace to make this go away when we eventually switch to 1.16. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: remove _ method receiverJosh Bleecher Snyder2021-01-201-1/+1
| | | | | | Minor style fix. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
* device: receive: do not exit immediately on transient UDP receive errorsJason A. Donenfeld2021-01-081-4/+4
| | | | | | | | | | | | | | | | Some users report seeing lines like: > Routine: receive incoming IPv4 - stopped Popping up unexpectedly. Let's sleep and try again before failing, and also log the error, and perhaps we'll eventually understand this situation better in future versions. Because we have to distinguish between the socket being closed explicitly and whatever error this is, we bump the module to require Go 1.16. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: linux: do not allow ReceiveIPvX to race with CloseJason A. Donenfeld2021-01-071-17/+32
| | | | | | | If Close is called after ReceiveIPvX, then ReceiveIPvX will block on an invalid or potentially reused fd. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: do not SO_REUSEADDR on linuxJason A. Donenfeld2021-01-071-19/+0
| | | | | | SO_REUSEADDR does not make sense for unicast UDP sockets. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: add comments saying what uses these interfacesDavid Crawshaw2020-06-221-2/+5
| | | | Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
* conn: unbreak boundif on androidJason A. Donenfeld2020-06-072-0/+41
| | | | | | Another thing never tested ever. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: remove useless commentJason A. Donenfeld2020-06-071-1/+0
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: fix windows situation with boundifJason A. Donenfeld2020-06-071-4/+4
| | | | | | This was evidently never tested before committing. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: update header comments and modulesJason A. Donenfeld2020-05-026-6/+6
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn: introduce new package that splits out the Bind and Endpoint typesDavid Crawshaw2020-05-026-0/+985
The sticky socket code stays in the device package for now, as it reaches deeply into the peer list. This is the first step in an effort to split some code out of the very busy device package. Signed-off-by: David Crawshaw <crawshaw@tailscale.com>