aboutsummaryrefslogtreecommitdiffstats
path: root/tun/tun.go (follow)
Commit message (Collapse)AuthorAgeFilesLines
* global: buff -> bufJason A. Donenfeld2023-03-131-5/+5
| | | | | | This always struck me as kind of weird and non-standard. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* conn, device, tun: implement vectorized I/O plumbingJordan Whited2023-03-101-8/+32
| | | | | | | | | | | | | | | | | | | | Accept packet vectors for reading and writing in the tun.Device and conn.Bind interfaces, so that the internal plumbing between these interfaces now passes a vector of packets. Vectors move untouched between these interfaces, i.e. if 128 packets are received from conn.Bind.Read(), 128 packets are passed to tun.Device.Write(). There is no internal buffering. Currently, existing implementations are only adjusted to have vectors of length one. Subsequent patches will improve that. Also, as a related fixup, use the unix and windows packages rather than the syscall package when possible. Co-authored-by: James Tucker <james@tailscale.com> Signed-off-by: James Tucker <james@tailscale.com> Signed-off-by: Jordan Whited <jordan@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* tun: guard Device.Events() against chan writesJordan Whited2023-02-091-1/+1
| | | | | Signed-off-by: Jordan Whited <jordan@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: bump copyright yearJason A. Donenfeld2023-02-071-1/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: bump copyright yearJason A. Donenfeld2022-09-201-1/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: bump copyrightJason A. Donenfeld2021-01-281-1/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: update header comments and modulesJason A. Donenfeld2020-05-021-1/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* tun: remove TUN prefix from types to reduce stutter elsewhereMatt Layher2019-06-141-6/+6
| | | | Signed-off-by: Matt Layher <mdlayher@gmail.com>
* receive: implement flush semanticsJason A. Donenfeld2019-03-211-0/+1
|
* wintun: Use native Win32 API for I/OSimon Rozman2019-03-211-13/+0
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: allow special methods in NativeTunJason A. Donenfeld2019-03-011-1/+1
|
* tun: use netpoll instead of rwcancelJason A. Donenfeld2019-02-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new sysconn function of Go 1.12 makes this possible: package main import "log" import "os" import "unsafe" import "time" import "syscall" import "sync" import "golang.org/x/sys/unix" func main() { fd, err := os.OpenFile("/dev/net/tun", os.O_RDWR, 0) if err != nil { log.Fatal(err) } var ifr [unix.IFNAMSIZ + 64]byte copy(ifr[:], []byte("cheese")) *(*uint16)(unsafe.Pointer(&ifr[unix.IFNAMSIZ])) = unix.IFF_TUN var errno syscall.Errno s, _ := fd.SyscallConn() s.Control(func(fd uintptr) { _, _, errno = unix.Syscall( unix.SYS_IOCTL, fd, uintptr(unix.TUNSETIFF), uintptr(unsafe.Pointer(&ifr[0])), ) }) if errno != 0 { log.Fatal(errno) } b := [4]byte{} wait := sync.WaitGroup{} wait.Add(1) go func() { _, err := fd.Read(b[:]) log.Print("Read errored: ", err) wait.Done() }() time.Sleep(time.Second) log.Print("Closing") err = fd.Close() if err != nil { log.Print("Close errored: " , err) } wait.Wait() log.Print("Exiting") }
* tun: use sysconn instead of .Fd with Go 1.12Jason A. Donenfeld2019-02-271-1/+16
|
* Update copyrightJason A. Donenfeld2019-02-051-2/+2
|
* global: fix up copyright headersJason A. Donenfeld2018-09-161-2/+1
|
* Move tun to subpackageJason A. Donenfeld2018-05-231-0/+27