From 7345cc20a2f217df08e3c74b6d2c3ef2e6dbc315 Mon Sep 17 00:00:00 2001 From: Gabi Date: Fri, 23 Aug 2024 01:01:18 -0300 Subject: [PATCH] fix(connlib): only emit route changes from disabled_resource if routes actually changed (#6424) Right now, whenever a connection is established we update the site status. In order to do that, we call `on_update_resources`, when `on_update_resources` is called this in turn calls `set_disabled_resources`, since we apply from the application side the "disabled" given the current resources. `set_disabled_resources` currently, always call `on_update_routes`, which causes connectivity issues on Android and MacOS, since the packets aren't correctly routed when the routes are changed. To fix this we make `set_disabled_resources` only emit the routes when they have actually changed. Fixes: #6387. --------- Signed-off-by: Gabi Co-authored-by: Thomas Eizinger --- rust/connlib/tunnel/src/client.rs | 5 +++++ website/src/components/Changelog/Android.tsx | 11 +++++++++++ website/src/components/Changelog/Apple.tsx | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/rust/connlib/tunnel/src/client.rs b/rust/connlib/tunnel/src/client.rs index f2ab915f5..1795924dd 100644 --- a/rust/connlib/tunnel/src/client.rs +++ b/rust/connlib/tunnel/src/client.rs @@ -89,9 +89,14 @@ impl ClientTunnel { } pub fn set_disabled_resources(&mut self, new_disabled_resources: BTreeSet) { + let old_routes = HashSet::::from_iter(self.role_state.routes()); self.role_state .set_disabled_resource(new_disabled_resources); + if HashSet::::from_iter(self.role_state.routes()) == old_routes { + return; + } + self.role_state .buffered_events .push_back(ClientEvent::TunRoutesUpdated { diff --git a/website/src/components/Changelog/Android.tsx b/website/src/components/Changelog/Android.tsx index 688e9f18c..b6e4ede59 100644 --- a/website/src/components/Changelog/Android.tsx +++ b/website/src/components/Changelog/Android.tsx @@ -9,6 +9,17 @@ export default function Android() { href="https://play.google.com/store/apps/details?id=dev.firezone.android" title="Android" > + {/* + +
    + + Fixes a bug where packets would be lost when a connection is first + established to a gateway, due to routes being updated with no actual + change. + +
+
+ */}
    diff --git a/website/src/components/Changelog/Apple.tsx b/website/src/components/Changelog/Apple.tsx index 2dcef1b72..b630ea8d0 100644 --- a/website/src/components/Changelog/Apple.tsx +++ b/website/src/components/Changelog/Apple.tsx @@ -15,6 +15,11 @@ export default function Apple() { Shows the Git SHA corresponding to the build on the Settings -> Advanced screen. + + Fixes a bug where packets would be lost when a connection is first + established to a gateway, due to routes being updated with no actual + change. +
*/}