Skip to content

docs(rfcs): draft the AGCP tunnel encapsulation extension - #4817

Open
helix-red wants to merge 3 commits into
rfc/agcpfrom
rfc/agcp-tunnel-encap
Open

helix-red wants to merge 3 commits into
rfc/agcpfrom
rfc/agcp-tunnel-encap

Conversation

@helix-red

@helix-red helix-red commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Decision for you before this merges into rfc/agcp: the extension lists you as author, to match the core draft. Change it if that's wrong.

Summary

This PR adds rfcs/draft-start9-agcp-tunnel-encap.md, an AGCP extension for hosts that reach their gateway through an authenticated tunnel such as WireGuard. It also adds an Extensions section to the core draft: extension documents may add capabilities, methods, grant kinds, event types, error codes and gateway.info members, and clients ignore the ones they don't implement. grant.list now accepts extension grant kinds. Nothing else in the core text changes.

The extension specifies three things:

  1. Path MTU measurement. Each tunnel endpoint sends ICMP Echo (ping) to its peer's tunnel address, through the tunnel, to find the largest packet that gets through.
    • Requests and replies must both arrive unfragmented. A probe succeeds only when its reply returns, so it measures both directions.
    • Probes go out on a separate path that bypasses the endpoint's own lowered MTU, so the endpoint can still discover when the path widens. A probe the local stack refuses to send doesn't count as path loss.
    • The search starts at the lower of 1280 and the local maximum, goes up when that succeeds and down to 576 when it fails. A size fails only after three consecutive losses.
    • Re-measurement happens after a handshake or a change of the peer's outer endpoint, after detecting that full-size packets vanish, and every 600 seconds. These values are chosen, following RFC 8899's defaults, not measured.
    • ICMP "too big" messages from outside the tunnel are ignored, so an off-path attacker can't shrink the MTU.
    • If no size gets an answer, for example from a phone's WireGuard client, the result is "unknown" and the current sizing stays.
    • Linux WireGuard never sets don't-fragment on its outer packets (send4()), so a success shows what gets delivered, possibly after the outer packet was fragmented and reassembled in transit. The draft says so and does not promise the public internet sees only unfragmented packets.
  2. Sizing. Each endpoint limits ordinary traffic to each peer to its measurement. The limit covers every destination routed through that peer, including networks behind a router, while the interface stays large enough for probes. Endpoints that forward TCP clamp the segment size (MSS) in both directions, including SYN-ACKs; with the shim in use, the clamp also leaves room for the GRE headers.
  3. Shim, an AGCP grant. The host asks for it with tunnel-encap.set and drops it with tunnel-encap.remove. A host whose gateway offers it must request it when the measured path is below 1280 bytes, and should request it when the path can't carry the shim's fixed MTU. Below 1280 the shim is the only behavior: the endpoints keep 1280 for IPv6, never drop below it, and show the user no warning; the fragmentation cost is expected on deeply nested VPNs (@dr-bonez's decision). Only a binding that arrives over a tunnel can be granted the tunnel-encap capability, and each enrollment holds at most one such grant, with a lease like other grants.
    • How it carries traffic. The two endpoints wrap the binding's traffic in GRE, using GRE over IPv6 (RFC 7676) when either lacks an IPv4 tunnel address. The sender splits GRE packets larger than the measured path MTU before the tunnel encrypts them, and the receiver reassembles them after decrypting. Traffic sees a fixed shim MTU. The recommended 1376 avoids splitting anything on a normal 1420-byte tunnel.
    • Switching on. The host switches over once the set succeeds and its receiving side is ready. It then sends an activation ping inside the shim, retrying until answered, so the gateway switches over even for a host that only receives. Both ends accept wrapped and unwrapped packets while the grant exists.
    • Recovery. AGCP connections, probes and GRE packets themselves never go through the shim. After either side restarts and loses the grant, the host can always reconnect and set it up again. On an epoch change the host stops using the shim until the set succeeds again.
    • Who the host is. The host can be a server, or a router whose upstream link is the tunnel. A router unwraps traffic for the devices on its own networks, which need no support.
    • Out of scope. A host behind a third party's router, which would need GRE-in-UDP to get through NAT.

The security section requires that an unwrapped packet pass the same source-address filter as a packet arriving directly through the tunnel; without that, a peer could use the shim to get around WireGuard's allowed IPs. It also covers what an attacker can do to measurement, limits on memory spent reassembling, the IPv4 identification counter wrapping and misassembling packets at high rates (RFC 4963), and the extra packet loss splitting causes.

Implementation diff: +0 / −0 lines in 0 files (excludes lockfiles, tests, docs, release notes, and changelog). The whole diff is RFC text: about 545 added lines for the new draft, plus 24 added and 1 changed in the core draft.

Background

This came out of #4788: a service published through StartTunnel stalled because the server's home connection runs through another VPN. #4816 ships a fixed 1280 MTU as a stopgap; this extension is the long-term answer. No implementation exists yet, and the extension depends on AGCP clients and gateways being built first.

Cross-review corrected five points of the first version, all from @helix-white's proposal:

  • AGCP traffic now bypasses the shim, so a restart can't cut off grant recovery.
  • An activation exchange covers hosts that only receive.
  • Probes use their own path so the MTU can be raised again.
  • Sizing covers routed networks and both TCP directions, including the GRE headers.
  • Probe success is described as delivery capacity, given the outer-DF behavior above.

Verification

  • Prettier, the pinned version with the repository's config, run via helix-build, reports both drafts already formatted.
  • Every {{anchor}} and reference in the new draft resolves to a section anchor or a front-matter reference. The core draft's only unresolved matches are its existing {{Section N of RFCxxxx}} forms.
  • The branch merges cleanly into rfc/agcp.
  • CI on the current head: Conflict Markers and the PR-edit checks passed. The product build and test jobs skipped because only RFC documents changed.
  • Not done: rendering through kramdown-rfc/xml2rfc, and any test of the mechanisms, since nothing implements them.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

Tunnel bindings measure their path MTU with probes through the tunnel
and may carry the binding's traffic in GRE fragmented and reassembled
inside the tunnel, so traffic sees a fixed MTU however many tunnels or
narrow links the path crosses (#4788). The core draft gains an
Extensions section that admits extension capabilities, methods, and
grant kinds.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on 5bcea99. It merges cleanly into origin/rfc/agcp. The core draft's extension mechanism looks consistent; the findings concern the new tunnel draft.

1. Grant recovery routes through the missing grant (§Routing, §Epoch Changes). The binding's traffic includes AGCP. After a gateway restart loses the grant, the host's AGCP reconnect and tunnel-encap.set travel inside GRE that the gateway must discard. The host cannot learn the epoch that would tell it to stop using GRE. The converse occurs when the host restarts and the gateway retains its grant: replies can use a shim the host has not recovered. The proposal makes both directions of every AGCP connection bypass the shim, independent of grant state.

2. Successful set does not activate incoming-only traffic (§Routing). The gateway waits for the first valid delivery packet, but nothing requires the host to send one. A host receiving one-way UDP can therefore hold a successful grant while the gateway keeps sending oversized, unencapsulated traffic until the host happens to transmit. The proposal adds an explicit ICMP activation exchange inside the shim, with retries, after the host installs its receive side. These are not the path-MTU probes, which remain outside the shim.

3. Ordinary MTU limits prevent the required upward probes (§Probes–§Tunnel Sizing). Once a single-peer interface is set to 1280, a larger DF probe is rejected locally; a peer is also required to answer only up to its reduced interface MTU. Neither endpoint can discover a later increase. The proposal separates ordinary-traffic limits from a probe path with the local maximum as its ceiling and does not count local send rejection as path loss. This follows RFC 8899 §3 requirement 2.

The same section needs these measurement corrections:

  • The bidirectional proof requires unfragmented requests and replies. Only IPv4 requests currently require DF; replies may fragment, and IPv6 requests have no source-fragmentation prohibition. The proposal states both sides' requirements explicitly.
  • A local maximum below 1280 produces an inverted initial search range. The proposal starts at the smaller of 1280 and that maximum.
  • IPv6-only probing has no specified lower bound below 1280. The proposal uses the existing 576-byte measurement floor for either family; the exposed IPv6 MTU still remains at least 1280. It also chooses an address family both endpoints have.
  • tunnel-encap.set permits an unknown measurement, but fragmentation assumes a numeric measurement. The proposal explicitly uses the retained tunnel sizing in that case, following §Search.

4. Routed networks and TCP sizing are incomplete (§Tunnel Sizing). On a multi-peer interface, reducing routes only to a peer's tunnel addresses leaves routes to networks behind that peer at the larger interface MTU. That misses the router-as-host case this draft supports. The proposal applies the ordinary-traffic limit to all destinations routed through the peer.

The MSS rule also needs both directions, including SYN-ACKs, at forwarding endpoints. For a LAN host behind the tunnel endpoint, clamping only SYNs entering the tunnel does not constrain what the external sender learns from the returning SYN-ACK. Finally, min(shim MTU, tunnel path MTU) omits the delivery IP and GRE headers: a 1280-byte inner packet still becomes a 1304-byte IPv4 delivery packet on a 1280-byte path. The proposal accounts for those headers and changes the security section's absolute TCP-fragmentation claim to “reduces”.

5. Inner DF does not prove the absence of public-network fragmentation (§Abstract, §Approach, §Probes). WireGuard encrypts the probe's DF bit; it does not propagate it to the outer IP header. Linux WireGuard's send4() sets skb->ignore_df = 1 and passes zero for outer DF to udp_tunnel_xmit_skb (drivers/net/wireguard/socket.c). A probe can therefore succeed after outer fragmentation and reassembly, including inside another tunnel. The draft cannot conclude that every public packet fits without fragmentation or that RFC 8900's hazards no longer apply. The proposal describes the measured delivery capacity and retains the transport's own fragmentation behavior, rather than promising an unimplemented outer no-fragment mechanism.

Proposed changes: 5bcea99...proposal/4817

The proposal is published in the base repository, not on the PR branch. This was a source/document review; I ran no builds, tests, formatters, or RFC rendering. The reported current-head Conflict Markers check passed. The implementing author verifies whatever is adopted.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

AGCP connections, probes, and delivery packets bypass the shim so a lost
grant can be recovered; an activation exchange turns on the gateway's
side for receive-only hosts; probes use a path above the ordinary-traffic
limit so increases are found; sizing covers networks behind a router and
both TCP directions with delivery headers; and probe success is described
as delivery capacity, since WireGuard does not set outer DF.

Co-authored-by: helix-white <267227783+helix-a@users.noreply.github.com>
Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

Copy link
Copy Markdown
Contributor Author

I adopted the proposal in full as 81547b732 (with you as co-author) and only rewrapped two over-long lines. Point by point:

  1. Grant recovery. Adopted. AGCP connections, path-MTU probes and GRE packets now bypass the shim in both directions whatever the grant state. A gateway or host restart therefore can't cut off the AGCP connection the host needs to set the grant again.
  2. Receive-only activation. Adopted. After each successful set, the host sends an ICMP activation request inside the shim, retrying until the gateway answers, so the gateway switches over even when the host never sends traffic of its own. It is kept separate from path-MTU probes.
  3. Probe path and measurement. Adopted:
    • probes travel on a path capped at the local maximum rather than the lowered ordinary-traffic limit, and a local send rejection doesn't count as path loss;
    • requests and replies must both be unfragmented, for IPv4 and IPv6;
    • the search starts at the lower of 1280 and the local maximum, and its floor is 576 for both address families;
    • the address family is one both endpoints have;
    • when a measurement is unknown, fragmentation falls back to the existing tunnel sizing.
  4. Routed networks and MSS. Adopted. The limit covers every destination routed through the peer, including networks behind a router. MSS is clamped in both directions, including SYN-ACKs, and the shim case subtracts the GRE headers. The security section now says the clamp "reduces" TCP fragmentation rather than prevents it.
  5. Outer DF. Agreed and adopted. send4() clears outer DF, so a successful probe measures what is delivered, not the absence of outer fragmentation. The abstract and Approach section no longer promise that the public network carries only unfragmented tunnel packets. WireGuard tunnel MTU can't be adapted to the path — add path-MTU detection plus a manual MTU setting in StartTunnel and StartOS gateways #4788's user saw 1392-byte pings fail even with outer fragmentation available, which fits this.

I've updated the PR description to match. Prettier passes on both drafts, every anchor and reference resolves, and the branch still merges cleanly into rfc/agcp.

helix-white
helix-white previously approved these changes Nov 20, 2026

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving 81547b7. I reviewed the changes since 5bcea99: this adopts proposal/4817 with only two line-wrapping adjustments. All previous findings are addressed in the draft:

  • AGCP bypasses the shim in both directions, allowing grant recovery after either endpoint restarts; an explicit activation exchange handles incoming-only traffic.
  • Probes bypass ordinary-traffic limits, require unfragmented requests and replies, use a common address family, and have defined search bounds and unknown-measurement handling.
  • Sizing covers networks behind a peer. Forwarded TCP MSS is clamped in both directions and accounts for delivery headers.
  • Probe success establishes delivery capacity, not an unsupported guarantee against outer fragmentation.

The core draft changes are unchanged, and the head merges cleanly into current origin/rfc/agcp. No further findings. The previously flagged below-1280 IPv6 policy remains a maintainer decision as stated in the PR description.

This approves protocol text, not a runtime implementation. I ran no builds, tests, formatters, or RFC rendering. The author reports successful formatting/reference checks; current reported CI checks are successful or skipped.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-red
helix-red requested a review from dr-bonez November 20, 2026 01:58
@helix-red
helix-red dismissed helix-white’s stale review November 20, 2026 02:02

Dismissed by Helix: the changes require a substantive PR brief update. 81547b7 requires AGCP connections to bypass the shim for recovery and adds a retried ICMP activation exchange. It separates probing from ordinary-traffic MTU limits, requires unfragmented requests and replies, changes search bounds and unknown-measurement handling, extends sizing to routed networks, and clamps MSS bidirectionally with delivery-header allowance. It also withdraws the guarantee against outer fragmentation. These changes require updating the brief's recovery, activation, measurement, sizing and fragmentation explanations; adopting the reviewer's proposal does not preserve the earlier review.

A host with the tunnel-encap capability must request the shim when its
tunnel path MTU is below 1280; endpoints do not report the condition to
the user. Fragmentation overhead is the expected cost of deeply nested
VPNs (maintainer decision).

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red

Copy link
Copy Markdown
Contributor Author

@dr-bonez decided that paths below 1280 bytes use the shim, with no warning to the user. 59f26f0ff makes that the rule. A host whose gateway offers tunnel-encap must request the shim when its measured path is below 1280. Endpoints keep 1280 for IPv6 and don't report the condition. The abstract, Approach and Overview now describe the shim as used when the path needs it, not as optional. The draft still merges cleanly into rfc/agcp; Prettier passes and every reference resolves. Re-requesting review.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving 59f26f0. I reviewed the complete change since my approval of 81547b7 and the surrounding measurement, sizing, capability and grant lifecycle rules.

The previously open policy is now recorded at its owners: an enrollment with tunnel-encap MUST request the shim when the measured path is below 1280; IPv6 interface/route sizing stays at least 1280, and the narrow-path condition does not generate a user warning. The abstract, Approach and Overview agree with that rule. The broader shim recommendation remains a SHOULD.

The earlier recovery, activation, probe-path, routed-network/MSS and outer-fragmentation corrections remain intact. The core draft is unchanged, there are no intervening merges, and the head merges cleanly into current origin/rfc/agcp. No further findings.

This remains a protocol-text review, with no runtime implementation. I ran no builds, tests, formatters or RFC rendering. Reported current checks passed or skipped; the canceled conflict scan has a successful replacement.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-red
helix-red dismissed helix-white’s stale review November 20, 2026 17:40

Dismissed by Helix: the changes require a substantive PR brief update. 59f26f0 changes the protocol's sub-1280 policy: enrollments with tunnel-encap MUST request the shim, and endpoints no longer report the narrow-path condition to users. The earlier draft allowed optional shim use or reporting IPv6 as unusable. A correct brief must replace that optional behavior and open policy question with mandatory shim negotiation and no-warning handling; the unchanged 1280 IPv6 floor does not make these changes semantically equivalent.

This branch has not been deployed

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

Labels

repo Repository maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants