Commit Graph

103 Commits

Author SHA1 Message Date
Matthias Frei
aaa1db679c internal/socket: support MSG_DONTWAIT
Explicitly handle MSG_DONTWAIT in read and send calls on platforms where this is defined, to get the per-call non-blocking behavior as would be expected when calling readmsg/sendmsg in C.
When MSG_DONTWAIT is set, we always return true from the function passed to syscall.RawConn.Read/Write, to avoid entering the polling state.

Fixes golang/go#46891

Change-Id: I4809577477554db1c45b6f4825a03d98208199d7
GitHub-Last-Rev: 4022e9b52c
GitHub-Pull-Request: golang/net#108
Reviewed-on: https://go-review.googlesource.com/c/net/+/333469
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
2021-08-05 18:22:04 +00:00
Matthias Frei
0287a6fb41 internal/socket: handle nil addr in sendMsgs
With the pool to reuse internal allocations for mmsghdrs introduced in
CL 315589, I've accidentally introduced a regression for sending
messages on dialed connections.
Calling sendMsgs with Messages with a nil address would panic during
(*msghdr).pack at msghdr_linux.go:18 when taking address of first
element of 0-sized buffer.
Handle this case by explicitly resetting the Name/Namelen.

Add test cases for writing to connected sockets.

Change-Id: I6d5dac696b7ab103a5290675c56002ede3e7b576
GitHub-Last-Rev: 4be010d03a
GitHub-Pull-Request: golang/net#103
Reviewed-on: https://go-review.googlesource.com/c/net/+/316712
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-05-05 02:47:14 +00:00
Matthias Frei
f8dd838d8c internal/socket: reuse buffers in recv/sendMsgs
Use a pool to reuse internally allocated temporary buffers, i.e. the
mmsghdrs structures and the associated iovecs and sockaddr buffers.

The temporary buffers obtained from the pool are re-allocated when their
sizes are not sufficient for the current call.
The (hopefully reasonable) assumption is that RecvMsgs and SendMsgs are
called with a somewhat uniform number of Messages/Buffers. If not, the
buffers in the pool will likely be re-allocated a few times until they
reach the size required for the "biggest" caller.

This pooling can significantly reduce the temporary allocations made in
recv/sendMsgs. While the effectiveness of this change clearly depends
on the usage pattern, pressure on the GC, etc., some improvements can
already be observed in the micro-benchmark BenchmarkUDP: the number and
size of allocations per iteration decreases significantly and there is a
small but noticable improvement in time per iteration.

