From 03c3bb7f1547c35c3019c366bfbcd5bd617b6a7e Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 23 Jul 2024 07:37:44 +1000 Subject: [PATCH] fix(connlib): drop direct traffic from gateway (#5945) In #5917, we introduced a sampled boolean that controls whether direct traffic from clients to gateways is dropped. To correctly, simulate such a network scenario, we also need to drop traffic from gateways back to clients. --- rust/Cargo.lock | 2 +- rust/connlib/tunnel/src/tests/sut.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 4f59965e1..8993f8b1b 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -5897,7 +5897,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "str0m" version = "0.5.1" -source = "git+https://github.com/firezone/str0m?branch=main#07c4fb0449db1fdde4b3421a61b666312ec81106" +source = "git+https://github.com/firezone/str0m?branch=main#b59f9eb58a5a5b506e12163b7fb8ccd088f057f1" dependencies = [ "combine", "crc", diff --git a/rust/connlib/tunnel/src/tests/sut.rs b/rust/connlib/tunnel/src/tests/sut.rs index 7905b37f1..e293f8ff2 100644 --- a/rust/connlib/tunnel/src/tests/sut.rs +++ b/rust/connlib/tunnel/src/tests/sut.rs @@ -497,12 +497,20 @@ impl TunnelTest { match host { HostId::Client(_) => { + if self.drop_direct_client_traffic + && self.gateways.values().any(|g| g.is_sender(src.ip())) + { + tracing::debug!(%src, %dst, "Dropping direct traffic"); + + return; + } + self.client .exec_mut(|c| c.handle_packet(payload, src, dst, self.now)); } HostId::Gateway(id) => { if self.drop_direct_client_traffic && self.client.is_sender(src.ip()) { - tracing::debug!("Dropping direct traffic from client -> gateway"); + tracing::debug!(%src, %dst, "Dropping direct traffic"); return; }