Skip to content

Commit 186541e

Browse files
committed
Remove dummy interfaces
1 parent 56f79e0 commit 186541e

File tree

3 files changed

+3
-70
lines changed

3 files changed

+3
-70
lines changed

test/test-manager/src/vm/network/linux.rs

+2-33
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ pub const BRIDGE_NAME: &str = "br-mullvadtest";
2525
/// TAP interface used by the guest
2626
pub const TAP_NAME: &str = "tap-mullvadtest";
2727

28-
/// Pingable dummy LAN interface (name)
29-
pub const DUMMY_LAN_INTERFACE_NAME: &str = "lan-mullvadtest";
30-
/// Pingable dummy LAN interface (IP)
31-
pub const DUMMY_LAN_INTERFACE_IP: Ipv4Addr = Ipv4Addr::new(172, 29, 1, 200);
32-
/// Pingable dummy interface with public IP (name)
33-
pub const DUMMY_INET_INTERFACE_NAME: &str = "net-mullvadtest";
34-
/// Pingable dummy interface with public IP (IP)
35-
pub const DUMMY_INET_INTERFACE_IP: Ipv4Addr = Ipv4Addr::new(1, 3, 3, 7);
36-
3728
// Private key of the wireguard remote peer on host.
3829
const CUSTOM_TUN_REMOTE_PRIVKEY: &str = "gLvQuyqazziyf+pUCAFUgTnWIwn6fPE5MOReOqPEGHU=";
3930
// Public key of the wireguard remote peer on host.
@@ -47,9 +38,9 @@ data_encoding_macro::base64_array!(
4738
"pub const CUSTOM_TUN_LOCAL_PRIVKEY" = "mPue6Xt0pdz4NRAhfQSp/SLKo7kV7DW+2zvBq0N9iUI="
4839
);
4940

50-
/// "Real" (non-tunnel) IP of the wireguard remote peer as defined in `setup-network.sh`.
41+
/// "Real" (non-tunnel) IP of the wireguard remote peer on the host
5142
#[allow(dead_code)]
52-
pub const CUSTOM_TUN_REMOTE_REAL_ADDR: Ipv4Addr = Ipv4Addr::new(172, 29, 1, 200);
43+
pub const CUSTOM_TUN_REMOTE_REAL_ADDR: Ipv4Addr = Ipv4Addr::new(172, 29, 1, 1);
5344
/// Port of the wireguard remote peer as defined in `setup-network.sh`.
5445
#[allow(dead_code)]
5546
pub const CUSTOM_TUN_REMOTE_REAL_PORT: u16 = 51820;
@@ -134,28 +125,6 @@ table ip mullvad_test_nat {{
134125
))
135126
.await?;
136127

137-
log::debug!("Set up pingable hosts");
138-
139-
run_ip_cmd(["link", "add", DUMMY_LAN_INTERFACE_NAME, "type", "dummy"]).await?;
140-
run_ip_cmd([
141-
"addr",
142-
"add",
143-
"dev",
144-
DUMMY_LAN_INTERFACE_NAME,
145-
&DUMMY_LAN_INTERFACE_IP.to_string(),
146-
])
147-
.await?;
148-
149-
run_ip_cmd(["link", "add", DUMMY_INET_INTERFACE_NAME, "type", "dummy"]).await?;
150-
run_ip_cmd([
151-
"addr",
152-
"add",
153-
"dev",
154-
DUMMY_INET_INTERFACE_NAME,
155-
&DUMMY_INET_INTERFACE_IP.to_string(),
156-
])
157-
.await?;
158-
159128
log::debug!("Create WireGuard peer");
160129

161130
create_local_wireguard_peer().await?;

test/test-manager/src/vm/network/macos.rs

-35
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ use anyhow::{anyhow, Context, Result};
44
use futures::future::{self, Either};
55
use tokio::{io::AsyncWriteExt, process::Command};
66

7-
/// Pingable dummy LAN interface (IP)
8-
pub const DUMMY_LAN_INTERFACE_IP: Ipv4Addr = Ipv4Addr::new(192, 168, 64, 254);
9-
107
// Private key of the wireguard remote peer on host.
118
const CUSTOM_TUN_REMOTE_PRIVKEY: &str = "gLvQuyqazziyf+pUCAFUgTnWIwn6fPE5MOReOqPEGHU=";
129
// Public key of the wireguard remote peer on host.
@@ -50,41 +47,9 @@ pub async fn setup_test_network() -> Result<()> {
5047
.await
5148
.context("Failed to create WireGuard interface")?;
5249

53-
// A bit of trickery to detect when the bridge is available.
54-
tokio::spawn(async move {
55-
for _ in 0..30 {
56-
let Ok(interface) = find_vm_bridge() else {
57-
tokio::time::sleep(Duration::from_secs(1)).await;
58-
continue;
59-
};
60-
match create_dummy_interface(interface).await {
61-
Ok(_) => log::debug!("Created dummy interface"),
62-
Err(error) => log::error!("Failed to create dummy interface: {error}"),
63-
}
64-
return;
65-
}
66-
log::error!("Failed to create dummy interface: timed out");
67-
});
68-
6950
Ok(())
7051
}
7152

72-
async fn create_dummy_interface(interface: String) -> Result<()> {
73-
let mut cmd = Command::new("/usr/bin/sudo");
74-
cmd.args([
75-
"/sbin/ifconfig",
76-
&interface,
77-
"alias",
78-
&DUMMY_LAN_INTERFACE_IP.to_string(),
79-
]);
80-
let output = cmd.output().await.context("Create dummy interface")?;
81-
if output.status.success() {
82-
Ok(())
83-
} else {
84-
Err(anyhow!("ifconfig failed: {:?}", output.status.code()))
85-
}
86-
}
87-
8853
/// A hack to find the Tart bridge interface using `NON_TUN_GATEWAY`.
8954
/// It should be possible to retrieve this using the virtualization framework instead,
9055
/// but that requires an entitlement.

test/test-manager/src/vm/network/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ pub use macos as platform;
1212
pub use platform::{
1313
CUSTOM_TUN_GATEWAY, CUSTOM_TUN_INTERFACE_NAME, CUSTOM_TUN_LOCAL_PRIVKEY,
1414
CUSTOM_TUN_LOCAL_TUN_ADDR, CUSTOM_TUN_REMOTE_PUBKEY, CUSTOM_TUN_REMOTE_REAL_ADDR,
15-
CUSTOM_TUN_REMOTE_REAL_PORT, CUSTOM_TUN_REMOTE_TUN_ADDR, DUMMY_LAN_INTERFACE_IP,
16-
NON_TUN_GATEWAY,
15+
CUSTOM_TUN_REMOTE_REAL_PORT, CUSTOM_TUN_REMOTE_TUN_ADDR, NON_TUN_GATEWAY,
1716
};
1817

1918
/// Port on NON_TUN_GATEWAY that hosts a SOCKS5 server

0 commit comments

Comments
 (0)