Commit Graph

912 Commits

Author SHA1 Message Date
Brad Fitzpatrick
5916dcb167 http2, lex/httplex: make Transport reject bogus headers before sending
The http2.Transport was able to send bogus header keys & values.
This changes rejects them earlier, before they hit the wire.

In the process, mirror the lexical rules from the http package to x/net.
Maintaining two copies has gotten increasingly annoying.

Updates golang/go#14048

Change-Id: I20abcdeea92e7dc8706a1bbd60688ee8843a2b12
Reviewed-on: https://go-review.googlesource.com/23229
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-19 01:54:56 +00:00
Brad Fitzpatrick
3c5cb154b0 http2: reject more trailer values
Updates golang/go#14188

Change-Id: Ic274841422fcb6179c0a782956bbfa336d27f1e1
Reviewed-on: https://go-review.googlesource.com/23230
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-19 01:52:22 +00:00
Brad Fitzpatrick
8aacbecd63 http2: with Go 1.7 set Request.Context in ServeHTTP handlers
And act the same as HTTP/1.x in Go 1.7.

Updates golang/go#15134

Change-Id: Ib64dd82cc5f8dd60e1680525f664d5b72be11fc6
Reviewed-on: https://go-review.googlesource.com/23220
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-18 21:19:18 +00:00
Brad Fitzpatrick
3b993948b6 http2: when using Go 1.7, make Transport use httptrace hooks
Updates golang/go#12580

Change-Id: I95d7206a8fde494f88288b381814a5d72d42df5e
Reviewed-on: https://go-review.googlesource.com/23205
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-18 15:10:36 +00:00
Mikio Hara
76e74a3365 ipv6: add support for linux/s390x
Change-Id: Ia431a6cfc53a66b20307f1e54b17f5bbceee02e3
Reviewed-on: https://go-review.googlesource.com/23193
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-18 03:10:44 +00:00
Mikio Hara
a71ada68b9 ipv4: add support for linux/s390x
Change-Id: I6789d04215f23dfb9fe07a90f78e80eadfcb906c
Reviewed-on: https://go-review.googlesource.com/23192
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-18 03:10:31 +00:00
Mikio Hara
fac978cc75 route: fix typos in test
Change-Id: Id0558e3ee71b393e0366c1ae5e022d657fec08f0
Reviewed-on: https://go-review.googlesource.com/23191
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-18 03:10:18 +00:00
David Anderson
ef00b378c7 ipv6: support attaching packet filters to PacketConn.
Fixes golang/go#14974

Change-Id: I58c41acf29329aedf61b9ca59eb271e4536c80ea
Reviewed-on: https://go-review.googlesource.com/23107
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-05-15 06:10:11 +00:00
David Anderson
58b2fb074e ipv4: support attaching packet filters to PacketConn/RawConn.
Updates golang/go#14974

Change-Id: I80da378a788d5d826b3b79ab308372231c012391
Reviewed-on: https://go-review.googlesource.com/23105
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-15 02:52:58 +00:00
Mikio Hara
30be488e91 route: new package
This change introduces a package that provides the basic manipulation of
routing facilities on BSD variants.

Unlike the existing APIs in syscall package of standard library, the
package tries to provide operating system and its architecture agnostic
APIs. At present, the package supports any version of Darwin, any
version of DragonFly BSD, FreeBSD 7 through 11, NetBSD 6 and above, and
OpenBSD 5.6 and above.

Updates golang/go#14724.

Change-Id: Id964ea22dec491ddac3776e3a8c8c10f140f96ac
Reviewed-on: https://go-review.googlesource.com/22446
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-14 01:16:38 +00:00
Carl Mastrangelo
6050c11192 http2/hpack: forbid excess and invalid padding in hpack decoder
This change fixes a few bugs in the HPACK decoder:
 * Excess trailing padding is treated as an error per the HPACK Spec
     section 5.2
 * Non EOS prefix padding is treated as an error
 * Max length is now enforced for all decoded symbols

The idea here is to keep track of the decoded symbol length, rather
than the number of unconsumed bits in cur.  To this end, nbits has
been renamed cbits (cur bits), and sbits (sym bits) has been
introduced.  The main problem with using nbits is that it can easily
be zero, such as when decoding {0xff, 0xff}.  Using a clear moniker
makes it easier to see why checking cbits > 0 at the end of the
function is incorrect.

Fixes golang/go#15614

Change-Id: I1ae868caa9c207fcf9c9dec7f10ee9f400211f99
Reviewed-on: https://go-review.googlesource.com/23067
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-13 23:09:52 +00:00
Brad Fitzpatrick
96dbb961a3 http2: make Transport use Request.Context, set Response.Uncompressed
Go 1.7 introduces Request.Context and Response.Uncompressed. Use them
both in the http2 Transport when building for Go 1.7.

Tests are in the main repo.

Updates golang/go#15366
Updates golang/go#15134

Change-Id: I4b78a2710b6cf30c769c7f85cea15ecde653a317
Reviewed-on: https://go-review.googlesource.com/23002
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-10 17:26:03 +00:00
Ian Lance Taylor
2a35e68658 context: correct spelling of TODO in comment
Change-Id: I62bfc730643cb0756fc67f3c5cf73029b75c07bb
Reviewed-on: https://go-review.googlesource.com/22884
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-06 21:07:50 +00:00
Mikio Hara
7e42c0e132 ipv4: don't fail test on big endian machine
Change-Id: I7fc0634dd1c7cd49b0f3aa2d84a83e783f6687a1
Reviewed-on: https://go-review.googlesource.com/22678
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-05 21:58:21 +00:00
Mikio Hara
9723ea673d icmp: don't fail test on big endian machine
Change-Id: I5ceede6cf0aa4fcdbf59c39e1aff9826874f2710
Reviewed-on: https://go-review.googlesource.com/22677
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-05 21:57:10 +00:00
Nic Day
35ec611a14 net/trace: fix comment typo
Abbreviating "if and only if" to "iff" is against Go style in public
documentation; use expanded form.

Change-Id: I23afdca1b773ef9572794555dfb768c9ded90ab7
Reviewed-on: https://go-review.googlesource.com/22545
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-01 04:31:21 +00:00
Brad Fitzpatrick
1aafd77e1e context: fix doc typo
Fixes golang/go#15449

Change-Id: Ib4802dc1d9208abc17ef31212d49f03f4f4ed3d1
Reviewed-on: https://go-review.googlesource.com/22494
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-27 15:28:33 +00:00
Brad Fitzpatrick
cb0ed7acc4 http2: allow StreamDep of 0 in HEADERS and PRIORITY frames
But still check that the high bit isn't set.

Fixes golang/go#15444

Change-Id: Ic9339244d3d0c4e4d6573a691b3ba37c9eac3981
Reviewed-on: https://go-review.googlesource.com/22476
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-26 22:44:14 +00:00
Dave Day
b797637b7a http2: delete pre-Go1.5 request cancellation
This was always a no-op in 1.4 and earlier. This change directly
inlines the 1.5 version.

Change-Id: I6dcf69497d876d7dde729c1801cef5382b97fa07
Reviewed-on: https://go-review.googlesource.com/22388
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-22 23:03:51 +00:00
Dave Day
815d315ead context/ctxhttp: remove pre-Go 1.5 support
The Go 1.4 (and earlier) support for request cancellation is racy and
complicates the implementation of ctxhttp. This change simply inlines
the existing 1.5+ cancellation logic directly, and removes support for
older versions.

Change-Id: I7df9f0648dd0e571366374d079e2976050464ca3
Reviewed-on: https://go-review.googlesource.com/22302
Reviewed-by: David Symonds <dsymonds@golang.org>
Run-TryBot: David Symonds <dsymonds@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-21 00:36:51 +00:00
David Symonds
fb93926129 context: bump gccgo-specific alloc limit for WithTimeout test.
9d8ef8d caused an extra allocation for gccgo.

Change-Id: I6568d84009882103ec4767546599afa20c54c480
Reviewed-on: https://go-review.googlesource.com/21940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-12 22:56:35 +00:00
Dan Peterson
0cc50bbd65 http2: standardize RFC mention format
Updates golang/go#15258

Change-Id: Ieaea9564a6e300938a75d3382151c46e9bde1e59
Reviewed-on: https://go-review.googlesource.com/21903
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-12 21:07:59 +00:00
Mikio Hara
589fda73dd ipv6: fix a typo
Change-Id: I4ce6dfec994252fec3874fb748e0d6b8db97394d
Reviewed-on: https://go-review.googlesource.com/21835
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-11 18:41:48 +00:00
Mikio Hara
a8a071f2a6 ipv4: fix a typo
Change-Id: I1e4133d1988cb745d465b478bcdf01594304e48a
Reviewed-on: https://go-review.googlesource.com/21834
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-11 18:41:38 +00:00
Mikio Hara
f608d985aa icmp: fix a typo
Change-Id: Icd29cd883dab0c916e2285d6053074e97771b840
Reviewed-on: https://go-review.googlesource.com/21833
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-11 18:41:27 +00:00
Mikio Hara
edd5b7d9bd http2: fix typos
Change-Id: I88501fc0d84cdcb210bf53a373982c4e399f4c1f
Reviewed-on: https://go-review.googlesource.com/21832
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-11 18:41:15 +00:00
Mikio Hara
e4306e4093 http2/hpack: fix a typo
Change-Id: I18cc9536444f3112f677f1439a114efe65faf51e
Reviewed-on: https://go-review.googlesource.com/21831
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-11 18:41:01 +00:00
Nigel Tao
e45385e9b2 webdav: have the exported API use the standard library's xml.Name type.
In particular, the Property and DeadPropsHolder types need to refer to
the standard xml package, not the internal fork, to be usable by other
packages.

Inside the package, the XML marshaling and unmarshaling is still done by
the etc/internal/xml package, and will remain that way until
https://github.com/golang/go/issues/13400 is resolved.

Fixes golang/go#15128.

Change-Id: Ie7e7927d8b30d97d10b1a4a654d774fdf3e7a1e3
Reviewed-on: https://go-review.googlesource.com/21635
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-07 03:40:12 +00:00
Nigel Tao
8f3641dedf webdav: rename the "etc/internal/xml" import.
There is no semantic change to this commit. A follow-up commit will
change this package's behavior, but this preparatory commit will make
the follow-up's diff smaller, and less noisy.

Change-Id: I12e356fc1f29d3c4a7c3374aab4a1b1eefe01144
Reviewed-on: https://go-review.googlesource.com/21631
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-07 02:10:48 +00:00
Nigel Tao
bcb71dd18f webdav: run "gofmt -s" to simplify some tests.
Change-Id: Ie7422dd04b4d7a14059e33ac19cb82691cff3d3f
Reviewed-on: https://go-review.googlesource.com/21632
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-07 02:09:49 +00:00
Nigel Tao
9622a22758 webdav: fill in the package's doc comment.
Change-Id: I078768667f46d413a65a347185a8fb296b9c5b1e
Reviewed-on: https://go-review.googlesource.com/21633
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-07 02:09:28 +00:00
Nigel Tao
e000e3cac1 webdav: remove runtime check for Go 1.4 or earlier.
During the Go 1.5 development cycle, this package used to require the
standard library's encoding/xml package from Go 1.5 or later, but
https://go-review.googlesource.com/#/c/12772/ (which was submitted in
July 2015) made an internal fork of encoding/xml, as some
namespace related changes introduced in the Go 1.5 cycle were rolled
back in response to https://github.com/golang/go/issues/11841

Thus, this "go1.4" runtime check is no longer necessary. In the long
term, this package should use the standard library's version, and the
internal fork deleted, once https://github.com/golang/go/issues/13400 is
resolved. We could re-introduce a similar check at that time, although
it could be done at compile time (via a "go1.7" build tag) instead of at
runtime.

Change-Id: I18258443aa3d9b519e23106aedb189f25c35495d
Reviewed-on: https://go-review.googlesource.com/21634
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-07 02:09:14 +00:00
Brad Fitzpatrick
af4fee9d05 http2: make Server reject connection-level headers with a 400 response
Fixes golang/go#14214

Change-Id: I474af4735e2135d787e948220a8fcdbba73a2b25
Reviewed-on: https://go-review.googlesource.com/21534
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-06 03:57:22 +00:00
Sam Whited
318395d8b1 websocket: remove redundant error handling
Change-Id: I1b0e8812ca5b2e3ca72948d5414d569879e54f35
Reviewed-on: https://go-review.googlesource.com/21461
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-05 03:06:35 +00:00
Brad Fitzpatrick
afc22ee913 context: implement in terms of the standard library for Go 1.7+
See https://golang.org/cl/20346

Updates golang/go#14660

Change-Id: Ia974e70cdcb240ae1df0018a07595c4d1dcd422a
Reviewed-on: https://go-review.googlesource.com/20347
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-05 00:08:57 +00:00
Roland Shoemaker
024ed629fd http2: Ignore Keep-Alive header in requests
Adds Keep-Alive to the list of ignored headers in encodeHeaders
as required in the HTTP/2 spec (section 8.1.2.2) and adds a test
to check this.

Fixes golang/go#15085

Change-Id: Ie4624680c5de1f13eb94fa58a2d5d67a02634df3
Reviewed-on: https://go-review.googlesource.com/21482
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-03 19:55:14 +00:00
David Anderson
3e8a7b0329 bpf: rename LoadIPv4HeaderLen to the more generic LoadMemShift.
The instruction itself doesn't care what the bits it's twiddling represents,
even though the it was introduced to more efficiently manipulate IPv4 packets.

Change-Id: Ie65a6df4041ad2090060636ccf7128680fcf75b7
Reviewed-on: https://go-review.googlesource.com/21244
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-03-31 21:48:25 +00:00
Mikio Hara
c4bb2f7b3d ipv6: remove unnecessary sysSockoptLen type
Change-Id: I87887ea03c36ca7d26e1ab2cb55d723611c942a8
Reviewed-on: https://go-review.googlesource.com/21354
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-31 04:07:02 +00:00
Mikio Hara
37db164db4 ipv4: remove unnecessary sysSockoptLen type
Change-Id: I367d38bca99ede07aa0cf697547c5cb43ce4e164
Reviewed-on: https://go-review.googlesource.com/21353
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-31 04:06:34 +00:00
Brad Fitzpatrick
31df19d69d http2: fix truncated comment
Backtick is my screen metakey, so this got lost in a copy/paste
at the backtick symbol.

Change-Id: Ia3e7bf5d2819ea83ff6cc86cc3b6210e3f279eb0
Reviewed-on: https://go-review.googlesource.com/21193
Reviewed-by: David Symonds <dsymonds@golang.org>
2016-03-28 23:19:20 +00:00
David Anderson
1dd0d85fc0 bpf: correct spelling of marshaling in package doc.
Change-Id: Ied9b2589b4aa5cb445dd368864df047c84848a95
Reviewed-on: https://go-review.googlesource.com/21217
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-03-28 08:44:40 +00:00
David Anderson
27276f6b36 bpf: add package documentation describing the BPF virtual machine.
Change-Id: I2fcb07bdc104c488aa61a6c6b6ee8797e60e868a
Reviewed-on: https://go-review.googlesource.com/21216
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-03-28 07:53:43 +00:00
David Anderson
9c7b3c72db bpf: simplify disasm state machine.
The code ends up slightly longer, but the decoding is more consistent from
one instruction class to another, so hopefully it's easier to make sense of it.