```
name             old time/op    new time/op    delta
UDP/Iter-1-8       5.50µs ± 2%    5.46µs ± 2%     ~     (p=0.055 n=20+20)
UDP/Batch-1-8      5.65µs ± 3%    5.56µs ± 4%   -1.68%  (p=0.011 n=20+20)
UDP/Iter-2-8       11.0µs ± 3%    11.0µs ± 3%     ~     (p=0.645 n=20+20)
UDP/Batch-2-8      8.40µs ± 3%    8.24µs ± 5%   -1.87%  (p=0.012 n=20+20)
UDP/Iter-4-8       22.0µs ± 1%    21.9µs ± 3%     ~     (p=0.437 n=17+20)
UDP/Batch-4-8      13.3µs ± 2%    12.7µs ± 2%   -4.69%  (p=0.000 n=20+20)
UDP/Iter-8-8       44.2µs ± 3%    44.0µs ± 2%     ~     (p=0.551 n=20+20)
UDP/Batch-8-8      24.2µs ± 4%    23.1µs ± 4%   -4.65%  (p=0.000 n=20+20)
UDP/Iter-16-8      87.9µs ± 4%    88.1µs ± 3%     ~     (p=0.708 n=19+20)
UDP/Batch-16-8     45.6µs ± 4%    44.1µs ± 5%   -3.12%  (p=0.000 n=20+20)
UDP/Iter-32-8       175µs ± 4%     176µs ± 4%     ~     (p=0.087 n=20+20)
UDP/Batch-32-8     87.9µs ± 1%    84.5µs ± 6%   -3.78%  (p=0.000 n=19+19)
UDP/Iter-64-8       353µs ± 3%     352µs ± 3%     ~     (p=0.414 n=20+20)
UDP/Batch-64-8      172µs ± 4%     172µs ±11%     ~     (p=0.157 n=20+20)
UDP/Iter-128-8      705µs ± 3%     699µs ± 4%     ~     (p=0.142 n=20+20)
UDP/Batch-128-8     345µs ± 2%     343µs ± 6%     ~     (p=0.134 n=20+20)
UDP/Iter-256-8     1.41ms ± 3%    1.41ms ± 4%     ~     (p=0.758 n=20+20)
UDP/Batch-256-8     692µs ± 4%     685µs ± 4%     ~     (p=0.114 n=20+20)
UDP/Iter-512-8     2.82ms ± 2%    2.81ms ± 2%     ~     (p=0.820 n=20+20)
UDP/Batch-512-8    1.27ms ± 3%    0.75ms ± 6%  -40.62%  (p=0.000 n=20+20)

name             old alloc/op   new alloc/op   delta
UDP/Iter-1-8         408B ± 0%      424B ± 0%   +3.92%  (p=0.000 n=20+20)
UDP/Batch-1-8        440B ± 0%      232B ± 0%  -47.27%  (p=0.000 n=20+20)
UDP/Iter-2-8         816B ± 0%      848B ± 0%   +3.92%  (p=0.000 n=20+20)
UDP/Batch-2-8        696B ± 0%      280B ± 0%  -59.77%  (p=0.000 n=20+20)
UDP/Iter-4-8       1.63kB ± 0%    1.70kB ± 0%   +3.92%  (p=0.000 n=20+20)
UDP/Batch-4-8      1.22kB ± 0%    0.38kB ± 0%  -68.42%  (p=0.000 n=20+20)
UDP/Iter-8-8       3.26kB ± 0%    3.39kB ± 0%   +3.92%  (p=0.000 n=20+20)
UDP/Batch-8-8      2.26kB ± 0%    0.59kB ± 0%  -73.76%  (p=0.000 n=20+20)
UDP/Iter-16-8      6.53kB ± 0%    6.78kB ± 0%   +3.92%  (p=0.000 n=20+20)
UDP/Batch-16-8     4.34kB ± 0%    1.01kB ± 0%  -76.75%  (p=0.000 n=20+20)
UDP/Iter-32-8      13.1kB ± 0%    13.6kB ± 0%   +3.92%  (p=0.000 n=20+20)
UDP/Batch-32-8     8.50kB ± 0%    1.84kB ± 0%  -78.34%  (p=0.000 n=20+18)
UDP/Iter-64-8      26.1kB ± 0%    27.1kB ± 0%   +3.92%  (p=0.000 n=20+20)
UDP/Batch-64-8     16.8kB ± 0%     3.5kB ± 0%  -79.16%  (p=0.000 n=20+20)
UDP/Iter-128-8     52.2kB ± 0%    54.3kB ± 0%   +3.92%  (p=0.000 n=20+20)
UDP/Batch-128-8    33.5kB ± 0%     6.8kB ± 0%  -79.56%  (p=0.000 n=20+16)
UDP/Iter-256-8      104kB ± 0%     109kB ± 0%   +3.92%  (p=0.000 n=20+17)
UDP/Batch-256-8    66.7kB ± 0%    13.5kB ± 0%  -79.77%  (p=0.000 n=20+20)
UDP/Iter-512-8      209kB ± 0%     217kB ± 0%   +3.92%  (p=0.000 n=20+20)
UDP/Batch-512-8     121kB ± 0%      15kB ± 0%  -87.89%  (p=0.000 n=20+20)

name             old allocs/op  new allocs/op  delta
UDP/Iter-1-8         14.0 ± 0%      14.0 ± 0%     ~     (all equal)
UDP/Batch-1-8        14.0 ± 0%       8.0 ± 0%  -42.86%  (p=0.000 n=20+20)
UDP/Iter-2-8         28.0 ± 0%      28.0 ± 0%     ~     (all equal)
UDP/Batch-2-8        20.0 ± 0%      10.0 ± 0%  -50.00%  (p=0.000 n=20+20)
UDP/Iter-4-8         56.0 ± 0%      56.0 ± 0%     ~     (all equal)
UDP/Batch-4-8        32.0 ± 0%      14.0 ± 0%  -56.25%  (p=0.000 n=20+20)
UDP/Iter-8-8          112 ± 0%       112 ± 0%     ~     (all equal)
UDP/Batch-8-8        56.0 ± 0%      22.0 ± 0%  -60.71%  (p=0.000 n=20+20)
UDP/Iter-16-8         224 ± 0%       224 ± 0%     ~     (all equal)
UDP/Batch-16-8        104 ± 0%        38 ± 0%  -63.46%  (p=0.000 n=20+20)
UDP/Iter-32-8         448 ± 0%       448 ± 0%     ~     (all equal)
UDP/Batch-32-8        200 ± 0%        70 ± 0%  -65.00%  (p=0.000 n=20+20)
UDP/Iter-64-8         896 ± 0%       896 ± 0%     ~     (all equal)
UDP/Batch-64-8        392 ± 0%       134 ± 0%  -65.82%  (p=0.000 n=20+20)
UDP/Iter-128-8      1.79k ± 0%     1.79k ± 0%     ~     (all equal)
UDP/Batch-128-8       776 ± 0%       262 ± 0%  -66.24%  (p=0.000 n=20+20)
UDP/Iter-256-8      3.58k ± 0%     3.58k ± 0%     ~     (all equal)
UDP/Batch-256-8     1.54k ± 0%     0.52k ± 0%  -66.45%  (p=0.000 n=20+20)
UDP/Iter-512-8      7.17k ± 0%     7.17k ± 0%     ~     (all equal)
UDP/Batch-512-8     2.61k ± 0%     0.56k ± 0%  -78.48%  (p=0.000 n=20+20)
```

