Граф коммитов

1903 Коммитов

Автор SHA1 Сообщение Дата
Damien Neil ef58d90fdf [internal-branch.go1.21-vendor] http2: send correct LastStreamID in stream-caused GOAWAY
When closing a connection because a stream contained a request we
didn't like (for example, because the request headers exceed
the maximum we will accept), set the LastStreamID in the GOAWAY
frame to include the offending stream. This informs the client
that retrying the request is unlikely to succeed, and avoids
retry loops.

This change requires passing the stream ID of the offending
stream from Framer.ReadFrame up to the caller. The most sensible
way to do this would probably be in the error. However,
ReadFrame currently returns a defined error type for
connection-ending errors (ConnectionError), and that type is a
uint32 with no place to put the stream ID. Rather than changing
the returned errors, ReadFrame now returns an error along with
a non-nil Frame containing the stream ID, when a stream is
responsible for a connection-ending error.

Merge conflicts were avoided by cherry-picking CL 576235 (test deflake)
prior to this, and then by squashing CL 576175 (typo fix) into this CL.

For golang/go#66668.
For golang/go#66697.

Change-Id: Iba07ccbd70ab4939aa56903605474d01703ac6e4
Reviewed-on: https://go-review.googlesource.com/c/net/+/576756
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/net/+/578336
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2024-04-12 19:37:43 +00:00
Damien Neil 324dfc12b0 [internal-branch.go1.21-vendor] http2: fix TestServerContinuationFlood flakes
This test causes the server to send a GOAWAY and close a connection.
The server GOAWAY path writes a GOAWAY frame asynchronously, and
closes the connection if the write doesn't complete within 1s.
This is causing failures on some builders, when the frame write
doesn't complete in time.

The important aspect of this test is that the connection be closed.
Drop the check for the GOAWAY frame.

This is a test-only fix that has no effect on the vendored content,
helps tests on this branch, and avoids a merge conflict in next CL.

For golang/go#66697.

Change-Id: I099413be9c4dfe71d8fe83d2c6242e82e282293e
Reviewed-on: https://go-review.googlesource.com/c/net/+/576235
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/net/+/578335
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2024-04-12 19:37:39 +00:00
Damien Neil 947e999f3f [internal-branch.go1.21-vendor] http2: close connections when receiving too many headers
Maintaining HPACK state requires that we parse and process
all HEADERS and CONTINUATION frames on a connection.
When a request's headers exceed MaxHeaderBytes, we don't
allocate memory to store the excess headers but we do
parse them. This permits an attacker to cause an HTTP/2
endpoint to read arbitrary amounts of data, all associated
with a request which is going to be rejected.

Set a limit on the amount of excess header frames we
will process before closing a connection.

Thanks to Bartek Nowotarski for reporting this issue.

Fixes CVE-2023-45288
For golang/go#65051

Change-Id: I15df097268df13bb5a9e9d3a5c04a8a141d850f6
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2130527
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2197243
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-on: https://go-review.googlesource.com/c/net/+/576057
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2024-04-03 17:06:00 +00:00
Damien Neil 1a2eef3ba5 [internal-branch.go1.21-vendor] http2: reject DATA frames after 1xx and before final headers
When checking to see if a DATA frame can be accepted, check to
see if we have received a non-1xx header, not whether we have
received any header.

For golang/go#65927
Fixes golang/go#66254

Change-Id: Id4fae1862de6179f8fc95e02dec7d4c47a7640e1
Reviewed-on: https://go-review.googlesource.com/c/net/+/567175
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/net/+/574855
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-03-27 21:44:20 +00:00
Mauri de Souza Meneguzzo 5ca955b178 [internal-branch.go1.21-vendor] http2: fix underflow in http2 server push
After CL 534215 was merged to fix a CVE it introduced
an underflow when we try to decrement sc.curHandlers
in handlerDone.

