Commit Graph

2011 Commits

Author SHA1 Message Date
Gopher Robot
cb5b10f0bb go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I77f3c5560bd989f4e9c6b8c3f36e900fefe9bb0e
Reviewed-on: https://go-review.googlesource.com/c/net/+/554675
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.20.0
2024-01-08 18:08:52 +00:00
Damien Neil
689bbc7005 quic: deflake TestStreamsCreateConcurrency
This test assumed that creating a stream and flushing it on the
client ensured the server had accepted the stream. This isn't
the case; the stream has been delivered to the server, but there's
no guarantee that it been accepted by the user layer.

Change the test to make a full loop: The client creates a stream,
and then waits for the server to close it.

Fixes golang/go#64788

Change-Id: I24f08502e9f5d8bd5a17e680b0aa19dcc2623841
Reviewed-on: https://go-review.googlesource.com/c/net/+/554175
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-01-04 19:50:13 +00:00
Damien Neil
f12db26b1c internal/quic/cmd/interop: use wget --no-verbose in Dockerfile
Pass --no-verbose to wget to avoid spamming the build logs with
progress indicators.

Change-Id: I36a0b91f8dac09cc4055c5d5db3fc61c9b269d6e
Reviewed-on: https://go-review.googlesource.com/c/net/+/551495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-12-19 21:36:31 +00:00
Damien Neil
c136d0c937 quic: avoid panic when PTO expires and implicitly-created streams exist
The streams map contains nil entries for implicitly-created streams.
(Receiving a packet for stream N implicitly creates all streams of the
same type <N.)

We weren't checking for nil entries when iterating the map on PTO,
resulting in a panic.

Change the map value to be a wrapper type to make it more explicit that
nil entries exist.

Change-Id: I070c6d60631744018a6e6f2645c95a2f3d3d24b6
Reviewed-on: https://go-review.googlesource.com/c/net/+/550798
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-19 18:24:40 +00:00
Damien Neil
f9726a9e4a quic: fix packet size logging
The qlog schema puts packet sizes as part of a "raw" field
of type RawInfo, not in the packet_sent/packet_received event.
Move to the correct location.

Change-Id: I4308d4bdb961cf83e29af014b60f50ed029cb915
Reviewed-on: https://go-review.googlesource.com/c/net/+/550797
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-12-19 00:11:13 +00:00
Damien Neil
c337daf7db quic: enable qlog output in tests
Set QLOG=/some/dir to enable qlog logging in tests.

Change-Id: Id4006c66fd555ad0ca47914d0af9f9ab46467c9c
Reviewed-on: https://go-review.googlesource.com/c/net/+/550796
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-19 00:11:06 +00:00
Damien Neil
2b416c3c96 quic/qlog: create log files with O_EXCL
Avoid confusing log corruption if two loggers try to write
to the same file simultaneously.

Change-Id: I3bfbcf56aa55c778ada0178d7c662c414878c9d1
Reviewed-on: https://go-review.googlesource.com/c/net/+/545577
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-18 17:09:42 +00:00
Damien Neil
1e59a7e58c quic/qlog: correctly write negative durations
"-10.000001", not "10.-000001".

Change-Id: I84f6487bad15ab3a190e73e655236376b1781e85
Reviewed-on: https://go-review.googlesource.com/c/net/+/545576
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-18 17:09:33 +00:00
Damien Neil
b0eb4d6c94 quic: compute pnum len from max ack received, not sent
QUIC packet numbers are truncated to include only the least
significant bits of the packet number. The number of bits
which must be retained is computed based on the largest
packet number known to have been received by the peer.
See RFC 9000, section 17.1.

We were incorrectly using the largest packet number
we have received *from* the peer. Oops.

(Test infrastructure change: Include the header byte
in the testPacket structure, so we can see how many
bytes the packet number was encoded with. Ignore this
byte when comparing packets.)

Change-Id: Iec17c69f007f8b39d14d24b0ca216c6a0018ae22
Reviewed-on: https://go-review.googlesource.com/c/net/+/545575
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-18 17:09:24 +00:00
Damien Neil
b952594c26 quic: fix data race in connection close
We were failing to hold streamsState.streamsMu when removing
a closed stream from the conn's stream map.