Fixes golang/go#26838

Change-Id: Id34e362737455cd48df5bc751426be49fbc28094
GitHub-Last-Rev: 4e33d507bb
GitHub-Pull-Request: golang/net#102
Reviewed-on: https://go-review.googlesource.com/c/net/+/315589
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-05-01 22:26:12 +00:00
Ben Hutchings
e997de6604 internal/socket: add ppc system call definitions, for use with gccgo
Add system call definitions for 32-bit PowerPC (ppc). These are
expected to be used with gccgo, as gc does not have a suitable code
generator.

* Define the system call numbers for recvmmsg() and sendmmsg()
* Enable the 32-bit definitions of cmsghdr, iovec, and msghdr structures
* Add the structure definitions generated by godefs

This has been tested with a program that listens for UDP connections
and then sends back multiple messages with PacketConn.WriteBatch.

Fixes golang/go#45677

Change-Id: Idd7bbcfcea373db674759d3cb86aab60312403dc
GitHub-Last-Rev: dfc1dfce61
GitHub-Pull-Request: golang/net#101
Reviewed-on: https://go-review.googlesource.com/c/net/+/312710
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-23 17:40:36 +00:00
Ian Lance Taylor
4e50805a07 internal/socket: use larger buffers in race test
The race detector doesn't seem to track races at the byte level.
Use a larger buffer to make the test more reliable.

Fixes golang/go#37338

Change-Id: I275db68a5c206b58c3bc48b9f5c1e22ee1aff176
Reviewed-on: https://go-review.googlesource.com/c/net/+/312529
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-21 23:01:15 +00:00
Tobias Klauser
2554d15bf5 internal/socket: use SizeofSockaddrInet{4,6} constants from x/sys/unix
Use the SizeofSockaddrInet4 and SizeofSockaddrInet6 constants defined in
the golang.org/x/sys/unix package instead of locally duplicating them.

Change-Id: I7e7ea9ec6e81a0af70bbf5c7e91f61a0662228ff
Reviewed-on: https://go-review.googlesource.com/c/net/+/312489
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-21 22:37:29 +00:00
Ian Lance Taylor
e915ea6b2b internal/socket: more logging for TestRace
For golang/go#37338

Change-Id: I00c222ee15bce07438ac56c0dfe4770897eccbbd
Reviewed-on: https://go-review.googlesource.com/c/net/+/310269
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-15 23:10:46 +00:00
Marten Seemann
a5a99cb37e internal/socket: use interface not type assertions to infer a wrapped net.Conn's kind
When passing a wrapped connection to ipv{4,6}.NewPacketConn, calls to
ReadBatch will fail with an invalid connection error. This is because
NewConn performs a type assertion to determine the type (TCP, UDP, IP)
of the net.Conn.
In order to allow for wrapped connections to be passed to NewConn, we
can use an interface assertion that checks for methods on the net.Conn
that are unique to TCP, UDP and IP.