The func startPush calls runHandler without incrementing
curHandlers. Seems to only affect users of http.Pusher.

For golang/go#63511
For golang/go#63560

Change-Id: Ic537c27c9945c2c2d4306ddb04e9527b65cee320
GitHub-Last-Rev: 249fe55f75
GitHub-Pull-Request: golang/net#197
Reviewed-on: https://go-review.googlesource.com/c/net/+/535595
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
(cherry picked from commit 37479d671c)
Reviewed-on: https://go-review.googlesource.com/c/net/+/537957
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2023-10-27 15:43:34 +00:00
Damien Neil 695775ce64 [internal-branch.go1.21-vendor] http2: limit maximum handler goroutines to MaxConcurrentStreams
When the peer opens a new stream while we have MaxConcurrentStreams
handler goroutines running, defer starting a handler until one
of the existing handlers exits.

For golang/go#63417.
For golang/go#63427.
For CVE-2023-39325.

Change-Id: If0531e177b125700f3e24c5ebd24b1023098fa6d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2047391
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/net/+/534218
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2023-10-10 17:20:13 +00:00
Damien Neil 57553cbff1 quic: connection ids
Each side of a QUIC connection chooses the connection IDs used by
its peer. In our case, we use 8-byte random IDs.

A connection has a list of connection IDs that it may receive
packets on, and a list that it may send packets to. Add a minimal
data structure for tracking these lists, and handling of the
connection IDs tracked across Initial and Handshake packets.

This does not yet handle post-handshake connection ID changes
made in NEW_CONNECTION_ID and RETIRE_CONNECTION_ID frames.

RFC 9000, Section 5.1.

For golang/go#58547

Change-Id: I3e059393cacafbcea04a1b4131c0c7dc28acad5e
Reviewed-on: https://go-review.googlesource.com/c/net/+/506675
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-07-12 16:29:46 +00:00
Damien Neil 304cc91b19 quic: tracking of received packets and acks to send
RFC 9000, Section 13.2.

For golang/go#58547

Change-Id: I0aad4c03fabb9087964dc9030bb8777d5159360c
Reviewed-on: https://go-review.googlesource.com/c/net/+/506595
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-07-11 21:56:44 +00:00
Damien Neil 9475ce144d quic: fix typos in comments
For golang/go#58547

Change-Id: I79f06d22fc010bf2e339df47abed3df170d18339
Reviewed-on: https://go-review.googlesource.com/c/net/+/506075
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2023-07-11 21:56:35 +00:00
Mateusz Poliwczak d8f9c0143e dns/dnsmessage: add fuzz test
After CL 443215 pack(unpack(msg)) should never fail,
so we can add a fuzz test to prove that.

Change-Id: Ia2abfc30e2b2a492b4dd5de6ca6f29d2324bd737
GitHub-Last-Rev: 1d9812a34c
GitHub-Pull-Request: golang/net#177
Reviewed-on: https://go-review.googlesource.com/c/net/+/500296
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
2023-07-07 17:38:37 +00:00
Mateusz Poliwczak 81261084d0 dns/dnsmessage: update Parser docs
The current API returns ErrSectionDone, not (nil,nil).

Change-Id: I95c721c6c198e7302b9154bc39617b502e3d62f9
GitHub-Last-Rev: c66bcff3b1
GitHub-Pull-Request: golang/net#181
Reviewed-on: https://go-review.googlesource.com/c/net/+/507955
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2023-07-07 01:47:36 +00:00
Leo Blöcher a1613c2230 http2: handle trailing colon in authorityAddr
This change modifies the authorityAddr result for authorities with empty
port information, such as "example.com:". Previously, such authorities
passed through the function unchanged. This conflicts with the result
from net/http's canonicalAddr, which returns "example.com:443" (for
HTTPS).

net/http's canonicalAddr result is passed to http2's upgradeFn (defined
inside http2.configureTransports) from net/http's (*Transport).dialConn.
The connection is then added to http2's cache under the canonicalAddr
key. However, cache lookups are performed in (*Transport).RoundTripOpt
using the result from authorityAddr applied directly to the input URL.
The lookup thus fails if authorityAddr and canonicalAddr don't agree.

http2's lookup error propagates upwards to net/http's
(*Transport).roundTrip, where the request is retried. The end result is
an infinite loop of the request being repeated, each time with a freshly
dialed connection, that can only be stopped by a timeout.

Aligning the results of http2's authorityAddr and net/http's
canonicalAddr fixes the bug. While an authority with a trailing colon is
invalid per URL specifications, I have personally come across
misconfigured web servers emitting such URLs as redirects. This is how I
discovered this issue in http2.

Change-Id: If47aa61b8d256d76a3451090076e6eb5ff596c9e
GitHub-Last-Rev: cb04701157
GitHub-Pull-Request: golang/net#170
Reviewed-on: https://go-review.googlesource.com/c/net/+/487915
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2023-07-05 22:23:14 +00:00
Gopher Robot c73c09c390 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.
Once this CL is submitted, and post-submit testing succeeds on all
first-class ports across all supported Go versions, this repository
will be tagged with its next minor version.

Change-Id: If0420bf8dcbd061d164f2fdafaa45a62a3593f32
Reviewed-on: https://go-review.googlesource.com/c/net/+/507838
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Gopher Robot <gobot@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2023-07-05 14:20:15 +00:00
Brad Fitzpatrick 4fc2eb9973 http2: revert Transport change from CL 486156
https://go.dev/cl/486156 was problematic, breaking applications
like load balancers where cancellations are normal. We tried
reverting only part of that change but it turns out all three of
the cancellation paths tainting the connection were wrong and
could ultimately be triggered by a request cancellation.

We need a different solution for golang/go#59690 which we'll now reopen.

This isn't a straight revert of CL 486156 because subsequent changes
(CL 496335) depended on its cancelRequest closure, so this was
reverted by hand.

Fixes golang/go#60818
Updates golang/go#59690 (no longer fixed)

Change-Id: Ic83b746d7cf89d07655d9efbd04b4d957487cb35
Reviewed-on: https://go-review.googlesource.com/c/net/+/507395
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-07-01 01:58:12 +00:00
Damien Neil 63727cc582 http2: validate Host header before sending
Verify that the Host header we send is valid.
Avoids sending a request that the server will reject,
possibly sending us into a retry loop.

No test in this CL, but this will be covered by the net/http
test added in CL 506996.

For golang/go#60374

Change-Id: I78867eb05293ad8ca1b02bc22fb626760949d4b8
Reviewed-on: https://go-review.googlesource.com/c/net/+/506995
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
2023-06-29 17:00:16 +00:00
Damien Neil 1bb09e6b1e quic: pass the connection ID length into 1-RTT packet parsing
1-RTT packets contain a variable-length connection ID field, but
no indication of the length of the connection ID.  The recipient
of the packet has chosen the connection ID, and is expected to
either choose a consistent length or encode the length in the
connection ID.

Change the parse1RTTPacket function to take the connection ID
length as an input, rather than assuming that all 1-RTT packets
contain our hardcoded connection ID length.

This permits using parse1RTTPacket in tests which may create
and parse packets using other lengths.

For golang/go#58547

Change-Id: I9d09e4a0041051be1604c9146f6db9ca959ad696
Reviewed-on: https://go-review.googlesource.com/c/net/+/504856
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-27 15:03:24 +00:00
Damien Neil 952fc9c67e quic: move ack_delay_exponent handling out of frame parsing
The ACK Delay field of ACK frames contains a duration.
The field contains an integer which is multiplied by two to the
power of the sender's ack_delay_exponent transport parameter to
arrive at the delay in microseconds.

