Skip to content

fix(snownet): don't allow duplicate server-reflexive candidates#7334

Merged
thomaseizinger merged 3 commits intomainfrom
fix/remove-invalidated-srflx-candidate
Nov 14, 2024
Merged

fix(snownet): don't allow duplicate server-reflexive candidates#7334
thomaseizinger merged 3 commits intomainfrom
fix/remove-invalidated-srflx-candidate

Conversation

@thomaseizinger
Copy link
Copy Markdown
Member

In #7163, we introduced a shared cache of server-reflexive candidates within a snownet::Node. What we unfortunately overlooked is that if a node (i.e. a client or a gateway) is behind symmetric NAT, then we will repeatedly create "new" server-reflexive candiates, thereby filling up this cache.

This cache is used to initialise the agents with local candidates, which manifests in us sending dozens if not hundreds of candidates to the other party. Whilst not harmful in itself, it does create quite a lot of spam. To fix this, we introduce a limit of only keeping around 1 server-reflexive candidate per IP version, i.e. only 1 IPv4 and IPv6 address.

At present, connlib only supports a single egress interface meaning for now, we are fine with making this assumption.

In case we encounter a new candidate of the same kind and same IP version, we evict the old one and replace it with the new one. Thus, for subsequent connections, only the new candidate is used.

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 10:00pm

@thomaseizinger
Copy link
Copy Markdown
Member Author

@jamilbk Let me know what you think about this approach. I am open to other ideas as well. Let me know if you need me to provide more details.

Copy link
Copy Markdown
Member

@jamilbk jamilbk left a comment

Choose a reason for hiding this comment

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

Makes sense

@thomaseizinger
Copy link
Copy Markdown
Member Author

Want to add a changelog entry here.

@thomaseizinger thomaseizinger added this pull request to the merge queue Nov 14, 2024
Merged via the queue into main with commit 00c7c42 Nov 14, 2024
@thomaseizinger thomaseizinger deleted the fix/remove-invalidated-srflx-candidate branch November 14, 2024 00:32
github-merge-queue Bot pushed a commit that referenced this pull request Nov 19, 2024
In the latest version, we added a warning log to str0m when the maximum
number of candidate pairs is exceeded:
algesten/str0m#587.

We only ever add the candidates of a single relay to an agent (2
candidates), plus at most 2 server-reflexive candidates and at most 2
host candidates. Unless there is a bug like what we fixed in #7334,
exceeding the default number of candidate _pairs_ (100) should never
happen.

In case it does, the newly added `warn` log in `str0m` will trigger a
Sentry alert.
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.

2 participants