Fixes golang/go#42444.

Change-Id: I07cdb037829643f5cf4cd77105a772fcff8c4b2a
Reviewed-on: https://go-review.googlesource.com/c/net/+/271927
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
2021-04-05 18:03:19 +00:00
Tobias Klauser
08027d57d8 internal/socket: skip known flaky TestRace
This test keeps flaking on almost every TryBot run. Skip it for now.

For golang/go#37338

Change-Id: I77cdd782f3bc164ec11894683aa50c3441807ba5
Reviewed-on: https://go-review.googlesource.com/c/net/+/303910
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-23 14:18:57 +00:00
Tobias Klauser
3d97a244fc internal/socket: check for EWOULDBLOCK on all platforms
Don't make the check for EWOULDBLOCK zos-specific. Most platforms define
EAGAIN and EWOULDBLOCK with the same underlying value. Thus, the
additional check will be a no-op on them. On platforms where EAGAIN and
EWOULDBLOCK have different underlying values, we probably want to check
both as well.

As pointed out by Michael Munday in CL 264028.

Change-Id: Id3404fc4440c66a3484975b4c94b4ebb788b80a1
Reviewed-on: https://go-review.googlesource.com/c/net/+/295569
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-24 08:20:22 +00:00
Russ Cox
5f55cee0dc all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I5b2b7d93424e828a3c5f76ae3f30ab825aca388e
Reviewed-on: https://go-review.googlesource.com/c/net/+/294371
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-20 03:31:24 +00:00
Tobias Klauser
c7110b5ffc internal/socket: add support for openbsd/mips64
For golang/go#40995

Change-Id: I415ce04a3fb419de933ab4bb5d2afbacbbaff80c
Reviewed-on: https://go-review.googlesource.com/c/net/+/274772
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
2020-12-02 16:19:06 +00:00
billofarrell
146b70c837 all: add support for zos/s390x
This adds net support for zos/s390x. These changes should not affect other platforms.

Fixes golang/go#42130

Change-Id: Ia7faa29de76b7c5713120657b296106c2e27bfd2
Reviewed-on: https://go-review.googlesource.com/c/net/+/264028
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-10-26 09:15:29 +00:00
Tobias Klauser
0a1ea396d5 internal/socket: use Cmsg{Len,Space} from golang.org/x/sys/unix
Instead of duplicating the logic for cmsg alignment, use CmsgLen and
CmsgSpace from golang.org/x/sys/unix. Moreover, this should simplify
adding new ports.

Change-Id: Ic3ac9cf14781eff5b8e4f34bfd2b1c8bd3b69341
Reviewed-on: https://go-review.googlesource.com/c/net/+/259058
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2020-10-02 20:24:02 +00:00
Tobias Klauser
4acb6c075d internal/socket: use correct cmsg alignment for netbsd/arm64
netbsd/arm64 requires 128-bit alignment for cmsgs.

Change-Id: I8e45e7d7f6b09d3c128d932dc5a73e3f2bd3a269
Reviewed-on: https://go-review.googlesource.com/c/net/+/258377
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2020-09-30 14:50:03 +00:00
Tobias Klauser
05aa5d4ee3 internal/socket, route: drop support for pre-1.12 direct syscalls on darwin
Go 1.12 and newer are using libSystem for syscalls on darwin.
Go 1.11 is the last release to use direct syscalls. It hasn't been
supported since the release of Go 1.13 in September 2019, so drop
support for direct syscalls on darwin from golang.org/x/net.

Change-Id: Ib53d64e8a6d12ad702951f8efc123ce92c01c4d9
Reviewed-on: https://go-review.googlesource.com/c/net/+/257057
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-25 08:00:53 +00:00
Emmanuel T Odeke
d06c31c94c internal/socket: pass race detection if CGO is not enabled
Follows up CL 205461 by recognizing that -race cannot
run if CGO is not enabled, hence won't broadly fail
the test.

Fixes golang/go#35668

Change-Id: I6a47e6fc7c4afd0bf225fc9876c96b29efa863ce
Reviewed-on: https://go-review.googlesource.com/c/net/+/207677
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-11-18 18:34:10 +00:00
Keith Randall
2180aed223 internal/socket: tell race detector about syscall reads and writes
The syscalls that send and receive messages write to buffers provided
by the user. The race detector can't see those reads and writes by
default (they are done by the kernel), so we need to tell the race
detector explicitly about them.

