Skip to content

Public link router: reuse connections to the service, without passing a closed link #559

Closed

Description

@7schmiede

Problem

The public link router (crates/devstack-node/src/linkrouter.rs, forward) opens a new connection to the service for every request that comes through a named tunnel and closes it after the answer. Each closed connection stays in TIME_WAIT on the router's side for two minutes. It is the same class as #556 (connection-per-request), which 0.49.2 fixed for a static service's forward and for the hub's way to its daemons (devstack_node::connpool).

The load is lower there (a public link is opened by hand, ADR-0090), but a page with many assets or an app that polls through a shared link adds up the same way, on the hub (a member's machine) and on a node.

Why it was left out of #557

Dial (linkrouter.rs) is two things at once: the way to the service and the check that the host is still open (the hub's publiclinks.rs, a node's node/links.rs). A pool keyed by host that skips dial for a kept connection would keep passing a link its owner closed, until the kept connection ends. That is a change at a trust boundary, so it needs its own decision.

Proposal

Split the check from the connection, then pool:

  1. Dial (or a second function beside it) answers "is this host open, and where does it go" without connecting: an Option<Target> with port, TLS and, for a node, the lane.
  2. Every request asks it first; only a host that is open now gets a connection, kept or new, from connpool::Pool, keyed by the target (not by the host name), so a link closed and opened again for another service never gets the old connection.
  3. Closing a link drops its target's idle connections (a Pool::forget(key)), so nothing kept outlives the link.
  4. Upgrades (WebSocket) and endless streams keep their own connection, as in fix(static): a forward keeps its connections to the target (#556) #557.

A review card first: points 1 and 3 touch who may reach a service through a tunnel.

A check that would catch it

As in #557: a target that counts accepted connections, N requests through the router (≤ 2 connections), and a request after the link is closed that is refused although an idle connection to the target exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions