Open Bug 2071358 Opened 2 months ago Updated 2 days ago

Establish the inner connection through an outer connection via Happy Eyeballs

Categories

(Core :: Networking, task, P2)

task

Tracking

()

People

(Reporter: kershaw, Assigned: kershaw)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(16 external files, 1 obsolete file)

Bug 2053088 handed the outer proxy connection to Happy Eyeballs, but the inner connection through the CONNECT tunnel is still established synchronously by the real transaction.
We'd like to race the tunnel endpoints (HTTP/3 against an HTTP/2 fallback) and publishes the first usable connection.

Removing a stream from the session's queues left its queued flags set, so
StreamReadyToWrite silently refused to schedule it again and QueueStream would
assert: a CONNECT-UDP tunnel stream, which FinishTunnelSetup removes while the
inner connection still has datagrams waiting, then never sent them. Clear both
flags on removal, and drain a queue into a local array before putting streams
back, because popping can release a stream's last reference and that teardown
re-enters the removal with a half-rotated deque. Hold a reference to the
session across Close for the same reason.

The inner session's first Initial is generated while the outer connection may
still be negotiating, and Http3Session::ProcessOutput treats a send failure as
fatal, so refusing the datagram tears down the connection that produced it.
Only fail once the stream is SEND_DONE and queue otherwise; OnProcessDatagram
flushes after activation.

Depends on D325811

Http2StreamTunnel inherits nsISupports through both Http2StreamBase and
nsISocketTransport, and its interface map had no entry for it, so
NS_INTERFACE_MAP_END asserted on any QueryInterface for nsISupports. Resolve it
through Http2StreamBase to match the refcounting, and drop a duplicated
nsITransport entry.

Depends on D325812

Http2StreamBase only moves bytes while the session holds its segment
reader/writer, so a consumer whose I/O lands after the OnSocketReady callback
returns -- anything copying through NS_AsyncCopy -- never makes progress and
spins the socket thread. Hold one chunk over in each direction so such a write
or read succeeds, and send or serve it from the next window.

Depends on D325813

Move DefaultHappyEyeballsConnMgrDelegate into its own file, hoist the attempt
timer from HappyEyeballsConnectionAttempt into ConnectionAttempt, and extract
ConnectionAttemptPool::AdoptConnectionAttempt and
ConnectionEstablisher::HandsOverBareConnection. Also let a caller override
network.http.happy_eyeballs_connection_attempt_delay, which an inner connection
through a CONNECT tunnel needs. No behaviour change.

Depends on D325814

An origin reached through a CONNECT proxy had its inner connection created
synchronously, with the real transaction driving the CONNECT: one endpoint, no
racing and no fallback. InnerConnectionAttempt runs a Happy Eyeballs machine of
its own over the tunnel, giving each endpoint an InnerConnectionEstablisher and
a TunnelSetupTransaction to own the CONNECT, and publishes the first usable
connection while the real transaction waits in the pending queue. Gated on
network.http.happy_eyeballs_tunnel_enabled.

Depends on D325815

A connect-only channel wants the CONNECT'd tunnel itself, and through a
multiplexed proxy it never got one: the outer connection tore its own HTTP/2
session down before any tunnel existed, and the setup driver consumed the
CONNECT response the channel needs. Narrow the connect-only handling in
nsHttpConnection to the connection that issues the CONNECT and to the real
transaction, hand the response to that transaction, and stop driving I/O while
the consumer takes the transport over.

Depends on D325816

An upgrade on an HTTP/2 inner connection has to become an extended CONNECT
stream, and dispatching it as a plain stream handed the consumer a session it
cannot take a transport from. Leave such a transaction pending once the
connection is published, so the entry's own dispatch places it -- that already
handles the peer's SETTINGS not having arrived and the fallback when extended
CONNECT turns out unsupported.

Depends on D325817

RemoveStreamFromQueues took the stream out of mReadyForWrite and mQueuedStreams
but left mInTxQueue and mQueued set, so StreamReadyToWrite's early return
refused to schedule it ever again and QueueStream would assert. A CONNECT-UDP
tunnel stream hits this: FinishTunnelSetup removes it from the queues and keeps
it in mTunnelStreams, so the inner connection's queued datagrams were never
sent.

Attachment #9641884 - Attachment is obsolete: true
Whiteboard: [necko-triaged]

Closing an HTTP/3 tunnel stream or its UDP connection can re-enter and drop
the last reference to the object running the call. Hold the Http3Session in
HttpConnectionUDP::CloseTransaction and the transaction in
Http3TunnelStreamBase::WriteSegments, and make HandleTunnelResponse take an
nsAHttpTransaction, which is all it needs. No behavior change.

It parses the CONNECT response itself, because NullHttpTransaction never does
and HandleTunnelResponse is only reached through OnHeadersAvailable. Nothing
uses it yet.

Depends on D346169

Creates an inner connection tunnelled through an HTTP/2 or HTTP/3 outer
connection and driven by a TunnelSetupTransaction. For HTTP/3 it also lets the
caller learn when the inner QUIC handshake completes. Nothing calls it yet.

Depends on D346170

The analogue of ConnectionEstablisher for an inner connection: it opens the
tunnel with CreateInnerConnection, lets a TunnelSetupTransaction run the
CONNECT, and reports success only once the connection is usable (CONNECT 200
plus the inner TLS or QUIC handshake). Nothing uses it yet.

Depends on D346171

MakeAllDontReuseExcept closes every attempt of an entry to make room for a
connection that may itself still belong to one, and closing that attempt would
tear the connection down. ConnectionAttempt::OwnsConnection lets an attempt say
so; it defaults to false, so no existing attempt behaves differently.

Depends on D346172

InnerConnectionAttempt runs a Happy Eyeballs machine of its own over the
tunnel, giving each endpoint an InnerConnectionEstablisher and a
TunnelSetupTransaction to own the CONNECT, and publishes the first usable
connection while the real transaction waits in the pending queue. The
connection manager does not start one yet.

Depends on D346173

An origin reached through a CONNECT proxy now has its inner connection
established by an InnerConnectionAttempt instead of the real transaction driving
the CONNECT, with no racing and no fallback. Gated on
network.http.happy_eyeballs_tunnel_enabled, on by default in Nightly. Consumers
that take the tunnel themselves (connect-only, WebSocket, WebTransport) stay on
the old path.

Depends on D346174

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: