Skip to content

Commit df3678c

Browse files
committed
Fix OpenVMM forwarded SSH ingress rule
Restore the forwarded SSH filter rule so DNAT traffic to the guest is accepted from any non-OpenVMM bridge ingress interface. The cleanup refactor accidentally tied the SSH path to the default route interface, which breaks baremetal hosts where the incoming management path is not that interface. Keep cleanup precise by continuing to track the exact inserted rule, and update the OpenVMM node selftest to reject the default-interface-constrained rule shape.
1 parent 2a81a94 commit df3678c

3 files changed

Lines changed: 15 additions & 35 deletions

File tree

lisa/sut_orchestrator/openvmm/node.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,16 +1209,15 @@ def _wait_for_guest_ssh_from_host(
12091209
log: Logger,
12101210
timeout: int = OPENVMM_CONNECTION_TIMEOUT,
12111211
) -> None:
1212-
command = (
1213-
"for i in $(seq 1 "
1214-
f"{timeout}); do "
1212+
probe_command = (
1213+
"while true; do "
12151214
"timeout 1 bash -c "
12161215
f"{shlex.quote(f'</dev/tcp/{guest_address}/{guest_port}')} "
12171216
">/dev/null 2>&1 && exit 0; "
12181217
"sleep 1; "
1219-
"done; "
1220-
"exit 1"
1218+
"done"
12211219
)
1220+
command = f"timeout {timeout} bash -c " f"{shlex.quote(probe_command)}"
12221221
result = self.host_node.execute(
12231222
command,
12241223
shell=True,
@@ -1703,8 +1702,8 @@ def _enable_ssh_forwarding(
17031702
),
17041703
(
17051704
"",
1706-
"FORWARD -i "
1707-
f"{shlex.quote(forwarding_interface)} -o "
1705+
"FORWARD ! -i "
1706+
f"{shlex.quote(host_interface)} -o "
17081707
f"{shlex.quote(host_interface)} "
17091708
f"-p tcp -d {guest_address} --dport {guest_port} -j ACCEPT",
17101709
),

lisa/tools/cargo.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from lisa.tools.curl import Curl
1212
from lisa.tools.echo import Echo
1313
from lisa.tools.gcc import Gcc
14-
from lisa.tools.ln import Ln
15-
from lisa.tools.rm import Rm
1614
from lisa.util import LisaException, UnsupportedDistroException
1715
from lisa.util.process import ExecutableResult
1816

@@ -98,20 +96,6 @@ def _install(self) -> bool:
9896
expected_exit_code=0,
9997
expected_exit_code_failure_message="curl fetch failed",
10098
)
101-
102-
ln = self.node.tools[Ln]
103-
ln.create_link(
104-
is_symbolic=True,
105-
target=cargo_bin,
106-
link="/usr/local/bin/cargo",
107-
force=True,
108-
)
109-
ln.create_link(
110-
is_symbolic=True,
111-
target=rustup_bin,
112-
link="/usr/local/bin/rustup",
113-
force=True,
114-
)
11599
else:
116100
raise UnsupportedDistroException(node_os)
117101

@@ -126,15 +110,6 @@ def _install(self) -> bool:
126110
self._command = cargo_bin
127111
self._exists = None
128112
is_installed = self._check_exists()
129-
130-
self.node.tools[Rm].remove_file(
131-
"/usr/local/bin/cargo",
132-
sudo=True,
133-
)
134-
self.node.tools[Rm].remove_file(
135-
"/usr/local/bin/rustup",
136-
sudo=True,
137-
)
138113
return is_installed
139114

140115
def wrap_with_rustup_lock(self, command: str) -> str:

selftests/test_openvmm_node.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def _execute(command: str, *args: Any, **kwargs: Any) -> Any:
342342
)
343343
self.assertTrue(
344344
any(
345-
f"iptables -C FORWARD -i eth0 -o {bridge_name} "
345+
f"iptables -C FORWARD ! -i {bridge_name} -o {bridge_name} "
346346
f"-p tcp -d {guest_address} --dport 22 -j ACCEPT" in command
347347
for command in commands
348348
)
@@ -368,7 +368,7 @@ def _execute(command: str, *args: Any, **kwargs: Any) -> Any:
368368
)
369369
self.assertTrue(
370370
any(
371-
f"iptables -I FORWARD -i eth0 -o {bridge_name} "
371+
f"iptables -I FORWARD ! -i {bridge_name} -o {bridge_name} "
372372
f"-p tcp -d {guest_address} --dport 22 -j ACCEPT" in command
373373
for command in commands
374374
)
@@ -394,7 +394,7 @@ def _execute(command: str, *args: Any, **kwargs: Any) -> Any:
394394
)
395395
self.assertTrue(
396396
any(
397-
f"iptables -D FORWARD -i eth0 -o {bridge_name} "
397+
f"iptables -D FORWARD ! -i {bridge_name} -o {bridge_name} "
398398
f"-p tcp -d {guest_address} --dport 22 -j ACCEPT" in command
399399
for command in commands
400400
)
@@ -405,6 +405,12 @@ def _execute(command: str, *args: Any, **kwargs: Any) -> Any:
405405
for command in commands
406406
)
407407
)
408+
self.assertFalse(
409+
any(
410+
f"FORWARD -i eth0 -o {bridge_name} -p tcp -d {guest_address}" in command
411+
for command in commands
412+
)
413+
)
408414

409415
def test_configure_connection_uses_host_proxy_mode(self) -> None:
410416
host_connection = schema.ConnectionInfo(

0 commit comments

Comments
 (0)