Change the frame parsing and encoding layer to operate on the
unscaled field value, rather than passing the ack_delay_exponent
and a duration. This better expresses the fact that we may
parse an ACK frame without knowing the ack_delay_exponent, if
the ACK is received before transport parameters.

For golang/go#58547

Change-Id: Ic26256761961ce89aea0618b849e5661b0502b12
Reviewed-on: https://go-review.googlesource.com/c/net/+/504855
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-06-27 15:03:13 +00:00
Damien Neil 02fe9a5973 quic: loss detection
Implement the loss detection algorithm from RFC 9002, Section 6.

For golang/go#58547

Change-Id: I9bec21fc0ec1e48f0421f2c365fc17a1b8988b2f
Reviewed-on: https://go-review.googlesource.com/c/net/+/499641
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-06-27 15:02:55 +00:00
Damien Neil c8a2c5a181 quic: remove stray debugging print
For golang/go#58547

Change-Id: Ieca0569b23972d581e3bfc828c28eb2929f62c25
Reviewed-on: https://go-review.googlesource.com/c/net/+/504616
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-21 14:58:03 +00:00
Damien Neil 5d50b4094a quic: add packetFate enum
Packets sent by an endpoint are ultimately acknowledged by the peer
or declared lost. When a packet is acked or lost, we will look
through the data it contained and either mark it as received
by the peer or resend it.

Add an enum for the fate of a sent packet: acked or lost.

Update the sentVal ackOrLoss function to take a packetFate
rather than a bool.

For golang/go#58547

Change-Id: I2e526308db2c03b9c44b59ede1ce84684392c576
Reviewed-on: https://go-review.googlesource.com/c/net/+/504615
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-06-21 14:57:51 +00:00
Damien Neil ee81e8c8e8 quic: correct rttvar updates
RFC errata 7539 adjusts RFC 9002 Section 5.3 to update
rttvar before smoothed_rtt.

https://www.rfc-editor.org/errata/eid7539

For golang/go#58547

Change-Id: I154ed54d3d693c3b42355de39c5907c7cc906fde
Reviewed-on: https://go-review.googlesource.com/c/net/+/502215
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-21 14:57:35 +00:00
Damien Neil ab184e6fa8 quic: rename side type to connSide
The clearest name for vars of this type is often "side",
so make the type name distinct to avoid conflicts.

For golang/go#58547

Change-Id: I35fda7ae70e54cd063bae7a83bcb2c8f5f76244f
Reviewed-on: https://go-review.googlesource.com/c/net/+/501375
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-21 14:57:21 +00:00
Damien Neil 508a5732b4 quic: add congestion controller
Implement the NewReno-derived congestion controller from
RFC 9002, Section 7.

For golang/go#58547

Change-Id: I5280c4ad040be22eb16f79a29d2daf5ba62d1169
Reviewed-on: https://go-review.googlesource.com/c/net/+/499640
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2023-06-21 14:57:06 +00:00
Roland Shoemaker 4050002696 html: handle equals sign before attribute
Apply the correct normalization when an equals sign appears before an
attribute name (e.g. '<tag =>' -> '<tag =="">'), per WHATWG 13.2.5.32.

Change-Id: Id21b428bd86117dd073c502767386bc718a3fb7b
Reviewed-on: https://go-review.googlesource.com/c/net/+/488695
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <nigeltao@google.com>
2023-06-20 17:16:42 +00:00
Russ Cox f5464ddb68 idna: update for Unicode 15.0.0
Changes entirely automated, the result of running

	cd src/golang.org/x/text
	go generate ./...

(which also edits x/net for us).

For golang/go#55079.

Change-Id: I6a638949ff2c53bc98c635e5e3b5ed672b51d71a
Reviewed-on: https://go-review.googlesource.com/c/net/+/503055
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2023-06-13 20:37:45 +00:00
Gopher Robot 6c96ca5daf go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.
Once this CL is submitted, and post-submit testing succeeds on all
first-class ports across all supported Go versions, this repository
will be tagged with its next minor version.

