Skip to content

Commit 0fddfd5

Browse files
authored
Merge pull request #505 from NordSecurity/LLT-4351-report-last-known-mesh-state
When meshnet is off, use the last known state to determine path type
2 parents 76e1ba3 + 290f9e6 commit 0fddfd5

File tree

5 files changed

+149
-78
lines changed

5 files changed

+149
-78
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* LLT-4168: Fix telio-dns assert panics in debug mode
1717
* LLT-4856: Enable aggregator timed events
1818
* LLT-4993: Remove most of the forks of dependencies for tvos and replace with latest upstream versions
19+
* LLT-4351: Fix when shutting down meshnet, in the disconnect event, path is sometimes incorrectly reported as direct
1920

2021
<br>
2122

nat-lab/tests/test_mesh_off.py

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,49 @@
1+
import asyncio
12
import pytest
23
import telio
34
from contextlib import AsyncExitStack
45
from helpers import SetupParameters, setup_mesh_nodes
6+
from telio import PathType, State
57
from telio_features import TelioFeatures, Direct
8+
from utils import testing
69
from utils.connection_util import ConnectionTag
10+
from utils.ping import Ping
711

812

913
# Marks in-tunnel stack only, exiting only through IPv4
1014
@pytest.mark.asyncio
1115
@pytest.mark.parametrize(
12-
"alpha_setup_params",
13-
[
14-
pytest.param(
15-
SetupParameters(
16-
connection_tag=ConnectionTag.DOCKER_CONE_CLIENT_1,
17-
adapter_type=telio.AdapterType.LinuxNativeWg,
18-
features=TelioFeatures(direct=Direct(providers=None)),
19-
)
20-
),
21-
],
16+
"direct",
17+
[True, False],
2218
)
23-
@pytest.mark.parametrize(
24-
"beta_setup_params",
25-
[
26-
pytest.param(
27-
SetupParameters(
28-
connection_tag=ConnectionTag.DOCKER_CONE_CLIENT_2,
29-
adapter_type=telio.AdapterType.LinuxNativeWg,
30-
features=TelioFeatures(direct=Direct(providers=None)),
31-
),
32-
),
33-
],
34-
)
35-
async def test_mesh_off(
36-
alpha_setup_params: SetupParameters, beta_setup_params: SetupParameters
37-
) -> None:
19+
async def test_mesh_off(direct) -> None:
3820
async with AsyncExitStack() as exit_stack:
21+
features = (
22+
TelioFeatures(direct=Direct(providers=None))
23+
if direct
24+
else TelioFeatures(direct=None)
25+
)
3926
env = await setup_mesh_nodes(
40-
exit_stack, [alpha_setup_params, beta_setup_params]
27+
exit_stack,
28+
[
29+
SetupParameters(
30+
connection_tag=ConnectionTag.DOCKER_CONE_CLIENT_1,
31+
adapter_type=telio.AdapterType.LinuxNativeWg,
32+
features=features,
33+
),
34+
SetupParameters(
35+
connection_tag=ConnectionTag.DOCKER_CONE_CLIENT_2,
36+
adapter_type=telio.AdapterType.LinuxNativeWg,
37+
features=features,
38+
),
39+
],
4140
)
41+
alpha, beta = env.nodes
4242

43-
client_alpha, _ = env.clients
44-
connection_alpha, _ = [conn.connection for conn in env.connections]
43+
client_alpha, client_beta = env.clients
44+
connection_alpha, connection_beta = [
45+
conn.connection for conn in env.connections
46+
]
4547

4648
await client_alpha.set_mesh_off()
4749

@@ -58,3 +60,25 @@ async def test_mesh_off(
5860
assert (
5961
"peer:" not in wg_show_stdout.strip().split()
6062
), f"There are leftover WireGuard peers after mesh is set to off: {wg_show_stdout}"
63+
64+
path_type = PathType.Direct if direct else PathType.Relay
65+
66+
await client_alpha.wait_for_state_peer(
67+
beta.public_key, [State.Disconnected], [path_type]
68+
)
69+
70+
await client_alpha.set_meshmap(env.api.get_meshmap(alpha.id))
71+
72+
asyncio.gather(
73+
client_alpha.wait_for_state_peer(
74+
beta.public_key, [State.Connected], [path_type]
75+
),
76+
client_beta.wait_for_state_peer(
77+
alpha.public_key, [State.Connected], [path_type]
78+
),
79+
)
80+
81+
async with Ping(connection_alpha, beta.ip_addresses[0]).run() as ping:
82+
await testing.wait_lengthy(ping.wait_for_next_ping())
83+
async with Ping(connection_beta, alpha.ip_addresses[0]).run() as ping:
84+
await testing.wait_long(ping.wait_for_next_ping())

0 commit comments

Comments
 (0)