Skip to content

fix(windows,linux): ensure set_routes is idempotent#6051

Merged
conectado merged 9 commits intomainfrom
chore/windows/keep-all-routes-updated
Jul 26, 2024
Merged

fix(windows,linux): ensure set_routes is idempotent#6051
conectado merged 9 commits intomainfrom
chore/windows/keep-all-routes-updated

Conversation

@conectado
Copy link
Contributor

@conectado conectado commented Jul 25, 2024

Windows may delete the default route during roaming. To prevent this from causing problems, we make set_routes add all routes regardless of the previously stored ones. The known routes are only used to compute, what routes are to be removed.

For Linux we do the same to make it consistent across platforms.

This also give us the chance to not clear the cache when ips are set, since now all routes are always added, meaning they will be always re-added when roaming.

Overall, this more closely aligns Linux and Windows with how Firezone works on Apple and Android. There, we always remove all routes and set new ones. Removing routes happens very rarely (only when CIDR resources are deactivated), thus, not removing all and re-adding the routes is still deemed to be worth it.

With the new implementation, this is guaranteed to always make the new routes take effect and at the same time be idempotent.

@vercel
Copy link

vercel bot commented Jul 25, 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 Jul 26, 2024 5:03am

@github-actions
Copy link

github-actions bot commented Jul 25, 2024

🐰Bencher

ReportFri, July 26, 2024 at 05:16:37 UTC
ProjectFirezone
Branchchore/windows/keep-all-routes-updated
Testbedgithub-actions
Click to view all benchmark results
BenchmarkThroughputThroughput Results
bits/s | (Δ%)
Throughput Lower Boundary
bits/s | (%)
direct-tcp-client2server✅ (view plot)235,883,956.45 (-1.89%)235,803,869.26 (99.97%)
direct-tcp-server2client✅ (view plot)251,320,646.23 (+2.04%)240,276,504.72 (95.61%)
direct-udp-client2server✅ (view plot)283,181,083.38 (-1.72%)271,471,083.14 (95.86%)
direct-udp-server2client✅ (view plot)392,148,501.11 (-0.35%)382,020,759.39 (97.42%)
relayed-tcp-client2server✅ (view plot)239,786,479.55 (-2.45%)239,689,551.24 (99.96%)
relayed-tcp-server2client✅ (view plot)253,204,720.07 (-1.41%)245,107,228.46 (96.80%)
relayed-udp-client2server✅ (view plot)234,317,477.87 (+2.42%)218,145,271.48 (93.10%)
relayed-udp-server2client✅ (view plot)338,186,212.48 (-0.57%)319,854,147.78 (94.58%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

@thomaseizinger
Copy link
Member

I am surprised this makes a difference? If you use the caches routes at all, shouldn't the two calls to .difference effectively be a no-op if the two sets are equal? Asked differently, if our "cache" of routes is stale, we do the .difference calls yield additions / removals?

@conectado
Copy link
Contributor Author

I am surprised this makes a difference? If you use the caches routes at all, shouldn't the two calls to .difference effectively be a no-op if the two sets are equal? Asked differently, if our "cache" of routes is stale, we do the .difference calls yield additions / removals?

The important difference here is that we call add_route even if the route is in our cache because I removed the .difference from the add_route loop

@conectado conectado requested a review from thomaseizinger July 26, 2024 03:42
@conectado conectado marked this pull request as ready for review July 26, 2024 03:47
@conectado
Copy link
Contributor Author

Manually tested on Windows, seems to work alright!

Copy link
Member

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Concept ACK

@thomaseizinger thomaseizinger changed the title chore(windows): always keep all routes updated with set_routes fix(windows,linux): ensure set_routes is idempotent Jul 26, 2024
Copy link
Member

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Nice work!

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
@conectado conectado added this pull request to the merge queue Jul 26, 2024
Merged via the queue into main with commit a39b853 Jul 26, 2024
@conectado conectado deleted the chore/windows/keep-all-routes-updated branch July 26, 2024 05:27
return;
}

tracing::warn!(%route, "Failed to remove route: {e}")
Copy link
Contributor

Choose a reason for hiding this comment

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

The caller doesn't decide how to handle the error?

Copy link
Member

Choose a reason for hiding this comment

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

What are we meant to do? This is something we should report via Sentry to know about it before users report bugs and we request logs TBH.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking if a route fails to add or remove, it will hard to debug where the symptoms appear, if we ignore the error here. But yeah I guess either way we have to use Sentry.

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.

3 participants