Fixes golang/go#35329

Change-Id: Ibf4ef1b937535c4834aa9eeb744722d91f669a27
Reviewed-on: https://go-review.googlesource.com/c/net/+/205461
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-11-12 18:23:07 +00:00
JP Sugarbroad
daa7c04131 internal/timeseries: avoid storing numbers as durations
... even if it does avoid a cast. advance isn't a duration and shouldn't be typed that way.

Change-Id: I6328188e74010d6c57adf5b26beede57b3bc7e33
GitHub-Last-Rev: 281097649e
GitHub-Pull-Request: golang/net#29
Reviewed-on: https://go-review.googlesource.com/c/net/+/161297
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-11-09 02:19:31 +00:00
Tobias Klauser
24d2ffbea1 all: fix tests on dragonfly after ABI changes
Detect the ABI version based on kern.osreldate.

Only use 32-bit cmsg alignment for versions before the September 2019
ABI changes:
http://lists.dragonflybsd.org/pipermail/users/2019-September/358280.html

Use RTM_VERSION 7 on Dragonfly master (5.8 release).

Determine sizeof struct ifa_msghdr at runtime based on the ABI version.

Temporarily skip some test relying on the net package which will only be
fixed once this CL is re-vendored into std.

Updates golang/go#34368

Change-Id: I732fab21d569b303f45dfb6a0bbbb11469511a07
Reviewed-on: https://go-review.googlesource.com/c/net/+/202317
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-21 12:47:07 +00:00
Tobias Klauser
c8589233b7 internal/socket: remove unused sizeofMmsghdr const
Change-Id: I6f66e2fd93916438ad959de469ee081b7085fe1a
Reviewed-on: https://go-review.googlesource.com/c/net/+/195597
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-16 14:08:28 +00:00
Ainar Garipov
a7b16738d8 all: fix typos
Change-Id: I86005e1f17747e4ffe4fc544546e980b987bad36
Reviewed-on: https://go-review.googlesource.com/c/net/+/193799
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-09 00:30:24 +00:00
Tobias Klauser
3b0461eec8 internal/socket, ipv4, ipv6: add support for GOOS=illumos
Treat it like GOOS=solaris for now.

Change-Id: I2b99427e80058f6c7308fe3752de21610457a3ba
Reviewed-on: https://go-review.googlesource.com/c/net/+/183277
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2019-06-20 20:02:07 +00:00
Tobias Klauser
d28f0bde59 all: follow convention for generated code comment
Follow the convertion (https://golang.org/s/generatedcode) for generated
code.

Change-Id: I3101fb91db42644ead179ffaeffe0211359ac886
Reviewed-on: https://go-review.googlesource.com/c/net/+/182137
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-13 19:41:53 +00:00
Tobias Klauser
3f473d35a3 internal/socket: add support for freebsd/arm64
Updates golang/go#24715

Change-Id: I4e87b6101069eb9ff745fdfac6d4f6b4884a995c
Reviewed-on: https://go-review.googlesource.com/c/net/+/181618
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-11 14:12:13 +00:00
Tobias Klauser
dbab0cf9d9 internal/socket: add support for openbsd/arm64
Updates golang/go#31656

Change-Id: I238655c111e8422c60d20d853aeb965be16c1c7e
Reviewed-on: https://go-review.googlesource.com/c/net/+/181617
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-11 14:11:12 +00:00
Tobias Klauser
60506f45cf internal/socket: add support for netbsd/arm64
Updates golang/go#30824

Change-Id: I872b725d6640e29570652171b6c45634fc21a461
Reviewed-on: https://go-review.googlesource.com/c/net/+/179939
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-06-03 09:10:49 +00:00
Tobias Klauser
f3200d17e0 internal/socket: remove leftover AF_* and SOCK_RAW constants on aix
Follow-up for CL 53310 which changed internal/socket to use these
constants from golang.org/x/sys/unix

Change-Id: I40fde84c875995fbeef2d21f8e05f5ba27b11098
Reviewed-on: https://go-review.googlesource.com/c/net/+/178557
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-22 15:58:17 +00:00
Tobias Klauser
fa69b94a3b internal/socket: use AF_* and SOCK_RAW constants from x/sys
Use the AF_UNSPEC, AF_INET, AF_INET6 and SOCK_RAW constants from
golang.org/x/sys instead of locally deriving them from the C headers (or
hard coding them in the case of Windows).

Change-Id: I37fe61d0435b6c615cd767eef38380db4b4af7b1
Reviewed-on: https://go-review.googlesource.com/c/net/+/53310
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-22 13:53:03 +00:00
CarlosEDP
018c4d40a1 ipv4, ipv6, internal/socket: add riscv64 support
Updates golang/go#27532

Change-Id: I64285280680e5d1d3903c352454f2c67cc653c88
GitHub-Last-Rev: 3747f61487
GitHub-Pull-Request: golang/net#43
Reviewed-on: https://go-review.googlesource.com/c/net/+/177997
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-05-20 21:01:07 +00:00
chigotc
457ff44d03 internal/socket: add port for aix/ppc64
This commit adds support for aix/ppc64 in internal/socket, for both
gccgo and gc.

Change-Id: Ic607e45d73be49cd0ed3ca4f60a967c306602367
Reviewed-on: https://go-review.googlesource.com/c/net/+/170557
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.public.networking@gmail.com>
2019-04-19 01:02:07 +00:00
Mikio Hara
63eda1eb06 all: use of nettest, remove internal/nettest
This change uses the nettest package where possible and removes the
internal/nettest package.

Change-Id: I5615a3ab7957183fecea6b5646df99dbb7c186e2
Reviewed-on: https://go-review.googlesource.com/c/net/+/123057
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2019-03-27 21:43:58 +00:00
Mikio Hara
77544e6953 all: make bit clear operator explicitly
Change-Id: If72588778b815bc5d8f3e9f41d888cffc0d2a18d
Reviewed-on: https://go-review.googlesource.com/c/net/+/168298
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-20 06:12:53 +00:00
Mikio Hara
c1c748415a internal/socket: drop support for go1.8 or below
Change-Id: I3dcc786d4e9196bfba7e139948ccf459d28675af
Reviewed-on: https://go-review.googlesource.com/c/net/+/162597
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2019-03-10 07:45:08 +00:00
Mikio Hara
16b79f2e4e internal/socket: use correct cmsg alignment for netbsd/arm
The NetBSD arm port requires 64-bit alignment for cmsgs.

Change-Id: I619a205b4ff1b292b4d9eb2565799fe2c0a41b9f
Reviewed-on: https://go-review.googlesource.com/c/164777
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-01 23:13:41 +00:00
Mikio Hara
312bce6e94 internal/socket: make not implemented errors more descriptive
Change-Id: I7c1447849dc664ae54229345f2fce8f59204ecdf
Reviewed-on: https://go-review.googlesource.com/c/150117
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-02-27 02:21:44 +00:00
Tobias Klauser
a67830ca58 internal/nettest: drop causesIPv6Crash
The causesIPv6Crash helper function was only needed on macOS 10.8 and
before. However, Go 1.11 requires at least macOS 10.11, so drop the
check altogether. Also remove the unused implementations for all other
geese.

Change-Id: I7459f942374e7e2e6c14b787e2dfc493de67bedc
Reviewed-on: https://go-review.googlesource.com/c/156497
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-07 15:50:40 +00:00
Joel Sing
e147a91383 internal/socket: use correct cmsg alignment for openbsd/arm
The OpenBSD armv7 port requires 64-bit alignment for cmsgs.

Change-Id: Ibb1c5dc32c9e0851d0ee23b4ebdb316d7ed79629
Reviewed-on: https://go-review.googlesource.com/c/154397
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-12-17 02:32:33 +00:00
Keith Randall
adae6a3d11 internal/socket: use libc calls on darwin
Use libc calls instead of raw syscalls on Darwin.

Change-Id: I0319ae61e3575e7f76b975b9325c9078ab3440d5
Reviewed-on: https://go-review.googlesource.com/c/149617
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-11-14 22:03:01 +00:00
Mikio Hara
03003ca0c8 internal/socket: simplify nested if-blocks
Change-Id: I9f5fa605d9dc4047f916d9adc998ed23a65839ed
Reviewed-on: https://go-review.googlesource.com/c/148357
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-08 08:20:09 +00:00
Michael Stapelberg
a544f70c90 internal/socket: update zoneCache on cache misses to cover appearing interfaces
Updates golang/go#28535

Change-Id: Id653b21b4d893cc8b6b9a74b129d1ce9b7e26a9f
Reviewed-on: https://go-review.googlesource.com/c/147739
Reviewed-by: Mikio Hara <mikioh.public.networking@gmail.com>
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
2018-11-07 09:39:36 +00:00
chigotc
9b4f9f5ad5 internal/nettest: add AIX operating system
This commit adds AIX operating system to internal/nettest package.

It also disables unixpacket network.

Change-Id: Ie1a0b5c02d41ede7297c3706f6967be3438321a5
Reviewed-on: https://go-review.googlesource.com/c/144077
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-23 16:26:49 +00:00
Mikio Hara
26e67e76b6 internal/socks: fix socket descriptor leakage in Dialer.Dial
Fixes golang/go#27630.

Change-Id: Id44ade435733ffcd2fc8159ea9ea3287baadf97a
Reviewed-on: https://go-review.googlesource.com/134755
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-11 22:03:05 +00:00
Mikio Hara
4d581e05a3 all: re-adjust build constraints for JS and NaCl
This change fixes the build breakage of h2i on JS and NaCl, and avoids
using unintentional code path on JS.

Change-Id: Ib08f0f6d1d79aecc9bf1e9ee7de52b0a57c22baf
Reviewed-on: https://go-review.googlesource.com/122539
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-09 03:26:41 +00:00
Mikio Hara
75944861c7 internal/socks: add DialWithConn method to Dialer
This change adds DialWithConn method for allowing package users to use
own net.Conn implementations optionally.

Also makes the deprecated Dialer.Dial return a raw transport connection
instead of a forward proxy connection for preserving the backward
compatibility on proxy.Dialer.Dial method.

Fixes golang/go#25104.

Change-Id: I4259cd10e299c1e36406545708e9f6888191705a
Reviewed-on: https://go-review.googlesource.com/110135
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-30 17:52:07 +00:00
Mikio Hara
4ef37e81ae internal/iana: follow the move of TOS/TC registry
The registry for IPv4 TOS Byte and IPv6 Traffic Class Octet has been
moved to DSCP registry.

Also uses HTTPS for fetching any IANA resource.

Change-Id: I6a54defc2be4415fac084fcf9dfe0a481d72df33
Reviewed-on: https://go-review.googlesource.com/115220
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-30 16:39:01 +00:00
Tobias Klauser
8d282c4e20 internal/socks: fix typo in comment
Follow-up fix for CL 115237 which fixed the generated file.

Change-Id: I17881ce4ad1fc8f7d74b2b78e515d5d5430ad451
Reviewed-on: https://go-review.googlesource.com/115275
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-30 14:40:21 +00:00
Richard Musiol
640f4622ab internal/nettest: add js/wasm architecture
This commit adds the js/wasm architecture
to the internal/nettest package.

js/wasm currently uses the same fake networking as nacl.
Support for real networking will be added later.

Related to https://go-review.googlesource.com/c/go/+/109995

Change-Id: Ic914175374d7588dcb3c078da0e0e71c88323d1a
Reviewed-on: https://go-review.googlesource.com/110895
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-02 16:41:42 +00:00
Mikio Hara
61147c48b2 internal/{socks,sockstest}: new packages
This change factors out the code related to SOCKS protocol version 5
from the golang/x/net/proxy package and provides new SOCKS-specific
API to fix the following:
- inflexbility of forward proxy connection setup; e.g., no support for
  context-based deadline or canceling, no support for dial deadline,
  no support for working with external authentication mechanisms,
- useless error values for troubleshooting.

The new package socks is supposed to be used by the net/http package
of standard library and proxy package of golang.org/x/net repository.

Fixes golang/go#11682.
Updates golang/go#17759.
Updates golang/go#19354.
Updates golang/go#19688.
Fixes golang/go#21333.

Change-Id: I24098ac8522dcbdceb03d534147c5101ec9e7350
Reviewed-on: https://go-review.googlesource.com/38278
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-06 21:48:16 +00:00
Mikio Hara
08b7f81811 internal/iana: add address family number constants
Updates golang/go#24440.

Change-Id: Ic56bb1add57831d6c94f148d209417be5aa22cb2
Reviewed-on: https://go-review.googlesource.com/63996
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-19 15:13:56 +00:00