Skip to content

Make ML_DERP_REGION a Kconfig option instead of a hardcoded #define - #29

Open
antonmeyer wants to merge 1 commit into
CamM2325:mainfrom
antonmeyer:derp-region-configurable
Open

Make ML_DERP_REGION a Kconfig option instead of a hardcoded #define#29
antonmeyer wants to merge 1 commit into
CamM2325:mainfrom
antonmeyer:derp-region-configurable

Conversation

@antonmeyer

Copy link
Copy Markdown

Fixes #19.

Every deployment outside North America that depends on relayed traffic (CGNAT peers, i.e. most cellular clients) currently pays intercontinental RTT on every relayed byte, since the preferred DERP region is hardcoded to 9 (Dallas) with no way to change it short of patching this header.

This is the interim fix suggested in #19: turn ML_DERP_REGION into a Kconfig int option (default unchanged at 9, so existing deployments are unaffected) instead of a #define, so users can set the closest region to their own deployment via idf.py menuconfig without patching library source. Region IDs are visible in a device's own boot log once the initial MapResponse is parsed (ml_coord: DERP region N (code): ...).

ML_DERP_HOST/_PORT are deliberately left hardcoded — they're only a bootstrap fallback used before the first DERPMap arrives; ml_derp_connect() already uses the real per-region host from the parsed DERPMap once available, so they don't need to track the preferred region.

Verified on real hardware (ESP32-S3, set to region 4/Frankfurt for a Germany-based deployment): clean boot shows "Home DERP region: 4 (default)" and "Connecting to DERP derp4j.tailscale.com:443 (region 4)" — the real DERPMap-resolved host for the configured region.

A full STUN-probe-and-pick-lowest-latency implementation (what real Tailscale clients do) is a bigger change than this — deliberately scoped to just the interim fix #19 itself suggested.

Fixes CamM2325#19.

Every deployment outside North America that depends on relayed traffic
(CGNAT peers, i.e. most cellular clients) currently pays intercontinental
RTT on every relayed byte, since the preferred DERP region is hardcoded to
9 (Dallas) with no way to change it short of patching this header.

This is the interim fix suggested in CamM2325#19: turn ML_DERP_REGION into a
Kconfig int option (default unchanged at 9, so existing deployments are
unaffected) instead of a #define, so users can set the closest region to
their own deployment via `idf.py menuconfig` without patching library
source. Region IDs are visible in a device's own boot log once the initial
MapResponse is parsed (`ml_coord: DERP region N (code): ...`).

ML_DERP_HOST/_PORT are deliberately left hardcoded - they're only a
bootstrap fallback used before the first DERPMap arrives; ml_derp_connect()
already uses the real per-region host from the parsed DERPMap once
available, so they don't need to track the preferred region.

Verified on real hardware (ESP32-S3, set to region 4/Frankfurt for a
Germany-based deployment): clean boot shows "Home DERP region: 4 (default)"
and "Connecting to DERP derp4j.tailscale.com:443 (region 4)" - the real
DERPMap-resolved host for the configured region.

A full STUN-probe-and-pick-lowest-latency implementation (what real
Tailscale clients do) is a bigger change than this - deliberately scoped to
just the interim fix CamM2325#19 itself suggested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ML_DERP_REGION hardcoded to 9 (Dallas) — high relay latency for deployments outside North America

1 participant