Skip to content

magicsock: don't report derp home to control until derp connected #212

Open

Description

@bradfitz

Currently magicsock measures its distance to the DERPs, makes a decision as its DERP home, and then reports it to the control plane concurrently with connecting to that DERP node.

That leaves a small window where control might think a node is on a certain DERP node (and tell peers) but it's not yet.

We should probably delay the netinfo update until after we're actually connected.

Alternatively, stop telling control about DERP homes entirely, and let control get that from the DERP nodes directly. If each DERP node had, say, 10,000 concurrent connections * 32 byte public keys, that's just 320 kB of network transfer from derp->control on control start-up, followed by a long-poll stream if changes. For auth, control can identify itself the same way nodes do: with the naclbox proof. To get control's public key, derp nodes could just ask for it from https://login.tailscale.com/your-pub-key.

/cc @crawshaw @danderson

Activity

  1. danderson commented on Mar 24, 2020

    @danderson
    Member

    I don't know that the race condition matters much. What's the adverse side-effect that's addressed by fixing it?

    delaying lgtm in principle, but it's going to be threading more synchronization into LocalBackend, which is already quite hairy and in need of less complex state management. That's why I'm asking about what we expect to benefit.

    Re: polling derp state from derp nodes: standard worry about coupling our servers to each other. No specific complaint, just that the second we have them talking to each other, we introduce the potential for coordinated or cascading failures. But we need derp to talk to control anyway, so we're just talking about degrees.

    Can we make control the upstream? derp dials into control and pushes updates, rather than control dialing out? Gets around the discovery problem (how many derps where - control is the well-known point of our universe)

    How do we support self-hosted derp for enterprise, or derp bundled into tailscaled? Have to be careful to not box ourselves out of that with the protocol to control. All the trickiness is going to be in the auth handshake, and knowing what keys derp is allowed to claim it's hosting (maybe end-host provides a proof using control's pubkey, which derper relays as evidence?).

  2. apenwarr commented on Apr 22, 2020

    @apenwarr
    Member

    This is not specific to DERP. We actually send an empty list of endpoints to the control server at startup, then immediately replace it. This is completely useless and actually causes a double-churn of the netmap every time a node starts, even if it would get exactly the same NAT mappings next time it starts.

  3. bradfitz commented on Nov 17, 2020

    @bradfitz
    MemberAuthor

    This is not specific to DERP. We actually send an empty list of endpoints to the control server at startup, then immediately replace it. This is completely useless and actually causes a double-churn of the netmap every time a node starts, even if it would get exactly the same NAT mappings next time it starts.

    FWIW, this is now fixed in 1.2.x.

  4. DentonGentry commented on Mar 11, 2022

    @DentonGentry
    Contributor

    I'm not sure this is something we need to do any more. #150 makes the system much less sensitive to whether the home DERP is connected or is in the process of connecting, other nodes will still be able to establish connections.

  5. DentonGentry commented on Aug 27, 2022

    @DentonGentry
    Contributor

    I'm not sure this is something we need to do any more. The work to fix #150 makes the system much less sensitive to whether the home DERP is connected or is in the process of connecting, other nodes will still be able to establish connections by using the return path through the same DERP.

    Barring further comment, we'll expect to close this during the next regular bug scrub.

  6. DentonGentry commented on Oct 30, 2022

    @DentonGentry
    Contributor

    Closing as sufficiently addressed.

  7. reopened this on Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    L5 All usersP1 NuisanceT3 Performance/Debugging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions