From 4750d76fce9cf3b08bea0fdf92beef71debf5805 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sat, 17 Aug 2024 00:14:00 +0100 Subject: [PATCH] fix(relay): re-insert channel into fast-path map (#6332) This is a test-failure detected in https://github.com/firezone/firezone/actions/runs/10426492110/job/28879531621. In the relay, we have fast-path lookup maps to for incoming traffic from peers. This improves throughput as any incoming packet only needs to look-up a single routing entry. Unfortunately, this creates duplication in how the data must be stored. In #6276, we correctly identified that channels must be re-bound on the relay when a client sends `CHANNEL_BIND` message whilst the channel is cooling down. What we failed to identify (and what as now caught by the tests) is that we also need to re-insert the entry into the fast-path lookup map to actually allow data from flowing through the channel. --- rust/connlib/tunnel/proptest-regressions/tests.txt | 1 + rust/relay/src/server.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/rust/connlib/tunnel/proptest-regressions/tests.txt b/rust/connlib/tunnel/proptest-regressions/tests.txt index 4ff08479d..83b961fdf 100644 --- a/rust/connlib/tunnel/proptest-regressions/tests.txt +++ b/rust/connlib/tunnel/proptest-regressions/tests.txt @@ -83,3 +83,4 @@ cc 26e8d4724f565037da88b0363f5ee4202d2feecb4ad9ad227d806582cf81919b cc 28c9fbe9572e61da2342347e3e5c159f3d4a62e90f3d85d6b7911fd015845656 cc ec2f348067458f6a7d3f2fbd1ab708a53fc27708440a3fcb6ed8557adc6db7d3 cc 2984b737f902f82c96ffec888a624afd7117078c125822b85de908c05f8e0b4c +cc 51ad9fe7ef585d42bd1a6369da810a5adb6d756e71aa393362e542f1560d0273 diff --git a/rust/relay/src/server.rs b/rust/relay/src/server.rs index a18434ca2..e7f84bd37 100644 --- a/rust/relay/src/server.rs +++ b/rust/relay/src/server.rs @@ -672,6 +672,12 @@ where channel.refresh(now); + // Update the fast-path map in case the binding expired in the cooldown period and got removed. + self.channel_and_client_by_port_and_peer.insert( + (channel.allocation, channel.peer_address), + (sender, requested_channel), + ); + tracing::info!(target: "relay", "Refreshed channel binding"); self.send_message(