Change-Id: Ifc35b03aeb994b74293ca0b2a4c79940cff8a66c
Reviewed-on: https://go-review.googlesource.com/c/net/+/502795
Run-TryBot: Gopher Robot <gobot@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2023-06-13 13:43:36 +00:00
Damien Neil 5541298b83 quic: add packet pacer
The pacer rate-limits the transmission of packets to avoid
creating bursts that may cause short-term congestion or loss.

See RFC 9002, Section 7.7.

For golang/go#58547

Change-Id: I75285c194a1048f988e4d5a829602d199829669d
Reviewed-on: https://go-review.googlesource.com/c/net/+/499287
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-06-08 16:11:41 +00:00
Bryan C. Mills 88a50b6484 all: update x/sys to HEAD
An update is needed to pull in CL 494856, to allow the bpf test to
build on js and wasip1 after the test changes in CL 501155.

Updates golang/go#55235.
Updates golang/go#57237.

Change-Id: Iff48bad97453932065c27b0c8b4a3706ddcf659a
Reviewed-on: https://go-review.googlesource.com/c/net/+/501615
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-07 16:41:47 +00:00
Damien Neil 7e6923f9c4 quic: add RTT estimator
Implement the round-trip time estimation algorithm from
RFC 9002, Section 5.

For golang/go#58547

Change-Id: I494e692e710f77270c9ad28354366f384feb4ac7
Reviewed-on: https://go-review.googlesource.com/c/net/+/499286
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-06-06 21:48:31 +00:00
Matt Layher 2796e09d6a bpf: check for little endian CPU for OS VM comparison
When I wrote these tests, I assumed the native endianness for the machine
was little endian. Explicitly check this so that the emulated BPF VM tests
can run on s390x, but we avoid test flakes related to endianness.

Updates golang/go#55235.

Change-Id: I9be430dfe7f97503af7a620ed80dcbacb66d73cc
Reviewed-on: https://go-review.googlesource.com/c/net/+/501155
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-06-06 21:42:20 +00:00
Damien Neil 10cf388024 quic: add a data structure for tracking lists of sent packets
Store in-flight packets in a ring buffer.

For golang/go#58547

Change-Id: I825c4e600bb496c2f8f6c195085aaae3e847445e
Reviewed-on: https://go-review.googlesource.com/c/net/+/499285
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2023-06-01 14:35:31 +00:00
Damien Neil ccc217c97e quic: parameterize rangeset
Make the rangeset type parameterized, so it can be used for
either packet number or byte ranges without type conversions.

For golang/go#58547

Change-Id: I764913a33ba58222dcfd36f94de01c2249d73551
Reviewed-on: https://go-review.googlesource.com/c/net/+/499284
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-05-31 22:22:16 +00:00
Damien Neil f16447cf6c quic: add go1.21 build constraint
This package will add on crypto/tls features added in Go 1.21,
so use a build constraint to restrict ourselves to that version.

Unlocks the ability to use other features from Go versions more recent
than what's in x/net's go.mod file.

For golang/go#58547

Change-Id: I14011c7506b047e389d9b3e995c0bafcd5e74d44
Reviewed-on: https://go-review.googlesource.com/c/net/+/499283
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-05-31 16:06:39 +00:00
Damien Neil f7250ea19d quic: add a type tracking sent values
Any given datum communicated to the peer follows a state machine:

  - We do not need to send the this datum.
  - We need to send it, but have not done so.
  - We have sent it, but the peer has not acknowledged it.
  - We have sent it and the peer has acknowledged it.

Data transitions between states in a consistent fashion; for example,
loss of the most recent packet containing a HANDSHAKE_DONE frame
means we should resend the frame in a new packet.

Add a sentVal type which tracks this state machine.

For golang/go#58547

Change-Id: I9de0ef5e482534b8733ef66363bac8f6c0fd3173
Reviewed-on: https://go-review.googlesource.com/c/net/+/498295
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-25 18:03:53 +00:00
Damien Neil 1b5a2d8538 quic: packet encoding/decoding
Frame encoding is handled by the packetWriter type.
The packetWriter also takes responsibility for recording the contents
of constructed packets in a sentPacket structure.

Frame decoding is handled by consume*Frame functions, which generally
return the frame contents. ACK frames, which have complex contents,
are provided to the caller via callback function.

In addition to the above functions, used in the serving path, this
CL includes per-frame types that implement a common debugFrame
interface.  These types are used for tests and debug logging, but
not in the serving path where we want to avoid allocations from
storing values in an interface.

For golang/go#58547

Change-Id: I03ce11210aa9aa6ac749a5273b2ba9dd9c6989cf
Reviewed-on: https://go-review.googlesource.com/c/net/+/495355
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-25 17:52:56 +00:00
Damien Neil a233290d30 quic: add a data structure for tracking sent packets
When we send a packet, we need to remember its contents until it has
been acked or detected as lost.

For golang/go#58547

Change-Id: I8c18f7ca1730a3ce460cd562d060dd6c7cfa9ffb
Reviewed-on: https://go-review.googlesource.com/c/net/+/495236
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-25 17:52:47 +00:00
Damien Neil 61d852e7b0 quic: error codes and types
Constants for the transport error codes in RFC 9000 Section 20,
types representing transport errors sent to or received from the peer,
and a type representing application protocol errors.

For golang/go#58547

Change-Id: Ib4325e1272f6e0984f233ef494827a1799d7dc26
Reviewed-on: https://go-review.googlesource.com/c/net/+/495235
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2023-05-25 17:52:39 +00:00
Damien Neil d40f1541f7 quic: varint encoding and decoding
Functions to encode and decode QUIC variable-length integers
(RFC 9000, Section 16), as well as a few other common operations.

For golang/go#58547

Change-Id: I2a738e8798b8013a7b13d7c1e1385bf846c6c2cd
Reviewed-on: https://go-review.googlesource.com/c/net/+/478258
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-05-25 17:52:27 +00:00
Damien Neil 10d90690bc quic: add rangeset type
A rangeset is an ordered list of non-overlapping int64 ranges.
This type will be used for tracking which packet numbers need to be
acknowledged and which parts of a stream have been sent/received.

For golang/go#58547

Change-Id: Ia4ab3a47e82d0e7aea738a0f857b2129d4ea1f63
Reviewed-on: https://go-review.googlesource.com/c/net/+/478295
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-05-25 17:52:15 +00:00
Damien Neil f71a821cfa quic: packet protection
Encrypt and decrypt QUIC packets according to RFC 9001.

For golang/go#58547

Change-Id: Ib7f824cf08f8520400bd38d3b3ab89e8a968114e
Reviewed-on: https://go-review.googlesource.com/c/net/+/475438
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-05-25 17:52:06 +00:00
Damien Neil 6488c8f457 quic: basic packet operations
The type of a QUIC packet can be identified by inspecting its first
byte, and the destination connection ID can be determined without
decrypting and parsing the entire packet.

For golang/go#58547

Change-Id: Ie298c0f6c0017343168a0974543e37ab7a569b0f
Reviewed-on: https://go-review.googlesource.com/c/net/+/475437
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-05-25 17:13:16 +00:00
Damien Neil d4a2c13d06 quic: packet number encoding/decoding
QUIC packet numbers are integers in the range [0, 2^62).
Packet numbers are encoded as the 1-4 least significant bytes
of the full number, with the remaining bytes extrapolated based
on the largest packet number seen by the receiver.

RFC 9000, Section 17.1.

For golang/go#58547

Change-Id: I9e111fe6c9c437fdcd9dc57336e094512c0b52b0
Reviewed-on: https://go-review.googlesource.com/c/net/+/475436
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-05-25 17:13:07 +00:00
Damien Neil 0d6f3cba5e quic: add various useful common constants and types
For golang/go#58547

Change-Id: I178373329de20fe8e1b3d256638f0ae7ab366d03
Reviewed-on: https://go-review.googlesource.com/c/net/+/475435
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2023-05-25 17:12:55 +00:00
Damien Neil ee6956ff9f quic: add internal/quic package
This package will eventually contain an implementation of the QUIC
protocol. Place it under internal/ to begin with to avoid accidental
use while it is in an incomplete state.

For golang/go#58547

Change-Id: Ib3526e0bbe433e91283859913818d3e72fc194b6
Reviewed-on: https://go-review.googlesource.com/c/net/+/468402
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-05-25 17:12:40 +00:00
Damien Neil 6826f5a7db http2: close request bodies before RoundTrip error return
When returning an error from RoundTrip, wait for the close
of the request body to complete before returning.

This avoids a race between the HTTP/2 transport closing
the request body and the net/http retry loop examining
the readTrackingBody to see if it has been closed.

For golang/go#60041

Change-Id: I8be69ff5056806406716e01e02d1f631deeca088
Reviewed-on: https://go-review.googlesource.com/c/net/+/496335
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-05-24 21:30:25 +00:00
Mateusz Poliwczak ca96da6018 dns/dnsmessage: reject names with dots inside label
Fixes golang/go#56246

Change-Id: I9c8d611d1305536a7510bf6c4a02a5e551aa657a
GitHub-Last-Rev: 8a8703a1a7
GitHub-Pull-Request: golang/net#154
Reviewed-on: https://go-review.googlesource.com/c/net/+/443215
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
2023-05-24 18:47:04 +00:00
Damien Neil 056145cf62 net/http: deflake TestTransportRetryAfterGOAWAY
Drop a redundant Close of a net.Conn.

On Windows, writing to a closed connection will cause future
reads from the connection to fail, even if there is buffered
data available. When the test server writes a GOAWAY frame and
immediately closes the connection, this can result in the client
never seeing the GOAWAY. To avoid this, don't close server
connections until after all test functions have returned.

Fixes golang/go#59919

Change-Id: I82ed15870f3e6cd47f833a7a60b007b2fa2e15b0
Reviewed-on: https://go-review.googlesource.com/c/net/+/496056
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-05-19 22:58:44 +00:00
Damien Neil abee42a2ab http2: deflake TestTransportReuseAfterError
This test issues a request with a short timeout, and expects that
the request timing out will result in the connection it was sent
on being marked as unusable.

However, it is possible for the request to time out before it is
sent, with no effect on the connection. The test's next request
then uses the same connection and hangs.

Rather than a timeout, cancel the request after it is received
on the server.

Fixes golang/go#59934

Change-Id: I1144686377158d0654e0f91a1b0312021a02a01d
Reviewed-on: https://go-review.googlesource.com/c/net/+/496055
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2023-05-18 16:34:21 +00:00
Nick Figgins 3b31286d86 ipv4,ipv6: remove unneeded deadlines added for flaky tests
Deadlines were added in https://go.dev/cl/21360043, but these are
unneeded as the tests will fail anyways as a result of the timeout.
This prevents these timeouts from causing further test flakes.

Fixes #58955

Change-Id: I76ebf7452bf326a09f1a7665d362fe68f345a4be
GitHub-Last-Rev: 9ca732a5ea
GitHub-Pull-Request: golang/net#172
Reviewed-on: https://go-review.googlesource.com/c/net/+/492620
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-05-16 21:31:51 +00:00
Laurent Senta 23ce3b89bc http2: disable Content-Length when nilled
Change-Id: Iefef8dc1004a8e889d0e9f7243f594ae7b727a07
Reviewed-on: https://go-review.googlesource.com/c/net/+/471535
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2023-05-15 17:07:19 +00:00