fix(derp): DERP TLS session resumption, longer connect timeout, upgrade backoff - #52
Merged
Merged
Conversation
…de backoff Adapted from cplewes/microlink@b9636816 (not a literal cherry-pick: git apply conflicted only on microlink_internal.h's ml_derp_conn_t, which lacks the entropy/ctr_drbg fields the source commit anchors near since this fork uses PSA crypto post-mbedTLS-4.x migration -- same divergence already handled for issue #14/PR #44. ml_derp.c and ml_wg_mgr.c applied cleanly; hand-ported with identical logic/comments throughout). - DERP TLS session resumption: save the negotiated mbedTLS session after each successful handshake and resume it on the next reconnect, skipping the full ECDHE handshake (~7.5s -> sub-second). Best-effort: falls back to a full handshake transparently if the ticket expired. - DERP_CONNECT_TIMEOUT_MS 10s -> 25s: the TLS handshake was observed taking ~7.5s+ and occasionally exceeding 10s on a lossy/high-latency captive network, tripping spurious "TLS handshake failed: timed out" -> full-retry thrash. - Per-peer exponential backoff on direct-path upgrade probes: on a P2P-hostile network (blocks peer-to-peer UDP) direct-path upgrades never succeed, so re-probing every 15s forever wastes CPU + DERP TX. Doubles the interval on each unanswered probe up to a 300s cap, resets to the base interval once a direct path is established. Closes #25 Co-authored-by: Adrian.Nguyen-Qualgo <nguyen.ndt@qualgo.net> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
Adapted from
cplewes/microlink@b9636816(issue #25). Not a literal cherry-pick:git apply --check --3wayconflicted only onmicrolink_internal.h'sml_derp_conn_t, which doesn't have theentropy/ctr_drbgfields the source commit anchors near — this fork uses PSA crypto post-mbedTLS-4.x migration (same divergence already handled for issue #14 / PR #44).ml_derp.candml_wg_mgr.capplied cleanly against this fork's current tree; hand-ported all three files with the source commit's logic/comments unchanged.DERP_CONNECT_TIMEOUT_MS10s → 25s: the TLS handshake was observed taking ~7.5s+ and occasionally exceeding 10s on a lossy/high-latency captive network, tripping spurious"TLS handshake failed: timed out"→ full-retry thrash.FORK_PRS.mdrow 6 (issue #25) marked done.Closes #25
Test plan
idf.py buildnot runnable in this sandbox — needs a real ESP-IDF 6.x build to confirm.grepconfirms all expected symbols (ML_DISCO_UPGRADE_BACKOFF_MAX_MS,upgrade_interval_ms,saved_session,have_saved_session,DERP_CONNECT_TIMEOUT_MS) present in the three touched files.derp_free_tls_state()(the teardown/reconnect path) only freesssl/ssl_conf, leavingsaved_sessionintact across reconnects — matches intended lifetime.FORK_PRS.mddiff touches only row 6; rows 7 (Fix wg_udp_output_cb thread-safety bug + RX queue starvation + disco_pong handshake gating (mined from antmanler/microlink) #26) and 9 (Investigate WG netif MTU 1420 vs 1280 (mined from antmanler/microlink) #28) remain open, deferred to a future session (bundled in a large, genuinely-divergedantmanler/microlink@2a7ba328commit that needs surgical extraction).🤖 Generated with Claude Code