Change-Id: Ia22c2ebb0865536da0c3dac6876bdb0b20075f04
Reviewed-on: https://go-review.googlesource.com/21215
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-28 07:27:13 +00:00
David Anderson
3c208088b6 bpf: new package to assemble and disassemble Berkeley Packet Filter programs.
The package currently implements the operations defined by
https://www.kernel.org/doc/Documentation/networking/filter.txt , which
comprises the base BPF virtual machine plus the Linux kernel's extension
opcodes.

Updates golang/go#14982

Change-Id: Iafb43d80e067040e60465a9bfb7d5f2ca90cc2ae
Reviewed-on: https://go-review.googlesource.com/21212
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-03-28 06:22:12 +00:00
Brad Fitzpatrick
1600a4cd69 http2: revert part of e7da8eda to fix data race it introduced
Git rev e7da8eda (CL 20542) introduced an optimization to reuse the
64k request body buffers across multiple requests. But ServeHTTP
handlers could retain them too long and cause races.

Temporarily revert the main part of that CL until a proper fix is in.

Updates golang/go#14960
Updates grpc/grpc-go#604

Change-Id: I28450e797a1d3122868214700b6ef345a0a1a47c
Reviewed-on: https://go-review.googlesource.com/21160
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-25 21:37:33 +00:00
Brad Fitzpatrick
991d3e32f7 http2: make Transport handle HEAD responses with DATA frames
The Google GFE replies to HEAD requests with the END_STREAM bit in an
empty DATA frame, not in the response HEADERS. The Go Transport code
mistook this to mean the Content-Length was real.

Worked around in:
645322e7db

Reported internally in b/27820181.

Change-Id: Id31a047e2277d7d90560fca264919e239ec76d74
Reviewed-on: https://go-review.googlesource.com/21061
Reviewed-by: Dave Day <djd@golang.org>
2016-03-24 04:41:38 +00:00
Brad Fitzpatrick
4876518f9e http2: don't make garbage when sorting things
benchmark                        old ns/op     new ns/op     delta
BenchmarkServer_GetRequest-2     259453        256050        -1.31%

benchmark                        old allocs     new allocs     delta
BenchmarkServer_GetRequest-2     24             22             -8.33%

benchmark                        old bytes     new bytes     delta
BenchmarkServer_GetRequest-2     1599          1532          -4.19%

Change-Id: Ieb11a3bd4c752567e0401bcc5e77e027cfb8063c
Reviewed-on: https://go-review.googlesource.com/20999
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-22 02:16:52 +00:00
Brad Fitzpatrick
c56178077d http2: remove method value allocation per read frame
benchmark                        old ns/op     new ns/op     delta
BenchmarkServer_GetRequest-2     269540        259453        -3.74%

benchmark                        old allocs     new allocs     delta
BenchmarkServer_GetRequest-2     25             24             -4.00%

benchmark                        old bytes     new bytes     delta
BenchmarkServer_GetRequest-2     1613          1599          -0.87%

Change-Id: I33609d8fbe2f81e32095fac8b89ddd55592e583f
Reviewed-on: https://go-review.googlesource.com/20998
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-22 01:48:32 +00:00
Brad Fitzpatrick
4d06dbdaa6 http2: reduce alloc-heavy init
Moves test cases into the test where they're used, to remove
distractions when profiling unrelated tests.

Also this is my style preference, to remove globals and reduce the
scope of variables.

Change-Id: Ie9cd41b16aad9acf5e210f1fb6f19a7fce52180d
Reviewed-on: https://go-review.googlesource.com/20996
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-21 23:20:58 +00:00
David Symonds
9d8ef8d73b context: Uniformly pass cancelCtx by pointer.
cancelCtx has an embedded sync.Mutex. This change causes an extra
allocation when creating a new timerCtx via WithDeadline, but that seems
minor when compared with better locking discipline. If it turns out to
be a problem, the whole cancelCtx struct can be flattened into timerCtx.

Addresses part of golang/go#14839.

Change-Id: Ie86ed1b63592b521aefde747d5fafcd49ac18178
Reviewed-on: https://go-review.googlesource.com/20840
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-20 20:34:16 +00:00