Rework this to remove the mutex entirely.
The only access to the map that isn't on the conn's loop is
during stream creation. Send a message to the loop to
register the stream instead of using a mutex.

Change-Id: I2e87089e87c61a6ade8219dfb8acec3809bf95de
Reviewed-on: https://go-review.googlesource.com/c/net/+/545217
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-12-18 17:09:09 +00:00
Damien Neil
577e44a5ce quic: skip leaked goroutine check on GOOS=js
Fixes golang/go#64620

Change-Id: I3b5ff4d1e1132a47b7cc7eb00861e9f7b76f8764
Reviewed-on: https://go-review.googlesource.com/c/net/+/548455
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-08 16:07:49 +00:00
Damien Neil
65efbad947 quic: avoid leaking tls goroutines in tests
Change-Id: Iaf273294ba3245bfeb387a72e068c048d0fcf93a
Reviewed-on: https://go-review.googlesource.com/c/net/+/547736
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-07 01:27:06 +00:00
Damien Neil
08a78b1eea quic: unblock operations when closing conns
Blocking operations associated with a connection,
such as accepting a stream or writing data to a stream,
should be canceled when the connection is closed.

Change-Id: I3b25789885a6c1a2b5aa2178a8d6219a8ea77cbb
Reviewed-on: https://go-review.googlesource.com/c/net/+/545216
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2023-12-05 23:17:45 +00:00
Damien Neil
c1b6eee3f6 quic: send occasional ack-eliciting packets
A receiver that is sending only non-ack-eliciting packets
(for example, a connection reading data from a stream but not sending
anything other than ACKs in response) can accumulate a large amount
of state for in-flight, unacknowledged packets.

Add an occasional PING frame when in this state, to cause the peer
to send an ACK for our outstanding packets.

Change-Id: Iaf6b5a9735fa356fdebaff24200420a280b0c9a5
Reviewed-on: https://go-review.googlesource.com/c/net/+/545215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-12-05 20:38:13 +00:00
Damien Neil
491f354593 quic: log packets and frames
For golang/go#58547

Change-Id: I601f1e74417c0de206f71da58cef5938bba6e860
Reviewed-on: https://go-review.googlesource.com/c/net/+/543084
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-05 20:38:03 +00:00
Roland Shoemaker
f812076c5d http2: explicitly set minimum TLS version in tests
Fixes tests when using 1.22 in certain cases where the go.mod 'go'
directive is not being respected.

Change-Id: Ia986a7c900287abd67f0a05f662906a665cdeb87
Reviewed-on: https://go-review.googlesource.com/c/net/+/546115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2023-11-29 21:54:09 +00:00
Gopher Robot
a8e0109124 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: Ia3b446633ffc0b3264692cfaae765bfb79063dab
Reviewed-on: https://go-review.googlesource.com/c/net/+/545175
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.19.0
2023-11-27 17:26:17 +00:00
Damien Neil
13e88dd2f7 quic: rename listener{_test}.go to endpoint{_test}.go
Separate from CL 543298 to help git recognize that this is a rename.

Change-Id: I1cbdffeb66d0960c951a564b8fc1a3dcf2cf40f6
Reviewed-on: https://go-review.googlesource.com/c/net/+/543299
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-17 21:35:08 +00:00
Damien Neil
e26b9a4457 quic: rename Listener to Endpoint
The name Listener is confusing, because unlike a net.Listener
a quic.Listener manages outgoing connections as well as inbound ones.

Rename to "endpoint" which doesn't map to any existing
net package name and matches the terminology of the QUIC RFCs.

For golang/go#58547

Change-Id: If87f8c67ac7dd15d89d2d082a8ba2c63ea7f6e26
Reviewed-on: https://go-review.googlesource.com/c/net/+/543298
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-17 21:33:25 +00:00
Damien Neil
399218d6bc quic: implement stream flush
Do not commit data written to a stream to the network until
the user explicitly flushes the stream, the stream output
buffer fills, or the output buffer contains enough data to
fill a packet.

We could write data immediately (as net.TCPConn does),
but this can require the user to put their own buffer in
front of the stream. Since we necessarily need to maintain
a retransmit buffer in the stream, this is redundant.

We could do something like Nagle's algorithm, but nobody
wants that.

So make flushes explicit.

For golang/go#58547

Change-Id: I29dc9d79556c7a358a360ef79beb38b45040b6bc
Reviewed-on: https://go-review.googlesource.com/c/net/+/543083
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-17 18:40:32 +00:00
Damien Neil
d87f99be5d quic: idle timeouts, handshake timeouts, and keepalive
Negotiate the connection idle timeout based on the sent and received
max_idle_timeout transport parameter values.

Set a configurable limit on how long a handshake can take to complete.

Add a configuration option to send keep-alive PING frames to avoid
connection closure due to the idle timeout.

RFC 9000, Section 10.1.

For golang/go#58547

Change-Id: If6a611090ab836cd6937fcfbb1360a0f07425102
Reviewed-on: https://go-review.googlesource.com/c/net/+/540895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-17 18:04:24 +00:00
Damien Neil
7b5abfaf7f quic: basic qlog support
Add the structure for generating and writing qlog events.

Events are generated as slog events using the structure of
the qlog events (draft-ietf-quic-qlog-quic-events-03).

The qlog package contains a slog Handler implementation
that converts the quic package events to qlog JSON.

This CL generates events for connection creation and closure.
Future CLs will add additional events.

Events follow draft-ietf-quic-qlog-quic-events-03, which
is the most recent draft supported by the qvis visualization
tool.

https://www.ietf.org/archive/id/draft-ietf-quic-qlog-main-schema-04.html
https://www.ietf.org/archive/id/draft-ietf-quic-qlog-quic-events-03.html

For golang/go#58547

Change-Id: I5fb1b7653d0257cb86726bd5bc9e8775da74686a
Reviewed-on: https://go-review.googlesource.com/c/net/+/537936
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-17 16:13:12 +00:00
Gopher Robot
fbaf41277f go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I828e052f9d32ff73d75d07087fcd25c8ed61d9de
Reviewed-on: https://go-review.googlesource.com/c/net/+/540816
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.18.0
2023-11-08 19:35:18 +00:00
Brad Fitzpatrick
cc6f4d19f5 http2: remove ancient build-tagged files for unsupported Go versions
x/net requires Go 1.18. No need to keep untested Go 1.11, Go 1.15, etc
support around.

Change-Id: I3588d273b543dec9ca120894ab36255f845abc20
Reviewed-on: https://go-review.googlesource.com/c/net/+/540236
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Christopher Taylor <ccmtaylor@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-08 17:54:49 +00:00
Jorropo
a720b30cbc http2: allocate buffer pools using pointers to arrays
This remove the allocation for the slice header in sync.Pool.New and putDataBufferChunk.
It also divide the number of allocations kept alive by the pool.

Change-Id: Icf493ebc568ae80a4e73e9768a6f1c7fce8e1365
Reviewed-on: https://go-review.googlesource.com/c/net/+/539915
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
2023-11-07 21:56:53 +00:00
Damien Neil
a7ef1a2680 internal/quic/cmd/interop: don't t.Log after test finishes
Fixes golang/go#63971

Change-Id: I795356202880daa2d4a0cfd019c542e5820e8020
Reviewed-on: https://go-review.googlesource.com/c/net/+/539857
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-07 18:09:47 +00:00
qmuntal
26ea8175a1 http2: unconditionally recycle responseWriterState
CL 46008 fixed golang/go#20704 by not recycling the responseWriterState
if any previous Write call failed, as there could be outstanding
goroutines referencing the responseWriterState memory.

More recently, CL 467355 fixed a variant of the same issue by not
referencing that memory after exiting the Write call. This fix
supersedes the fix in CL 46008, as it is more general and does not
require the caller to know whether any previous Write calls failed.

This CL partially reverts CL 46008 just leaving the test case to ensure
that golang/go#20704 does not regress.

Change-Id: I18ea4d27420265a94cc7af21f1dffa3f7dc3bd34
Reviewed-on: https://go-review.googlesource.com/c/net/+/534315
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Commit-Queue: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-11-06 21:52:15 +00:00
Damien Neil
39c9d01355 quic: don't send CONNECTION_CLOSE after stateless reset
After receiving a stateless reset, we must enter the draining
state and send no further packets (including CONNECTION_CLOSE).
We were sending one last CONNECTION_CLOSE after the user
closed the Conn; fix this.

RFC 9000, Section 10.3.1.

Change-Id: I6a9cc6019470a25476df518022a32eefe0c50fcd
Reviewed-on: https://go-review.googlesource.com/c/net/+/540117
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-06 20:51:22 +00:00
Damien Neil
45fa414209 quic: undo accidental rename of test helpers
https://go.dev/cl/539341 inadvertently made the
newLocalConnPair and newLocalListener helpers exported.
These are test-only functions, so the change isn't really important,
but undo the rename to keep them consistent with other test helpers.

Change-Id: Ie3860db3584fc83c0c0aa2ad0dda4cc5cb03351a
Reviewed-on: https://go-review.googlesource.com/c/net/+/540116
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-06 20:51:14 +00:00
Damien Neil
434956a1a8 quic: include more detail in connection close errors
When closing a connection with an error, include a reason
string in the CONNECTION_CLOSE frame as well as the
error code, when the code isn't sufficient to explain the error.

Change-Id: I055a4e11b222e87d1ff01d8c45fcb7cc17fe4196
Reviewed-on: https://go-review.googlesource.com/c/net/+/539342
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-06 18:06:55 +00:00
Damien Neil
ec29a9498a quic: provide source conn ID when creating server conns
New server-side conns need to know a variety of connection IDs,
such as the Initial DCID used to create Initial encryption keys.
We've been providing these as an ever-growing list of []byte
parameters to newConn. Bundle them all up into a struct.

Add the client's SCID to the set of IDs we pass to newConn.
Up until now, we've been setting this when processing the
first Initial packet from the client. Passing it to newConn
will makes it available when logging the connection_started event.

Update some test infrastructure to deal with the fact that
we need to know the peer's SCID earlier in the test now.

Change-Id: I760ee94af36125acf21c5bf135f1168830ba1ab8
Reviewed-on: https://go-review.googlesource.com/c/net/+/539341
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-06 18:06:44 +00:00
Damien Neil
5791239e3d internal/quic/cmd/interop: skip tests when exec is unavailable
Some platforms, such as js and wasip1, can't exec.
Skip tests that need exec when it isn't available.

Change-Id: Id3787b28c2ffe780eb24800c59fe69d12e04bbdd
Reviewed-on: https://go-review.googlesource.com/c/net/+/539035
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-01 21:30:58 +00:00
Damien Neil
4865e2af27 internal/quic/cmd/interop: add interop test runner
The QUIC interop tests at https://interop.seemann.io/
invoke a program and instruct it to perform some set
of operations (mostly serve files from a directory,
or download a set of files).

The cmd/interop binary executes test cases for our
implementation.

For golang/go#58547

Change-Id: Ic1c8be2f3f49a30464650d9eaa5ded74c92fa5a7
Reviewed-on: https://go-review.googlesource.com/c/net/+/532435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2023-10-31 21:19:14 +00:00
Damien Neil
770149e988 quic: pad ack-eliciting server Initial datagrams
UDP datagrams containing Initial packets are expanded to 1200 bytes
to validate that the path is capable of supporting the smallest
allowed maximum QUIC datagram size.

(In addition, client Initial packets must be sent in datagrams
of at least 1200 bytes, to defend against amplification attacks.)

We were expanding client datagrams containing Initial packets,
but not server datagrams. Fix this. (More specifically, server
datagrams must be expanded to 1200 bytes when they contain
ack-eliciting Initial packets.)

RFC 9000, Section 14.1.

Change-Id: I0c0c36321c055e960be3e29a49d7cb7620640b82
Reviewed-on: https://go-review.googlesource.com/c/net/+/538776
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-31 21:05:27 +00:00
Damien Neil
05086a79fc quic: fix panic when handling resent CRYPTO data
When pipe.discardBefore was called with an offset greater
than the current pipe.end position, we would update
pipe.start but not pipe.end, leaving the pipe in an
inconsistent state where start > end. This could then
subsequently cause a panic when writing data that
lies before pipe.start.

This sequence occurs when handling several in-order
CRYPTO frames (where we skip writing in-order data
to the pipe, but still call discardBefore), followed
by an out-of-order frame containing resent data.

Change-Id: Ibac0caad53cd30dac1cd4719a825226809872d96
Reviewed-on: https://go-review.googlesource.com/c/net/+/538775
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-10-31 18:01:49 +00:00
Damien Neil
0526b49b34 quic: fix data race caused by aliased DCID
The initServer function was retaining a reference to a []byte that
aliases a packet buffer, which is subsequently recycled.

Make a copy of the data before retaining it.

Fixes golang/go#63783

Change-Id: I3dbb0cdfd78681014dec97ff9909ff6c7dbf82ba
Reviewed-on: https://go-review.googlesource.com/c/net/+/538615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-10-30 20:00:15 +00:00
Damien Neil
6d267b1f96 quic: properly shut down connections on listener close
We were failing to add new connections to the listener's set of
live connections, so closing a listener wouldn't abort connections
or wait for them to shut down.

We were also aborting active connections with an error that resulted
in the connection closing with an INTERNAL_ERROR status. Close with
NO_ERROR instead.

For golang/go#58547

Change-Id: I89b6c4fabf744ae5178c0cae655929db1ae40ee4
Reviewed-on: https://go-review.googlesource.com/c/net/+/537935
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-30 17:55:29 +00:00
Damien Neil
642f15ebba quic: support stateless reset
Add a StatelessResetKey config field to permit
generating consistent stateless reset tokens
across server restarts.

Set the stateless_reset_token transport parameter
and populate the Token field in NEW_CONNECTION_ID
frames.

Detect reset tokens in datagrams which cannot
be associated with a connection or cannot be parsed.

RFC 9000, Section 10.3.

For golang/go#58547

Change-Id: Idb52ba07092ab5c08b323d6b531964a7e7e5ecea
Reviewed-on: https://go-review.googlesource.com/c/net/+/536315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2023-10-27 18:36:19 +00:00
Damien Neil
4c7a5b64f1 http2: add test for push promise accounting underflow
Verify that repeated requests resulting in a PUSH_PROMISE result
all complete successfully, validating the fix in CL 535595.

For golang/go#63511

Change-Id: I6bebdcfcecb6c53f076e4ac6873d61a150d1040e
Reviewed-on: https://go-review.googlesource.com/c/net/+/537715
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-25 18:07:29 +00:00
Damien Neil
48a597731c quic: support Retry
Add a RequireAddressValidation configuration setting to enable
sending Retry packets on the server.

Support receiving Retry packets on the client.

RFC 9000, Section 8.1.2.

For golang/go#58547

Change-Id: Ia78b9594a03ce1b1143b95cb3c1ef4c38b2b39ef
Reviewed-on: https://go-review.googlesource.com/c/net/+/535237
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-10-23 22:24:13 +00:00
Damien Neil
9ef1b7226a quic: move more testConn behavior into testListener
Refactor the testConn/testListener relationship some.
Move synthetic time tracking into the listener.
Let the testListener create testConns.

These changes will allow us to test Retry behavior,
where the listener responds to a new connection request
with a Retry packet, and only initiates the connection
upon receiving a valid Retry token.

For golang/go#58547

Change-Id: Ib6fc86a21819059f2a603fa6c9be14ab87a7a44c
Reviewed-on: https://go-review.googlesource.com/c/net/+/535236
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-23 22:24:06 +00:00
Mauri de Souza Meneguzzo
37479d671c 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

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>
2023-10-23 20:37:47 +00:00
Dmitri Shuralyov
d23d9bc549 all: update go directive to 1.18
Done with:

go get go@1.18
go mod tidy
go fix ./...

Using go1.21.3.

With a manual change to keep golang.org/x/net/context testing itself,
not context in the standard library.

For golang/go#60268.

Change-Id: I00682bf7cf1e3ba4370e2a3e7f63dc245b294a36
Reviewed-on: https://go-review.googlesource.com/c/net/+/534241
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2023-10-11 21:58:12 +00:00
Mateusz Poliwczak
92728b3b3c dns/dnsmessage: document that Skip does not fully validate the header
The Skip methods do not fully validate the name in header,
the compression pointers are not followed

Change-Id: If34a041d799a22117afac9bd23e76606f5d0c8f7
GitHub-Last-Rev: f8f2586fb2
GitHub-Pull-Request: golang/net#196
Reviewed-on: https://go-review.googlesource.com/c/net/+/534175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-10-11 16:52:37 +00:00
Damien Neil
b225e7ca6d 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.

Fixes golang/go#63417
Fixes CVE-2023-39325

Change-Id: If0531e177b125700f3e24c5ebd24b1023098fa6d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2045854
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/net/+/534215
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
v0.17.0
2023-10-10 15:45:19 +00:00
Gopher Robot
88194ad8ab go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I6a03cb993ffb84dff46b8cdcade2198da0491bd5
Reviewed-on: https://go-review.googlesource.com/c/net/+/533115
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
v0.16.0
2023-10-05 16:33:35 +00:00
Damien Neil
2b60a61f1e quic: fix several bugs in flow control accounting
Connection-level flow control sets a bound on the total maximum
stream offset of all data sent, not the total amount of bytes sent
in STREAM frames. For example, if we send the bytes [0,10) for a
stream, and then retransmit the same bytes due to packet loss,
that consumes 10 bytes of connection-level flow, not 20.

We were incorrectly tracking total bytes sent. Fix this.

We were blocking retransmission of data in lost STREAM frames
on availability of connection-level flow control.
We now place a stream with retransmitted data on queueMeta
(non-flow-controlled data), since we have already
accounted for the flow control window consumption of the
data.

We were incorrectly marking a stream as being able to send
an empty STREAM frame with a FIN bit, when the stream was
actually blocked on stream-level flow control. Fix this.

For golang/go#58547

Change-Id: Ib2ace94183750078a19d945256507060ea786735
Reviewed-on: https://go-review.googlesource.com/c/net/+/532716
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-10-05 16:21:57 +00:00
Damien Neil
73d82efb96 quic: handle DATA_BLOCKED frames
We never send DATA_BLOCKED frames, and ignore ones sent by the peer,
but we do need to parse them.

For golang/go#58547

Change-Id: Ic9893245108fd1c32067d14811e2d44488ce1ab5
Reviewed-on: https://go-review.googlesource.com/c/net/+/532715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-10-05 16:21:24 +00:00
Damien Neil
5d5a036a50 quic: handle streams moving from the data queue to the meta queue
In Conn.appendStreamFrames, a stream can be moved from the
data queue (for streams with only flow-controlled frames to send)
to the metadata queue (for streams with non-flow-controlled frames
to send) if some other goroutine asynchronously modifies the
stream state.

Adjust the check at the end of this function to clear the needSend
bool only if queueMeta and queueData are both empty, to avoid
losing track of the need to send frames when this happens.

For golang/go#58547

Change-Id: Ib9ad3b01f543cd7673f5233ceb58b2db9adfff5a
Reviewed-on: https://go-review.googlesource.com/c/net/+/531656
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-10-04 22:08:37 +00:00
Damien Neil
350aad2603 quic: correctly extend peer's flow control window after MAX_DATA
When sending the peer a connection-level flow control update in
a MAX_DATA frame, we weren't recording the updated limit locally.
When the peer wrote data past the old limit, we would incorrectly
close the connection with a FLOW_CONTROL_ERROR.

For golang/go#58547

Change-Id: I6879c0cccc3cfdc673b613a07b038138d9e285ff
Reviewed-on: https://go-review.googlesource.com/c/net/+/530075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-10-03 17:58:44 +00:00