Skip to content

derp, derphttp, magicsock: send new unknown peer frame when destination is unknown - #7552

Merged
valscale merged 3 commits into
mainfrom
valscale/derpPeerGone
Mar 25, 2023
Merged

valscale merged 3 commits into
mainfrom
valscale/derpPeerGone

Conversation

@valscale

@valscale valscale commented Mar 13, 2023 •

Copy link
Copy Markdown
Contributor

If node A sends a CallMeMaybe packet to DERP for node B, and DERP has no record of node B, send an "unknown peer" frame back to node A.

Uses the existing framePeerGone and adds a reason byte at the end in what is intended to be a backwards-compatible manner.

Fixes #4326

Comment thread derp/derp_server.go Resolved
Comment thread derp/derp_client.go Resolved
Comment thread derp/derp_client.go Resolved
Comment thread derp/derp.go Resolved
@jwhited

jwhited commented Mar 14, 2023

Copy link
Copy Markdown
Member

I haven't gotten very deeply into DERP yet, so my comments come with a grain of salt.

@valscale

Copy link
Copy Markdown
Contributor Author

Upon reflection, I'm rewriting this to push the reason back up the call chain instead of creating a new chan for each different peerGone reason.

Comment thread derp/derp_server.go Resolved
Comment thread derp/derp_server.go Resolved

@danderson danderson 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.

Looks right to me. Some nitpicky comments since you asked for Go style feedback, but aside from the missing rate limiter I'd say this is good to go.

Comment thread derp/derp.go Resolved
Comment thread derp/derp.go Resolved
Comment thread derp/derp_client.go Resolved
Comment thread derp/derp_server.go Resolved
Comment thread derp/derp_server.go Resolved
Comment thread derp/derp_server.go Resolved
Comment thread derp/derp_server.go Resolved
Comment thread wgengine/magicsock/magicsock.go Resolved
@valscale
valscale force-pushed the valscale/derpPeerGone branch 2 times, most recently from c96c770 to 1082f4f Compare March 18, 2023 01:49
@valscale valscale changed the title derp, magicsock: send new unknown peer frame when destination is unknown derp, derphttp, magicsock: send new unknown peer frame when destination is unknown Mar 18, 2023
@valscale
valscale force-pushed the valscale/derpPeerGone branch from 1082f4f to 7021a77 Compare March 24, 2023 03:31
For testing older client version responses to the PeerGone packet format change.

Updates #4326

Signed-off-by: Val <[email protected]>
Comment thread wgengine/magicsock/magicsock.go Resolved
@bradfitz

Copy link
Copy Markdown
Member

Nit: lowercase verb after colon in derp: Remove dead sclient struct member replaceLimiter

@valscale
valscale force-pushed the valscale/derpPeerGone branch from 7021a77 to ab6b99a Compare March 24, 2023 04:01
Leftover from an previous solution to the duplicate client problem.

Updates #2751

Signed-off-by: Val <[email protected]>
@valscale
valscale force-pushed the valscale/derpPeerGone branch 3 times, most recently from 1443559 to 9102aae Compare March 24, 2023 04:52
@valscale

Copy link
Copy Markdown
Contributor Author

Differences from first version:

  • Tested end-to-end with all combos of new/old DERP and clients
  • Only sent on bad disco messages
  • Debug knob added to force bad CallMeMaybe for testing
  • Rate limited to 3 per second per client
  • Actually uses PeerGoneReasonType
  • Unused ratelimiter removal separated into its own commit

I'd be happy to merge this one but still appreciate nitpicky feedback.

@valscale
valscale requested a review from danderson March 24, 2023 05:04
@valscale
valscale requested review from andrew-d and mihaip March 24, 2023 19:58
case derp.PeerGoneReasonDisconnected:
// Do nothing.
case derp.PeerGoneReasonNotHere:
c.logf("[unexpected] magicsock: derp-%d does not know about peer %s, removing route",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May want to increment a client metric if this is an unexpected/interesting thing to happen (there's already a few DERP-related metrics in this file).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I added two new metrics, noticed two arguments were swapped for the log message for the unknown reason case and fixed that, and tested the not here path. If you can double check the logf() after metricRecvDiscoDERPPeerGoneUnknown.Add(1), I would appreciate it.

@valscale
valscale force-pushed the valscale/derpPeerGone branch from 9102aae to 46922c6 Compare March 24, 2023 21:48
…e Not Here

Extend the PeerGone message type by adding a reason byte. Send a
PeerGone "Not Here" message when an endpoint sends a disco message to
a peer that this server has no record of.

Fixes #4326

Signed-off-by: Val <[email protected]>
@valscale
valscale force-pushed the valscale/derpPeerGone branch from 46922c6 to 8da10be Compare March 24, 2023 22:09

@mihaip mihaip left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Metrics and logf LGTM

@valscale
valscale merged commit 74eb99a into main Mar 25, 2023
@valscale
valscale deleted the valscale/derpPeerGone branch March 25, 2023 02:11
darksip pushed a commit to darksip/tailscale that referenced this pull request Apr 3, 2023
…on is unknown (tailscale#7552)

* wgengine/magicsock: add envknob to send CallMeMaybe to non-existent peer

For testing older client version responses to the PeerGone packet format change.

Updates tailscale#4326

Signed-off-by: Val <[email protected]>

* derp: remove dead sclient struct member replaceLimiter

Leftover from an previous solution to the duplicate client problem.

Updates tailscale#2751

Signed-off-by: Val <[email protected]>

* derp, derp/derphttp, wgengine/magicsock: add new PeerGone message type Not Here

Extend the PeerGone message type by adding a reason byte. Send a
PeerGone "Not Here" message when an endpoint sends a disco message to
a peer that this server has no record of.

Fixes tailscale#4326

Signed-off-by: Val <[email protected]>

---------

Signed-off-by: Val <[email protected]>
spikecurtis added a commit to coder/tailscale that referenced this pull request May 31, 2024
bradfitz pushed a commit that referenced this pull request May 31, 2024
Updates #2745
Updates #7552

Signed-off-by: Spike Curtis <[email protected]>
chen8945 pushed a commit to Ckid-Home/tailscale that referenced this pull request Jul 31, 2024
Asutorufa pushed a commit to Asutorufa/tailscale that referenced this pull request Aug 23, 2024
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.

debug: make DERP send frame (framePeerGone) as limited reply as "nobody's here"

6 participants