Commit 5b9ea0c
fix(daemon): tear the tunnel down when it amplifies traffic instead of carrying it
THE OWNER'S MACHINE SENT 3.38 Tb. A live tunnel ran for ~40 minutes at up to
1.34 Gbps OUT with 0 Kbps IN (322 Kb received in total) until he noticed, killed
urnetworkd and took his internet back by hand. That is not a leak or a
misroute — it is an amplifying loop.
THE CAUSE IS IN THE LOG, one line above "tunnel up":
[tun] egress split verified: unmarked -> urnet0, daemon (mark 0x55524e57) -> enp129s0
[tun] egress mark applied to 2 packet(s), 160 byte(s)
TWO packets matched the daemon's own egress-exclusion rule in forty minutes. So
R4 self-exclusion was not in force: the daemon's SDK traffic fell into the tun,
the IoLoop read it back out, sent it again, and it was captured again. Each pass
multiplies. The routing probe passed because it tests the ROUTING DECISION for a
marked vs unmarked packet; nothing tested whether the daemon's actual sockets
ever get marked, and they did not. Root cause of the match failure is still open
and is the next piece of work.
WHAT THIS COMMIT ADDS IS THE THING THAT SHOULD HAVE EXISTED FIRST: a guard that
makes this class of bug survivable. On the reaper tick the daemon samples the
tun's own kernel counters, and after three consecutive strikes of ">64 MiB out
and <1 MiB back" it stops the tunnel, publishes kCodeTunnelStorm and says
plainly that the connection was looping rather than carrying. Deliberately dumb
and slow to fire: a genuinely upload-heavy session still draws ACKs, which move
rx_bytes, so a backup or a large upload cannot trip it. Counters that cannot be
read are treated as no evidence, never as a reason to tear a tunnel down.
A VPN that can saturate a user's uplink for forty minutes without noticing is
missing a safety valve, independently of whichever bug does the saturating.
Verified: both builds clean, 86/86, jammy 2/2, tarball rebuilt. The guard has NOT
been exercised against a real storm — doing that deliberately on the owner's
machine is not a test I am willing to run.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011zv2X6ZPH8h6uBudVCGvG71 parent bb87adb commit 5b9ea0c
3 files changed
Lines changed: 81 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
696 | 696 | | |
697 | 697 | | |
698 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
699 | 705 | | |
700 | 706 | | |
701 | 707 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
957 | 957 | | |
958 | 958 | | |
959 | 959 | | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
960 | 1027 | | |
961 | 1028 | | |
962 | 1029 | | |
963 | 1030 | | |
| 1031 | + | |
964 | 1032 | | |
965 | 1033 | | |
966 | 1034 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
170 | 177 | | |
171 | 178 | | |
172 | 179 | | |
| |||
0 commit comments