Make ML_DERP_REGION a Kconfig option instead of a hardcoded #define - #29
Open
antonmeyer wants to merge 1 commit into
Open
Make ML_DERP_REGION a Kconfig option instead of a hardcoded #define#29antonmeyer wants to merge 1 commit into
antonmeyer wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_REGIONinto a Kconfigintoption (default unchanged at 9, so existing deployments are unaffected) instead of a#define, so users can set the closest region to their own deployment viaidf.py menuconfigwithout 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/_PORTare 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.