When A selects B and B selects C, B’s own default route must not carry A’s forwarded packets on to C. Accept only locally sourced overlay traffic for the client default, while keeping authenticated member traffic on the physical uplink from its first packet. Replies still route to the owning member. Switching B’s default does not tear down A’s existing flows. On Linux, distinguish forwarded packets and SNAT replies from local traffic, including strict reverse-path checks when the agent runs as root. On macOS, tag packets on the offered utun and keep their PF NAT state on the physical interface. On Windows, use interface-bound sockets and a bounded smoltcp TCP endpoint, UDP flow mappings and ICMP echo. An offer and its live sockets survive changes to the client's split routes and transient uplink discovery failures. Remove only owned legacy WinNAT objects. Document the supported IPv4 protocols and resource limits. Real WireGuard agents exercised A, B and C. Two Linux ARM64 namespace tests passed in an isolated Colima container with strict reverse-path filtering. The same destination saw A keep its physical SNAT TCP session while B's local connections switched to C and back. Strict Linux core Clippy passed. Six portable socket regressions passed on macOS, including TCP resets, both half-close orders, UDP port stability and resource limits. The macOS PF rules passed native syntax checking and the Windows target cross-compiled on macOS. Extended privileged macOS and Windows fixtures are available in CI; neither native system routing test ran on this host.
120 lines
5.7 KiB
YAML
120 lines
5.7 KiB
YAML
name: Native subnet source selection
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
paths:
|
|
- '.github/workflows/subnet-source.yml'
|
|
- 'crates/tsunagi-core/src/overlay/egress.rs'
|
|
- 'crates/tsunagi-core/src/overlay/egress/**'
|
|
- 'crates/tsunagi-core/src/overlay/interface.rs'
|
|
- 'crates/tsunagi-core/src/overlay/router.rs'
|
|
- 'crates/tsunagi-core/src/overlay/hostrules/linux_exit*.rs'
|
|
- 'crates/tsunagi-core/src/overlay/provision/linux.rs'
|
|
- 'crates/tsunagi-core/src/overlay/hostrules/macos*.rs'
|
|
- 'crates/tsunagi-core/src/overlay/hostrules/windows*.rs'
|
|
- 'crates/tsunagi-core/src/overlay/provision/macos.rs'
|
|
- 'crates/tsunagi-core/src/overlay/provision/windows.rs'
|
|
- 'crates/tsunagi-core/src/overlay/provision/mod.rs'
|
|
- 'crates/tsunagi-core/src/overlay/provision/factory.rs'
|
|
- 'crates/tsunagi-core/src/overlay/tun.rs'
|
|
- 'crates/tsunagi-core/src/net.rs'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
source:
|
|
if: github.server_url == 'https://github.com'
|
|
runs-on: ${{ matrix.os }}
|
|
timeout-minutes: 45
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
test: overlay::hostrules::linux_exit_kernel::serving_an_established_flow_while_switching_the_local_exit
|
|
- os: macos-latest
|
|
test: overlay::provision::macos::tests::unbound_sockets_choose_each_networks_source_on_one_real_utun
|
|
- os: windows-latest
|
|
test: overlay::provision::windows::tests::two_windows_subnets_choose_their_own_source_and_survive_removal
|
|
env:
|
|
TEST_NAME: ${{ matrix.test }}
|
|
CARGO_PROFILE_TEST_DEBUG: '0'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Build and locate the native test
|
|
shell: pwsh
|
|
run: |
|
|
$artifacts = @(cargo test --locked -p tsunagi-core --lib --features tun-device --no-run --message-format=json-render-diagnostics |
|
|
ForEach-Object { ConvertFrom-Json -InputObject $_ } |
|
|
Where-Object { $_.reason -eq 'compiler-artifact' -and $_.target.name -eq 'tsunagi' -and $_.profile.test -and $_.executable })
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
if ($artifacts.Count -ne 1) { throw "Expected one core test binary, found $($artifacts.Count)" }
|
|
$binary = $artifacts[0].executable
|
|
$tests = @(& $binary --ignored --exact $env:TEST_NAME --list)
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
if ($tests -notcontains "$($env:TEST_NAME): test") { throw "Missing ignored test: $env:TEST_NAME" }
|
|
"TEST_BINARY=$binary" >> $env:GITHUB_ENV
|
|
- name: Verify separate forwarding and local egress in Linux namespaces
|
|
if: runner.os == 'Linux'
|
|
shell: bash
|
|
run: sudo -n -- "$TEST_BINARY" --ignored --exact "$TEST_NAME" --nocapture
|
|
- name: Verify source selection on a real utun
|
|
if: runner.os == 'macOS'
|
|
shell: bash
|
|
run: sudo -n -- "$TEST_BINARY" --ignored --exact "$TEST_NAME" --nocapture
|
|
- name: Verify exit routing and PF translation on two real utuns
|
|
if: runner.os == 'macOS'
|
|
shell: bash
|
|
timeout-minutes: 2
|
|
env:
|
|
EXIT_TEST: overlay::hostrules::macos_exit::kernel::exit_preserves_underlay_and_both_meshes
|
|
run: |
|
|
"$TEST_BINARY" --ignored --exact "$EXIT_TEST" --list | grep -Fx "$EXIT_TEST: test"
|
|
previous=$(sysctl -n net.inet.ip.forwarding)
|
|
trap 'sudo -n sysctl -w "net.inet.ip.forwarding=$previous"' EXIT
|
|
sudo -n sysctl -w net.inet.ip.forwarding=1
|
|
sudo -n -- "$TEST_BINARY" --ignored --exact "$EXIT_TEST" --nocapture
|
|
- name: Verify source selection on a real Wintun adapter
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
$zip = Join-Path $env:RUNNER_TEMP 'wintun.zip'
|
|
Invoke-WebRequest -Uri https://www.wintun.net/builds/wintun-0.14.1.zip -OutFile $zip
|
|
# This is the signed Wintun distribution pinned by the Windows installer.
|
|
if ((Get-FileHash $zip -Algorithm SHA256).Hash -ne '07C256185D6EE3652E09FA55C0B673E2624B565E02C4B9091C79CA7D2F24EF51') {
|
|
throw 'Unexpected Wintun archive checksum'
|
|
}
|
|
$directory = Join-Path $env:RUNNER_TEMP 'wintun-dl'
|
|
Expand-Archive -Path $zip -DestinationPath $directory
|
|
Copy-Item (Join-Path $directory 'wintun/bin/amd64/wintun.dll') (Split-Path -Parent $env:TEST_BINARY)
|
|
& $env:TEST_BINARY --ignored --exact $env:TEST_NAME --nocapture
|
|
exit $LASTEXITCODE
|
|
- name: Verify forwarded and local traffic to the same destination
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
timeout-minutes: 2
|
|
run: |
|
|
$test = 'overlay::egress::tests::physical_member_sockets_survive_a_more_specific_wintun_route'
|
|
$listing = @(& $env:TEST_BINARY --ignored --exact $test --list)
|
|
if ($listing -notcontains "${test}: test") { throw "Missing ignored test $test" }
|
|
& $env:TEST_BINARY --ignored --exact $test --nocapture
|
|
exit $LASTEXITCODE
|
|
- name: Verify one Windows exit bypass route through the physical gateway
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
timeout-minutes: 2
|
|
run: |
|
|
$test = 'overlay::hostrules::windows_exit::tests::windows_refresh_installs_only_the_external_test_address'
|
|
$listing = @(& $env:TEST_BINARY --ignored --exact $test --list)
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
if ($listing -notcontains "${test}: test") { throw "Missing ignored test: $test" }
|
|
& $env:TEST_BINARY --ignored --exact $test --nocapture
|
|
exit $LASTEXITCODE
|