Commit Graph

1021 Commits

Author SHA1 Message Date
Brad Fitzpatrick
dffc95cbb4 context: use Go 1.8 type alias for CancelFunc and Context
CancelFunc was the only part of the context package which didn't
forward nicely with the move from x/net/context to std context.

Use it for Context as well.

Change-Id: Ieff39b10b0783d55d0437c73923053297ed0ea4a
Reviewed-on: https://go-review.googlesource.com/32317
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-10-28 22:21:43 +00:00
Brad Fitzpatrick
b336a971b7 http2: initialize Server.IdleTimeout from http.Server as http1 does
This makes ConfigureServer initialize the http2 Server's IdleTimeout
from the http1 Server configuration, using the same rules as
IdleTimeout in Go 1.8: first use IdleTimeout if specified, else fall
back to the old ReadTimeout.

Updates golang/go#14204

Change-Id: I4dee971f8416ef0cbf99335a199c46355f9ab09d
Reviewed-on: https://go-review.googlesource.com/32230
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-27 20:31:54 +00:00
Brad Fitzpatrick
b626cca987 http2: fix optimized write scheduling
Fixes regression from https://golang.org/cl/31495 which generated
massive stacks like:

net/http.(*http2serverConn).startFrameWrite(0x1890e7e0, 0x859bc70, 0x18c26050, 0x1897c1c0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3664 +0x34a
net/http.(*http2serverConn).scheduleFrameWrite(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3779 +0x114
net/http.(*http2serverConn).wroteFrame(0x1890e7e0, 0x859bb50, 0x18c26060, 0x0, 0x0, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3742 +0xc8
net/http.(*http2serverConn).startFrameWrite(0x1890e7e0, 0x859bb50, 0x18c26060, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3689 +0x23f
net/http.(*http2serverConn).scheduleFrameWrite(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3779 +0x114
net/http.(*http2serverConn).writeFrame(0x1890e7e0, 0x859bb50, 0x18c26060, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3648 +0x6b
net/http.(*http2serverConn).resetStream(0x1890e7e0, 0x1, 0x8, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3815 +0x91
net/http.(*http2serverConn).wroteFrame(0x1890e7e0, 0x859b6d0, 0x1890db00, 0x1897c1c0, 0x18ede040, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3736 +0x124
net/http.(*http2serverConn).startFrameWrite(0x1890e7e0, 0x859b6d0, 0x1890db00, 0x1897c1c0, 0x18ede040)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3689 +0x23f
net/http.(*http2serverConn).scheduleFrameWrite(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3779 +0x114
net/http.(*http2serverConn).wroteFrame(0x1890e7e0, 0x859bc70, 0x18c26018, 0x0, 0x0, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3742 +0xc8
net/http.(*http2serverConn).startFrameWrite(0x1890e7e0, 0x859bc70, 0x18c26018, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3689 +0x23f
net/http.(*http2serverConn).scheduleFrameWrite(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3779 +0x114
net/http.(*http2serverConn).wroteFrame(0x1890e7e0, 0x859b730, 0x18ede000, 0x1897c1c0, 0x0, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3742 +0xc8
net/http.(*http2serverConn).serve(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3504 +0x50d
net/http.(*http2Server).ServeConn(0x18ab49a0, 0x859e040, 0x18df2000, 0x1894ae18)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3152 +0x6d9
net/http.http2ConfigureServer.func1(0x18d364e0, 0x18df2000, 0x859a1b0, 0x18ab2308)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3033 +0x70
net/http.(*conn).serve(0x18ad60f0, 0x859cbc0, 0x18aa42a0)
    /tmp/workdir/go/src/net/http/server.go:1633 +0xf03

This changes it to be a loop instead.

This also fixes the "internal error: attempt to send frame on
half-closed-local stream" crash from golang/go#17627 because
wroteFrame set stateHalfClosedLocal temporarily while calling
resetStream which itself does a write in some cases. Prior to CL 31495
those writes were processed breadth-first. CL 31495 made the writes
generated from resetStream (like the window updates returning unused
flow-control) more aggressive and scheduled immediately. This loop
restores the old write scheduling.

Fixes golang/go#17627

Change-Id: I9651568e4105791d24d46819499efc7e018c86c3
Reviewed-on: https://go-review.googlesource.com/32217
Reviewed-by: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-27 17:37:18 +00:00
Tom Bergan
c46f265c32 http2: implement support for server push
This makes x/net/http2's ResponseWriter implement the new interface,
http.Pusher. This new interface requires Go 1.8. When compiled against
older versions of Go, the ResponseWriter does not have a Push method.

Fixes golang/go#13443

Change-Id: I8486ffe4bb5562a94270ace21e90e8c9a4653da0
Reviewed-on: https://go-review.googlesource.com/29439
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-27 00:19:06 +00:00
Tom Bergan
65dfc08770 http2: reject stream self-dependencies
Fix spec bug: Section 5.3.1 says that self-dependencies should be
treated as a stream error of type PROTOCOL_ERROR.

Updates golang/go#16046

Change-Id: I8b5dc8808943dc96aac0c543c7032fa989ab9e0b
Reviewed-on: https://go-review.googlesource.com/31858
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-24 23:31:26 +00:00
Brad Fitzpatrick
e7b14352cc http2: optimize server frame writes
Don't do async frame writes when the write is known to be small enough
to definitely fit in the write buffer and not cause a flush (which
might block). This avoids starting a new goroutine and doing a channel
send operation for many frame writes.

name                  old time/op    new time/op    delta
ServerGets-4             146µs ± 2%     144µs ± 1%  -1.46%        (p=0.000 n=14+14)
ServerPosts-4            162µs ± 1%     160µs ± 1%  -1.15%        (p=0.000 n=15+15)
Server_GetRequest-4      145µs ± 1%     143µs ± 0%  -1.26%        (p=0.000 n=15+15)
Server_PostRequest-4     160µs ± 1%     158µs ± 1%  -1.32%        (p=0.000 n=15+15)

The headers frame is the main last one which might show some benefit
if there's a cheap enough way to conservatively calculate its size.

Change-Id: I9be2ddbf04689340819d8701ea671fff378d9e79
Reviewed-on: https://go-review.googlesource.com/31495
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-24 18:47:39 +00:00
Tom Bergan
4be9b97e3a http2: interface to support pluggable schedulers
This adds an interface to support pluggable schedulers. The interface
is defined in writesched.go. The only type needed by this interface is
FrameWriteRequest, which describes a request to write a frame (this used
to be called frameWriteMsg). The scheduler can be configured with a new
field in http2.Server. Two schedulers are implemented:

1) A random scheduler that is essentially equivalent to the existing
   scheduler. This is currently the default scheduler if none is
   configured. The implementation is in writesched_random.go.

2) A scheduler that uses H2 weights and priorities. The H2 priority tree
   is maintained as a tree of priorityNodes. The next frame is chosen by
   walking this tree in topological order, where sibling nodes are ordered
   by their bandwidth usage relative to their H2 weight. Two optional
   features are added to improve performance -- these are configured with
   PriorityWriteSchedulerConfig.

Fixes golang/go#16168

Change-Id: I97ec93e5c58c2efec35455ba2f3c31e849f706af
Reviewed-on: https://go-review.googlesource.com/25366
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-24 17:05:25 +00:00
Nigel Tao
5695785b44 publicsuffix: update table to latest list from publicsuffix.org
Update the list to revision 915565885d0fbd25caf7d8b339cd3478f558da94
(2016-10-19T08:16:09Z).

Change-Id: Ie94e7237015f2d84e0a0d082bd7ff9e04b05ecd9
Reviewed-on: https://go-review.googlesource.com/31530
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-24 07:02:33 +00:00
Brad Fitzpatrick
c33d37840d http2: add Server.IdleTimeout
Also remove some stale TODOs and finish one of the TODOs, ignoring
more incoming frames when the connection is in GOAWAY mode.

Also, fix independently-broken transport test from a change in std:
https://golang.org/cl/31595

Updates golang/go#14204

Change-Id: Iae8b02248464d613979c30d8f86eacb329cd262f
Reviewed-on: https://go-review.googlesource.com/31727
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-23 13:31:18 +00:00
Luka Zakrajšek
f11d7120b1 webdav: escape displayname
Displayname WebDAV property should be XML escaped. With current
implementation a file with name '<.txt' would make the XML
invalid.

Fixes golang/go#17158

Change-Id: Ib3b5376094edc957ed15adf511bd1050ea13d27e
Reviewed-on: https://go-review.googlesource.com/29297
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-10-22 21:48:12 +00:00
Brad Fitzpatrick
41c5c5cb12 http2: make Server return conn protocol errors on bad idle stream frames
Per RFC 7540, section 5.1 discussing the "idle" state: "Receiving any
frame other than HEADERS or PRIORITY on a stream in this state MUST be
treated as a connection error (Section 5.4.1) of type PROTOCOL_ERROR."x

Updates golang/go#16046

Change-Id: Ie0696059e76a092e483aea5ee017d9729339d309
Reviewed-on: https://go-review.googlesource.com/31736
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-21 21:08:44 +00:00
Brad Fitzpatrick
40a0a18980 http2: fix Server race with concurrent Read/Close
Introduced by golang.org/cl/31447.

grpc-go does concurrent Read/Close calls to the Request.Body. Since
that was supported previously, continue to support it, and add a test.

Updates grpc/grpc-go#938

Change-Id: I8a5cf6b28c5eca346ea46c4129021172e489f71d
Reviewed-on: https://go-review.googlesource.com/31636
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-21 17:55:28 +00:00
Mikio Hara
daba796358 ipv6: remove unnecessary control message marshaling
The encoded data is just for debugging at kernel side and has
remained in normal code path until now, oops.

Change-Id: I3581bf73a6e6c9ec4b6228a670b6d8338f13ee14
Reviewed-on: https://go-review.googlesource.com/31535
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-20 06:46:33 +00:00
Mikio Hara
4bc7a68051 ipv4: remove unnecessary control message marshaling
The encoded data is just for debugging at kernel side and has remained
in normal code path until now, oops.

Change-Id: I28003ae211eb63d717d7e20f39ee0f39201892a5
Reviewed-on: https://go-review.googlesource.com/31534
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-20 06:46:24 +00:00
Brad Fitzpatrick
3bafa3320e http2: make Server reuse 64k request body buffer between requests
name           old time/op    new time/op    delta
ServerPosts-4     192µs ± 1%     164µs ± 1%  -14.16%  (p=0.000 n=17+19)

name           old alloc/op   new alloc/op   delta
ServerPosts-4    69.8kB ± 0%     2.8kB ± 0%  -95.95%  (p=0.000 n=18+18)

name           old allocs/op  new allocs/op  delta
ServerPosts-4      42.0 ± 0%      40.0 ± 0%   -4.76%  (p=0.000 n=20+20)

This is a redo of git rev e7da8eda (golang.org/cl/20542) which had a race
and was later reverted in golang.org/cl/21160.

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

Change-Id: Ie216e45730dce4fc0c58f295bcbc669973145599
Reviewed-on: https://go-review.googlesource.com/31447
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-19 18:40:16 +00:00
Brad Fitzpatrick
a625e39532 http2: never Read from Request.Body in Transport to determine ContentLength
Updates golang/go#17480 (fixes after vendor to std)
Updates golang/go#17071 (a better fix than the original one)

Change-Id: Ibb49d2cb825e28518e688b5c3e0952956a305050
Reviewed-on: https://go-review.googlesource.com/31326
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-10-18 18:39:36 +00:00
Mikio Hara
8b4af36cd2 websocket: drop support for go1.4 or below
Change-Id: I228f1405aac4ed058dafdfd5fc4cc609c56004fa
Reviewed-on: https://go-review.googlesource.com/30897
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-13 03:57:02 +00:00
Mikio Hara
236cde1758 websocket: use of crypto/rand package in test
The Read function of math/rand package doesn't exist on Go 1.5 or below.

Change-Id: If837bbd0a862726be93e07b021701004ba0f0fad
Reviewed-on: https://go-review.googlesource.com/30896
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-13 03:56:52 +00:00
Mikio Hara
c4e6936235 ipv6: drop support for go1.4 or below
Change-Id: I95dfb05e5c958c2949059c4230c023968a442b50
Reviewed-on: https://go-review.googlesource.com/30895
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-13 03:56:40 +00:00
Mikio Hara
8e2f460f38 ipv4: drop support for go1.4 or below
Change-Id: Ifbc3848dcf1f7d43e3d781bcfe24e144ce028c32
Reviewed-on: https://go-review.googlesource.com/30894
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-13 03:56:25 +00:00
Artyom Pervukhin
6dba816f10 websocket: limit incoming payload size
Codec's Receive method calls io.ReadAll of the whole frame payload,
which can be abused by user sending large payloads in order to exhaust
server memory.

Introduce limit on received payload size defined by
Conn.MaxPayloadBytes. If payload size of the message read with
Codec.Receive exceeds limit, ErrFrameTooLarge error is returned; the
connection can still be recovered if required: the next call to Receive
would at first discard leftovers of previous oversized message before
processing the next one.

Fixes golang/go#5082.

Change-Id: Ib04acd7038474fee39a1719324daaec1c0c496b1
Reviewed-on: https://go-review.googlesource.com/23590
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-12 14:08:20 +00:00
Mikio Hara
cf4effbb9d ipv4: add support for FreeBSD 11
From FreeBSD 11 both ip_len and ip_off fields of struct ip must be
provided in network byte order. See IP(4) on FreeBSD.

Change-Id: I091b551074767daf098cc1d6a256eddc4f55e304
Reviewed-on: https://go-review.googlesource.com/30736
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-11 06:13:41 +00:00
Radu Berinde
f4b625ec9b trace: don't allocate all events upfront
SetMaxEvent allocates storage for all events, which is very expensive
if we want to set a high value; even with small values, the
unnecessary allocation of the initial slice is measurable.

We improve the performance by having a few events preallocated as part
of the trace, and appending as necessary. We also co-locate the flags
in event which makes it smaller (by a word).

We also add a set of benchmarks; before and after amortized cost
per-event is shown:

name                    old time/op  new time/op  delta
Trace_Default_2-32      1.19µs ± 1%  0.96µs ± 0%  -18.94%
Trace_Default_10-32      579ns ± 0%   635ns ± 1%   +9.82%
Trace_Default_100-32     463ns ± 1%   466ns ± 1%     ~
Trace_Default_1000-32    451ns ± 1%   451ns ± 0%     ~
Trace_Default_10000-32   451ns ± 2%   449ns ± 1%     ~
Trace_10_2-32           1.41µs ± 1%  0.96µs ± 1%  -31.74%
Trace_10_10-32           623ns ± 1%   634ns ± 1%   +1.73%
Trace_10_100-32          469ns ± 1%   466ns ± 1%     ~
Trace_10_1000-32         452ns ± 1%   453ns ± 2%     ~
Trace_10_10000-32        451ns ± 1%   449ns ± 1%     ~
Trace_100_2-32          2.78µs ± 2%  0.97µs ± 1%  -65.28%
Trace_100_10-32          912ns ± 1%   637ns ± 1%  -30.23%
Trace_100_100-32         479ns ± 1%   541ns ± 0%  +12.77%
Trace_100_1000-32        510ns ± 0%   541ns ± 1%   +6.08%
Trace_100_10000-32       514ns ± 1%   540ns ± 0%   +5.14%
Trace_1000_2-32         17.2µs ± 1%   1.0µs ± 1%  -94.39%
Trace_1000_10-32        3.90µs ± 1%  0.64µs ± 0%  -83.68%
Trace_1000_100-32        814ns ± 1%   542ns ± 0%  -33.46%
Trace_1000_1000-32       503ns ± 1%   581ns ± 0%  +15.56%
Trace_1000_10000-32     1.28µs ± 2%  1.03µs ± 1%  -19.68%

Change-Id: I5bbc12153a9f30dff821ef139583cb1c07a11069
Reviewed-on: https://go-review.googlesource.com/30615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-07 14:35:04 +00:00
Brad Fitzpatrick
9b4f494e78 Revert "trace: don't allocate all events upfront"
This reverts commit If7c68bb1809fb92fa5d06cb6640be5e09e1f131f.

Reason for revert: breaks the build for Go 1.6 or below due to use of Go 1.7+ only features.

Original change's description:
> trace: don't allocate all events upfront
> 
> SetMaxEvent allocates storage for all events, which is very expensive
> if we want to set a high value; even with small values, the
> unnecessary allocation of the initial slice is measurable.
> 
> We improve the performance by having a few events preallocated as part
> of the trace, and appending as necessary. We also co-locate the flags
> in event which makes it smaller (by a word).
> 
> We also add a set of benchmarks; before and after amortized cost
> per-event is shown:
> 
> name                 old time/op  new time/op  delta
> Trace/0-2-32         1.19µs ± 1%  0.96µs ± 0%  -18.94%  (p=0.008 n=5+5)
> Trace/0-10-32         579ns ± 0%   635ns ± 1%   +9.82%  (p=0.008 n=5+5)
> Trace/0-100-32        463ns ± 1%   466ns ± 1%     ~     (p=0.190 n=5+5)
> Trace/0-1000-32       451ns ± 1%   451ns ± 0%     ~     (p=0.984 n=5+5)
> Trace/0-10000-32      451ns ± 2%   449ns ± 1%     ~     (p=0.492 n=5+5)
> Trace/10-2-32        1.41µs ± 1%  0.96µs ± 1%  -31.74%  (p=0.008 n=5+5)
> Trace/10-10-32        623ns ± 1%   634ns ± 1%   +1.73%  (p=0.008 n=5+5)
> Trace/10-100-32       469ns ± 1%   466ns ± 1%     ~     (p=0.357 n=5+5)
> Trace/10-1000-32      452ns ± 1%   453ns ± 2%     ~     (p=0.913 n=5+5)
> Trace/10-10000-32     451ns ± 1%   449ns ± 1%     ~     (p=0.175 n=5+5)
> Trace/100-2-32       2.78µs ± 2%  0.97µs ± 1%  -65.28%  (p=0.008 n=5+5)
> Trace/100-10-32       912ns ± 1%   637ns ± 1%  -30.23%  (p=0.008 n=5+5)
> Trace/100-100-32      479ns ± 1%   541ns ± 0%  +12.77%  (p=0.008 n=5+5)
> Trace/100-1000-32     510ns ± 0%   541ns ± 1%   +6.08%  (p=0.008 n=5+5)
> Trace/100-10000-32    514ns ± 1%   540ns ± 0%   +5.14%  (p=0.008 n=5+5)
> Trace/1000-2-32      17.2µs ± 1%   1.0µs ± 1%  -94.39%  (p=0.008 n=5+5)
> Trace/1000-10-32     3.90µs ± 1%  0.64µs ± 0%  -83.68%  (p=0.008 n=5+5)
> Trace/1000-100-32     814ns ± 1%   542ns ± 0%  -33.46%  (p=0.008 n=5+5)
> Trace/1000-1000-32    503ns ± 1%   581ns ± 0%  +15.56%  (p=0.008 n=5+5)
> Trace/1000-10000-32  1.28µs ± 2%  1.03µs ± 1%  -19.68%  (p=0.008 n=5+5)
> 
> Change-Id: If7c68bb1809fb92fa5d06cb6640be5e09e1f131f
> Reviewed-on: https://go-review.googlesource.com/30374
> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
> TryBot-Result: Gobot Gobot <gobot@golang.org>
> Reviewed-by: Ian Lance Taylor <iant@golang.org>
> 

Change-Id: I7cf25464ae836489e0af4a59a4d534a5d25ee352
Reviewed-on: https://go-review.googlesource.com/30650
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-07 04:33:39 +00:00
Mikio Hara
084869ab42 lif: rename internal types and constants generated by cgo
To match up with other packages that work with IP protocol stack.

Change-Id: Idc3ee5b2399c4982dbd9114aac441f6d7452aeef
Reviewed-on: https://go-review.googlesource.com/30576
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-07 03:59:10 +00:00
Mikio Hara
30df40a6a1 ipv6: rename internal types and constants generated by cgo
To match up with other packages that work with IP protocol stack.

Change-Id: I1f4eb76051964766113914c9698233022e73d5eb
Reviewed-on: https://go-review.googlesource.com/30575
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-07 03:58:57 +00:00
Mikio Hara
a14f429b86 ipv4: rename internal types and constants generated by cgo
To match up with other packages that work with IP protocol stack.

Change-Id: I2d20e4194617b05b6b46d6fba5df1f6c12ae2793
Reviewed-on: https://go-review.googlesource.com/30574
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-07 03:58:42 +00:00
Radu Berinde
88c1a61b3d trace: don't allocate all events upfront
SetMaxEvent allocates storage for all events, which is very expensive
if we want to set a high value; even with small values, the
unnecessary allocation of the initial slice is measurable.

We improve the performance by having a few events preallocated as part
of the trace, and appending as necessary. We also co-locate the flags
in event which makes it smaller (by a word).

We also add a set of benchmarks; before and after amortized cost
per-event is shown:

name                 old time/op  new time/op  delta
Trace/0-2-32         1.19µs ± 1%  0.96µs ± 0%  -18.94%  (p=0.008 n=5+5)
Trace/0-10-32         579ns ± 0%   635ns ± 1%   +9.82%  (p=0.008 n=5+5)
Trace/0-100-32        463ns ± 1%   466ns ± 1%     ~     (p=0.190 n=5+5)
Trace/0-1000-32       451ns ± 1%   451ns ± 0%     ~     (p=0.984 n=5+5)
Trace/0-10000-32      451ns ± 2%   449ns ± 1%     ~     (p=0.492 n=5+5)
Trace/10-2-32        1.41µs ± 1%  0.96µs ± 1%  -31.74%  (p=0.008 n=5+5)
Trace/10-10-32        623ns ± 1%   634ns ± 1%   +1.73%  (p=0.008 n=5+5)
Trace/10-100-32       469ns ± 1%   466ns ± 1%     ~     (p=0.357 n=5+5)
Trace/10-1000-32      452ns ± 1%   453ns ± 2%     ~     (p=0.913 n=5+5)
Trace/10-10000-32     451ns ± 1%   449ns ± 1%     ~     (p=0.175 n=5+5)
Trace/100-2-32       2.78µs ± 2%  0.97µs ± 1%  -65.28%  (p=0.008 n=5+5)
Trace/100-10-32       912ns ± 1%   637ns ± 1%  -30.23%  (p=0.008 n=5+5)
Trace/100-100-32      479ns ± 1%   541ns ± 0%  +12.77%  (p=0.008 n=5+5)
Trace/100-1000-32     510ns ± 0%   541ns ± 1%   +6.08%  (p=0.008 n=5+5)
Trace/100-10000-32    514ns ± 1%   540ns ± 0%   +5.14%  (p=0.008 n=5+5)
Trace/1000-2-32      17.2µs ± 1%   1.0µs ± 1%  -94.39%  (p=0.008 n=5+5)
Trace/1000-10-32     3.90µs ± 1%  0.64µs ± 0%  -83.68%  (p=0.008 n=5+5)
Trace/1000-100-32     814ns ± 1%   542ns ± 0%  -33.46%  (p=0.008 n=5+5)
Trace/1000-1000-32    503ns ± 1%   581ns ± 0%  +15.56%  (p=0.008 n=5+5)
Trace/1000-10000-32  1.28µs ± 2%  1.03µs ± 1%  -19.68%  (p=0.008 n=5+5)

Change-Id: If7c68bb1809fb92fa5d06cb6640be5e09e1f131f
Reviewed-on: https://go-review.googlesource.com/30374
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-06 21:53:57 +00:00
Mikio Hara
2a824cf922 ipv6: don't refer to cgo-generated union field
The size of sockaddr_storage is fixed for interoperability on each
platform. There is no need to depend on changable cgo-generated
offset values.

Change-Id: I54b775b2a8c86d969a6da0398a335075f0cbe3df
Reviewed-on: https://go-review.googlesource.com/30178
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-06 03:50:05 +00:00
Mikio Hara
534e18705b ipv4: don't refer to cgo-generated union field
The size of sockaddr_storage is fixed for interoperability on each
platform. There is no need to depend on changable cgo-generated
offset values.

Change-Id: I7469fe330d49867bbdbdfae128834140244925ec
Reviewed-on: https://go-review.googlesource.com/30177
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-06 03:49:48 +00:00
Mikio Hara
a7769702ac ipv6: add support for solaris
This change adds support for Solaris.

To read and write IPv6 ancillary data using ControlMessage, ipv6 pacakge
requires https://go-review.googlesource.com/30171/

Note: Unlike other platforms, Solaris seems to have a few restrictions
on ICMP property access via raw IP sockets. At least applications are
prohibited from using IPV6_CHECKSUM option for ICMP transport.

Fixes golang/go#17324.

Change-Id: Ie014665d94ae6e4955c95d3eea88db90332e20bd
Reviewed-on: https://go-review.googlesource.com/30176
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-06 03:49:20 +00:00
Mikio Hara
c8c327cf36 ipv4: add support for solaris
This change adds support for Solaris.

To read and write IPv4 ancillary data using ControlMessage, ipv4 pacakge
requires https://go-review.googlesource.com/30171/

Note: Unlike other platforms, Solaris seems to have a few restrictions
on ICMP property access via raw IP sockets. At least applications are
prohibited from using IP_RECVTTL option for ICMP transport.

Fixes golang/go#17323.

Change-Id: Icb6dfa3c8eced28d14693ddfea4601301999d735
Reviewed-on: https://go-review.googlesource.com/30175
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-06 03:48:57 +00:00
Mikio Hara
ffe101cce3 ipv6: rename thunk_linux_386.s to sys_linux_386.s
Change-Id: I8f05f473bb78336dd1ba788cfa09fc02797eb8dd
Reviewed-on: https://go-review.googlesource.com/30174
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-03 23:52:14 +00:00
Mikio Hara
c67f38167b ipv4: rename thunk_linux_386.s to sys_linux_386.s
Change-Id: I6b58c698527a1ebcb34fd1e08834bb5d7f33f49a
Reviewed-on: https://go-review.googlesource.com/30173
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-03 23:51:52 +00:00
Brad Fitzpatrick
0f2be02c5d http2: remove duplicate map lookups in checkConnHeaders
Change-Id: I3fa5b27a4846807e8ed1265d696929037b77861b
Reviewed-on: https://go-review.googlesource.com/30160
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-03 15:03:54 +00:00
Cezar Sa Espinola
819f4c5391 websocket: use net.Dialer to open tcp connection
This change adds a Dialer field to websocket.Config struct. If this
value is set the Dialer will be used. If it's nil, DialConfig will
create an empty Dialer that will maintain the original behavior.

Because before Go 1.3 there was no crypto/tls.DialWithDialer function,
the Dialer will be ignored when opening TLS connections in these
versions.

Fixes golang/go#9198.

Change-Id: If8b5c3c47019a3d367c436e3e60eb54bf0276184
Reviewed-on: https://go-review.googlesource.com/12191
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-03 02:44:59 +00:00
Ivan Babrou
cd95c68ba2 http2: mention bogus header value in error messages
Change-Id: I69d713341b878a2343bb85fb2de2ef49441fd16d
Reviewed-on: https://go-review.googlesource.com/30098
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-01 18:13:48 +00:00
Sam Whited
1f79cc9b4a trace: spelling consistency tweaks
s/customise/customize/
s/authorisation/authorization/

Change-Id: I23afdca1b773ef9572794555dfb768c9ded90ab8
Reviewed-on: https://go-review.googlesource.com/30159
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-01 16:38:42 +00:00
Brad Fitzpatrick
0d8126fc61 http2: don't sniff Request.Body on 100-continue requests in Transport
Tests in net/http: TestNoSniffExpectRequestBody_h2

Updates golang/go#16002

Change-Id: Ib5255c14f0a8fdafd36077b86442dff213815567
Reviewed-on: https://go-review.googlesource.com/30150
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-01 01:36:18 +00:00
Brad Fitzpatrick
697293012c http2: in Server, disarm connection's ReadTimeout after first request
Fix a regression from Go 1.5 to Go 1.6: when we introduced automatic
HTTP/2 support in Go 1.6, we never handled Server.ReadTimeout. If a
user set ReadTimeout, the net/http package would set the read deadline
on the connection during the TLS handshake, but then the http2 package
would never disarm it, killing the likely-still-in-use connection
after the timeout period.

This CL changes it to disarm the timeout after the first request
headers, similar to net/http.Server.

Unlike net/http.Server, we don't re-arm it on each idle period,
because the definition of idle is more complicated with HTTP/2.

No tests here for now. Tests will be in the go repo once all the knobs
are in place and this is re-bundled into std, testing both http1 and
http2.

Updates golang/go#16450 (minimal fix for now)
Updates golang/go#14204 (considering a new http1+http2 IdleTimeout knob)

Change-Id: Iaa1570c118efda7dc0a65ba84cd77885699ec8fc
Reviewed-on: https://go-review.googlesource.com/30077
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-30 14:21:48 +00:00
Brad Fitzpatrick
a333c534c8 http2: add Transport support for IdleConnTimeout
Tests will be in the go repo's net/http package when this
package is re-bundled into std.

Updates golang/go#16808 (fixes after bundle into std)

Change-Id: Iad31dc120bc008b1e9679bf7b2b988aac9c893c8
Reviewed-on: https://go-review.googlesource.com/30075
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-30 00:27:50 +00:00
Brad Fitzpatrick
8058fc7b18 http: fix build on Go 1.6 and below
https://golang.org/cl/29965 adding ClientConn.Ping support introduced
a build failure on Go versions before 1.7.

Fixes golang/go#17286

Change-Id: Ibfb565e7d823a436e58dc833973d7bdb41b7de5a
Reviewed-on: https://go-review.googlesource.com/30071
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-09-29 20:00:32 +00:00
Olivier Poitrey
ed0556cc88 http2: implement Ping method on ClientConn
This new method sends a PING frame with random payload to the peer and
wait for a PING ack with the same payload.

In order to support cancellation and deadling, the Ping method takes a
context as argument.

Fixes golang/go#15475

Change-Id: I340133a67717af89556837cc531a885d116eba59
Reviewed-on: https://go-review.googlesource.com/29965
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-29 18:27:59 +00:00
ayanamist
fbd690d915 x/net/http2: use request url scheme
The existing implementation has a hardcoded "https" scheme for
all request, since it allows http scheme in the request, it should
use the scheme in the request url.

Fixes golang/go#17257

Change-Id: Ibd9528df0328d7630ee94a006db694645625cdc9
Reviewed-on: https://go-review.googlesource.com/29975
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-29 16:24:05 +00:00
Mikio Hara
9f0e377a8a lif: new package
This change introduces a package that provides basic functions for the
manipulation of logical network interfaces, interface addresses and
data links on Solaris.

As BSD variants implement routing socket and routing messages, Linux
implements netlink socket and netlink messages, Solaris implements
STREAMS-like interface for reading, writing network facility
information inside the kernel. The package wraps various I/O control
calls which involve message exchanges between kernel protocol modules
in exposed APIs.

At present, the package supports Solaris 11 or above.

Updates golang/go#7177.

Change-Id: I192d85e53b0bee942dfefca0f73a3eb94ab8bfe9
Reviewed-on: https://go-review.googlesource.com/29893
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-29 00:31:53 +00:00
Mikio Hara
f09c4662a0 route: fix typo
Change-Id: I41d449e071f1d40bdc69288e7290af168b6b0d3c
Reviewed-on: https://go-review.googlesource.com/29693
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-24 02:07:28 +00:00
Mikio Hara
99a55505f4 ipv4: fix typo
Change-Id: Iaec7505bea3ea29cd58147b6057f03a4c7f0861c
Reviewed-on: https://go-review.googlesource.com/29694
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-24 02:07:15 +00:00
Mikio Hara
6ea239cd4e ipv6: fix typo
Change-Id: I2e0a8f0e344a2fc31b3d40e0b9f3812dbbd75569
Reviewed-on: https://go-review.googlesource.com/29695
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-24 02:06:57 +00:00
Mikio Hara
6d3beaea10 route: test helper code cleanup
Rename method receivers of propVirtual and make the String method of
Inet4Addr use of a pointer receiver.

Change-Id: I422593cf4028d83f856efa55c631f69fdce0514d
Reviewed-on: https://go-review.googlesource.com/28993
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-21 22:18:37 +00:00
Tom Bergan
f4fe4abe3c http2: fix broken tests
testServerResponse had dead code -- it was not checking the return
value from the handler func. This fix revealed two broken tests, which
were also fixed.

Change-Id: I7cd6f6c71dbd909fa3b0aff7f98a47dade42913b
Reviewed-on: https://go-review.googlesource.com/29434
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-20 19:31:15 +00:00