Loopback has no physical-link errors, but software queues, memory pressure, filtering and scheduling can still cause drops or retransmissions. The record began with 62 lines containing retrans and later found a local RST-drop rule. Retain those readings while checking units and causality.
1. The symptom: dies under load, fine after a reboot, nothing left to inspect
A home router running a transparent proxy failed during evening peak: new connections failed in large numbers, clients repeatedly retried, and the CPU reached full load. A reboot restored service.
The worst part is that the reboot destroyed the evidence. On this machine:
logread 128KB in-memory ring, empty after reboot
/var/log tmpfs
collectd/RRD not installed
pstore/ramoops absent
wtmp empty
These settings can turn an oops into a panic and reboot after about three seconds. Persistent or remote logs and dumps determine what survives. Missing listed local records does not establish that all evidence must vanish.
2. Establish what the count of 62 measures
Two of four cores were busy at load average around 2. Inspect IRQ, softirq, RPS/RFS, queues and scheduling; a single NIC queue alone does not restrict all networking to two cores. Load average does not measure network throughput or latency.
The original command and output follow. grep -c counts matching lines, and this command does not restrict loopback addresses. Parse socket endpoints and retrans fields before counting loopback retransmitted packets:
ss -tin | grep -c retrans # retransmissions on loopback connections
The recorded output is 62 matching lines, not by itself 62 retransmitted packets.
Investigate loopback processing, pressure, filtering and timeouts. Absence of a physical link does not exclude these mechanisms or prove deliberate packet drops.
Ask which local connections missed timely packet or acknowledgement processing, and which rules or resource states correlate with them.
3. Socket states and packet evidence
The record classifies selected sockets as 53 LAST_ACK and nine CLOSE_WAIT. Current state does not establish when their accumulated retransmissions occurred.
LAST_ACK 53
CLOSE_WAIT 9
everything else 0
Both states belong to connection teardown:
CLOSE_WAIT: the peer’s FIN arrived, the local side has not closed yetLAST_ACK: the local side sent its FIN and is waiting for the final ACK
LAST_ACK awaits acknowledgement of FIN; CLOSE_WAIT awaits the application’s close after peer FIN. RST is not normally retransmitted by the TCP retransmission timer. State and historical retrans counters do not identify the missing packets; combine captures with rule counters.
4. Root cause: the rule protected the wrong address
The router carried an nftables rule that drops RST packets originating from a set of upstream addresses (a common technique when a middlebox injects forged resets):
ip saddr @protected_node_v4 tcp flags & rst == rst drop
That @protected_node_v4 set is synced every two minutes by a cron script, which awks the server: field out of the upper proxy’s configuration.
Here is the problem: the chain has two layers. The upper proxy hands traffic to a local process on the same box, so all six of its configured nodes carry server: 127.0.0.1. The real upstream addresses live in the address field of a different config file entirely.
So the synced set was:
protected_node_v4 = { 127.0.0.1 }
The shown set and rule drop matching 127.0.0.1 RST packets traversing that hook. The original 1074 hits over about 21 minutes extrapolate to roughly 73,500 per day at constant rate, rather than an observed full day.
5. A candidate resource-accumulation chain
RSTs dropped
-> sockets on both ends stick in LAST_ACK / CLOSE_WAIT, never released
-> file descriptors and socket buffers accumulate
-> the processes have an nofile limit of only 4096
-> peak traffic approaches the ceiling, new connections fail to be created
-> clients retry furiously
-> the one or two cores that can handle networking peg
-> presents as "the network is dead"
The record reports 252 connections and 1983 descriptors, a ratio near 7.8. Extrapolating to 4096 gives about 520 only under a zero-fixed-overhead linear model. nofile is per process; compare per-process baselines, increments and EMFILE evidence instead of pooled counts.
6. The fork in the road that sends you after the wrong bug
Staring at a climbing fd count, it is very easy to conclude “the upstream process leaks descriptors” and disappear into its issue tracker.
But the fd count came back down: 1968 → 980.
The fall from 1968 to 980 establishes reduced net use, not absence of every leak. Normal connections can close during lower traffic while leaked descriptors remain. Compare idle baselines and ownership under matched load cycles.
Observe multiple load cycles and idle baselines, correlating application closes, kernel sockets and process descriptors. A LAST_ACK socket can already have no process fd; state counts are not descriptor counts.
7. The other half of the same bug: an experiment that had never run
That same wrong set was referenced by a second rule, which adds a fixed delay to traffic bound for the upstream nodes as a controlled experiment:
oifname "eth0" ip daddr @protected_node_v4 ...
Under ordinary routing, 127.0.0.1 uses lo and will not match an eth0 output requirement. Check special route_localnet, namespaces or policy routes separately. The recorded zero counter supports no matches in that observation.
This rule caused no outage, but still needed a matching check: without a counter, a rule that never matches looks like a rule that works perfectly. Inspect the counters in nft list ruleset -a when deploying a rule.
8. Fix and verification
The fix itself is small: point the sync script at the correct config file, and add a public-address allowlist that rejects loopback, RFC1918 space, link-local, multicast, and the fake-IP ranges proxy software commonly uses.
The original before/after snapshots remain below. They are not timestamp-paired with the earlier 53/9 classification and 62-line count. Address sets and fd limits were both changed, so the snapshots cannot assign every outcome to one intervention.
| Metric | Before | After |
|---|---|---|
| Loopback retransmissions | 62 | 0 |
| Loopback connection states | 11 CLOSE_WAIT + 7 LAST_ACK + 6 FIN_WAIT2 | 110 ESTABLISHED + 49 TIME_WAIT |
| Set contents | { 127.0.0.1 } |
4 real upstream addresses |
TIME_WAIT shows that those connections reached that close state. It does not prove all earlier teardowns failed or every current connection is healthy. Reset closures can legitimately skip TIME_WAIT.
The record raised nofile from 4096 to 65535. Higher limits provide headroom and permit more resource use. Evaluate process demand and reclamation separately.
9. The second trap: nftables chain priority decides what state you can read
Dropping early RST is a heuristic, not forgery detection. Legitimate refusals and resets can occur within the first 20 packets. Include legitimate-reset controls when checking the policy.
ct original packets <= 20
The original rule hangs off prerouting priority raw, which is -300. Adding the condition in place is the obvious, minimal edit.
The record’s raw rule had zero hits and its mangle counterpart had hits. Check hook timing and accounting prerequisites before interpreting that difference.
On the usual inbound prerouting path, raw=-300 precedes conntrack=-200, so a new packet may not yet be associated. Also inspect hook, existing associations, NOTRACK and nf_conntrack_acct; flow packet counters need accounting support.
That conclusion was not reasoned out, it was measured: build two identical rules, one in the raw chain and one in mangle, each with a counter, and let them run:
raw chain counter = 0
mangle chain counter = 108
Mangle is normally -150, so mangle-10 is -160, after -200. Retain the original LAST_ACK reduction from 40–90 to zero, upstream retransmission result and rising hit count. A hit proves a match, not that every dropped RST was forged.
Check that a conntrack field exists at the selected hook and priority and that accounting is enabled. Operations such as setting ct zone belong before tracking, so not every ct operation should run afterwards.
10. What this cost and what it taught
- Start with a localisable anomaly and distinguish software processing, resource pressure and filtering; loopback retransmission is possible.
- Record states and counter changes together. Current state and lifetime retransmissions provide different evidence and need timestamps.
- Compare fd baselines under matched load cycles. A rise does not prove a leak; a decline does not exclude one.
- Use rule counters, traces or controlled packets to confirm matches, recording window and configuration.
- Keep traffic and rule placement comparable in twin tests and interpret them with documented semantics.
- Persistent logs and resource trends aid postmortems; counters, external monitoring and reproducible tests provide additional evidence.
References
- nft(8): chain types, hooks and priorities
- RFC 9293: TCP specification (state machine and teardown)
- ss(8): socket statistics and the
-iretransmit counters
Related: TCP reliability and the congestion window (what a retransmission means at the protocol level), forward and reverse proxy trust boundaries (how layered proxies are structured), and SOCKS5 proxies and DNS boundaries.
