Skip to content

net/netmon: Allow excluding custom interfaces - #14575

Open
craciunoiuc wants to merge 2 commits into
tailscale:mainfrom
craciunoiuc:craciunoiuc/no-query-ifs-regex
Open

craciunoiuc wants to merge 2 commits into
tailscale:mainfrom
craciunoiuc:craciunoiuc/no-query-ifs-regex

Conversation

@craciunoiuc

Copy link
Copy Markdown

Problem

In order to be able to exclude interfaces currently you need to hardcode the name of the interface like in https://github.com/tailscale/tailscale/blob/main/net/netmon/state.go#L37 or do tricks denying IP addresses through systemd

Reasoning

As the code that does this runs on init and does not have access directly to the config, the only way to provide input there is through an environmental variable. This variable should be a regex such that people can catch complex interface patterns.

Personal Use Case

We are running Tailscale on a server which has several tens of thousands of active interfaces. These are correctly filtered out by tailscale, but in order for Tailscale to build state when first started, it requires 10+ minutes and multiple GBs of RAM.

A quick experiment with 2000 created interfaces gave the following results:

Memory

2.2GB in use memory. Out of which:
1GB - message buffers from interfaces
0.3GB - interfaces list

48.6GB allocated memory. Out of which:
2.6GB - List of interfaces
8GB - Interfaces state
7.7GB - Interface ip/gateways

CPU Time

1 minute CPU time (10 minutes total since start):
19% time - Getting interface state
18% time - Getting interface ip/gateway mappings
46% time - Getting endpoints of interfaces

Flamegraph of Tailscale before applying the patch:
image

Flamegraph of Tailscale after applying the patch:
image

CPU Time reduced on boot from 66 seconds to 0.5 seconds.

Related Work

There were several other attempts at excluding interfaces [1], which can all be seen in the issue tracking everything #1552

Let me know what you think, thanks 🙏

[1] #8682

craciunoiuc and others added 2 commits January 8, 2025 17:36
Iterating interfaces happens unrelated to the previous problematic
interface check. Check here also to save time on initialization.

Updates tailscale#1552

Signed-off-by: Cezar Craciunoiu <[email protected]>
Providing a regex env variable ensures that any other specific
interface that interferes with tailscale can be disabled on startup.

Updates: tailscale#1552

Signed-off-by: Cezar Craciunoiu <[email protected]>
@NickMuellner

Copy link
Copy Markdown

Any updates on this?

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