tcp: rehash onto different local ECMP path on retransmit timeout
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v14 Latest1 of 2 patches 1 replyIn review 1 of 2 applied
- v132 patches 2 repliesSuperseded
- v122 patches 2 repliesSuperseded
Earlier versions · 11
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v11 | 2 patches | 1 reply | Superseded | |
| v10 | 2 patches | 0 replies | Superseded | |
| v9 | 2 patches | 0 replies | Superseded | |
| v8 | 2 patches | 0 replies | Superseded | |
| v7 | 2 patches | 2 replies | Superseded | |
| v6 | 2 patches | 1 reply | Superseded | |
| v5 | 2 patches | 1 reply | Superseded | |
| v4 | 2 patches | 1 reply | Superseded | |
| v3 | 2 patches | 1 reply | Superseded | |
| v2 | 2 patches | 3 replies | Superseded | |
| v1 | 2 patches | 2 replies | Superseded |
1 of 2 patches is in this archive. The cover letter announces 2.
Patches in v14 1 of 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | tcp: rehash onto different local ECMP path on retransmit timeoutDocumentation/ include/ include/ +9 more | +91 | 1 reply | Applied |
Reviews trailers per patch
The patch has a Reviewed-by or Acked-by.
| Patch | Eric Dumazet |
|---|---|
| 1/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net-next v14 0/2] tcp: rehash onto different local ECMP path on retransmit timeout
Currently sk_rethink_txhash() re-rolls the socket's txhash on RTO, PLB, and spurious-retransmission events, but the new hash is not propagated into the IPv6 ECMP path selection. The cached route is reused and fib6_select_path() is never re-invoked, so the connection uses the same local ECMP decision.
This series adds the two missing pieces:
1. __sk_dst_reset() alongside sk_rethink_txhash() so the cached dst is invalidated and the next transmit triggers a fresh route lookup.
2. fl6->mp_hash set from sk_txhash before each route lookup so fib6_select_path() picks a path from the (potentially re-rolled) hash.
The override applies only to fib_multipath_hash_policy 0 (the default L3 policy). Its hash includes the flow label, but that is 0 by default (np->flow_label is unset; auto_flowlabels computes the on-wire label later, per packet), so flows to the same peer share one local path. Keying it on sk_txhash makes that local path per-connection and lets a rehash re-select it; even when a flow label is present (reflected REPFLOW or explicitly set) only local path selection changes -- the on-wire flow label is unaffected. Policies 1-3 are left unchanged.
Patch 1 is the kernel change; patch 2 adds selftests covering rehash on SYN, SYN/ACK, midstream RTO, midstream spurious-retransmission, and PLB events, plus a policy 1 negative test, a flowlabel-leak regression test, a dst-rebuild consistency test, and a syncookie path-consistency test.
Changes since v13: https://lore.kernel.org/netdev/[email protected]/
Patch 1:
- Set the syncookie txhash from the cookie unconditionally, dropping the
v11 IPv6-only guard; on IPv4 it only feeds TX-queue selection (Paolo Abeni)
Patch 2:
- Pin DCTCP for the PLB test with a route congctl attribute instead of
the host-global tcp_allowed_congestion_control (Sashiko AI review)
- Drop the redundant syncookie dst-rebuild test, already covered by the
dst rebuild and syncookie path consistency tests (Sashiko AI review)
- Give each test (and retry) its own port via an alloc_ports helper to
avoid overlap (Sashiko AI review)
Changes since v12: https://lore.kernel.org/netdev/[email protected]/
Patch 1:
- Factor the repeated policy-0 IPv6 mp_hash assignment into a shared ip6_ecmp_set_mp_hash() helper (Paolo Abeni)
- Replace the open-coded txhash reroll + dst reset at the three rehash
sites with a __sk_rethink_txhash_reset_dst() helper, kept separate
from sk_rethink_txhash() so dst_negative_advice()'s dst op still runs (Paolo Abeni)
Patch 2:
- Check the first rehash attempt's exit status directly instead of via
$? (shellcheck SC2181), and drop the redundant fail_reason capture on
the tolerated first attempt (Paolo Abeni)
- Redirect the remaining slowwait stdout to /dev/null so loopy_wait's
counter output cannot leak into the captured failure message
(Sashiko AI review)
Changes since v11: https://lore.kernel.org/netdev/[email protected]/
Patch 1:
- Fix the IPv6-only rule to exclude IPv4-mapped connections: key the
cookie txhash on skb->protocol, not sk->sk_family (Sashiko AI review)
- Set fl6->mp_hash in tcp_v6_send_response() so RSTs and time-wait
ACKs use the connection's ECMP path (Sashiko AI review)
- Remove the bpf_sk_assign_tcp_reqsk() txhash init added in v7; it is redundant, as cookie_tcp_reqsk_init() always sets txhash before the
request socket is routed (verified by poisoning txhash and running
the tcp_custom_syncookie BPF selftest: the route lookup never saw
the poison)
- Document that policy 0 IPv6 TCP ECMP selection follows txhash over a reflected/explicit flow label (on-wire flow label unchanged)
Patch 2:
- Drain TCP teardown between rounds so late FIN/RST packets do not
pollute the next round's tc filter counters (bot+bpf-ci)
- Skip the syncookie tests when CONFIG_SYN_COOKIES is unavailable;
select it in selftests/net/config
Changes since v10: https://lore.kernel.org/netdev/[email protected]/
Patch 1:
- Fix build without CONFIG_SYN_COOKIES
- Leave IPv4 syncookie txhash unmodified (net_tx_rndhash())
- Document the IPv6 TCP policy 0 behavior change in ip-sysctl.rst
Patch 2:
- Correct runtime estimate from ~15s to ~60s
- Build DCTCP as =y instead of =m to avoid module load races
- Fix false failure of the midstream ACK test by limiting the send
buffer to avoid a closed receive window; window probes do not
cause rehash
Changes since v9: https://lore.kernel.org/netdev/[email protected]/
Patch 1:
- Split cookie_init_sequence() into pure computation and a new cookie_record_sent() helper for the side effects; call
cookie_record_sent() after route_req() succeeds so the overflow
timestamp and SYNCOOKIESSENT counter are not bumped when no
SYN-ACK is sent
Patch 2:
- Make midstream ACK rehash test more reliable by blocking the unused
path first
- Fix port overlap when ECMP_REBUILD_ROUNDS exceeds the default
Changes since v8: https://lore.kernel.org/netdev/[email protected]/
Patch 1:
- Fix REPFLOW flowlabel reflection for syncookie SYN-ACKs: pass 0 as
tw_isn to route_req() so tcp_v6_init_req() saves ireq->pktopts
Patch 2:
- Give midstream and ACK rehash attempt helpers distinct failure
messages (no TX activity vs no data on alternate path vs counter
not incrementing) instead of a single generic error
- Drop unused ns_server parameter from ecmp_dst_rebuild_check()
- Clean up server socat before break on setup failure in the dst
rebuild loop
Changes since v7: https://lore.kernel.org/netdev/[email protected]/
Patch 1:
- Remove #if IS_ENABLED(CONFIG_IPV6) guards around __sk_dst_reset()
in tcp_plb.c and tcp_timer.c (Eric Dumazet)
- Guard mp_hash in inet6_csk_route_socket() on sk_protocol == IPPROTO_TCP instead of txhash != 0, since non-TCP callers like L2TP set sk_txhash
in __ip6_datagram_connect() and should retain flow-key-based ECMP
- Use the syncookie (ISN) as txhash for both the SYN-ACK route lookup
and cookie_v6_check() socket creation, so the server's ECMP selection is consistent across the stateless SYN-ACK and the subsequent full socket. Move cookie_init_sequence() before route_req() in tcp_conn_request()
so the SYN-ACK dst is computed with the cookie-derived txhash; derive txhash from snt_isn in cookie_tcp_reqsk_init() to match
Patch 2:
- Invalidate dst via dummy route add/del instead of route replace to
avoid a transient single-nexthop state during multipath replacement
- Add syncookie server path consistency test verifying the SYN-ACK and post-cookie ACKs use the same ECMP path
- Strengthen policy 1 negative test to wait for multiple rehash attempts
and verify SYNs landed on exactly one interface
Changes since v6: https://lore.kernel.org/netdev/[email protected]/
- Guard mp_hash assignment so that non-TCP callers of inet6_csk_route_socket() fall through to rt6_multipath_hash()
(superseded in v8 by sk_protocol == IPPROTO_TCP guard)
- Initialize txhash in bpf_sk_assign_tcp_reqsk() to avoid reading uninitialized slab memory in inet6_csk_route_req() (reverted in v12
as redundant)
- Check post-rebuild busywait return status to avoid silent false pass
Changes since v5: https://lore.kernel.org/netdev/[email protected]/
- Improve selftest reliability: suppress __dst_negative_advice() via tcp_retries1=255 in dst rebuild tests so a real RTO cannot trigger
an unintended rehash; add internal retry to midstream and ACK
rehash tests to tolerate probabilistic ECMP path selection; fix
midstream baseline capture to account for packets that bypass tc
filters during the prio qdisc's TCQ_F_CAN_BYPASS window
- Increase ECMP_REBUILD_ROUNDS default to 10 for reliable regression detection with 2-way ECMP; replace sleep with busywait
- Use tcp_allowed_congestion_control instead of changing the host's
default congestion control for PLB test (superseded in v14 by route congctl)
- Use (txhash >> 1) ?: 1 to guarantee non-zero mp_hash, since zero
falls back to rt6_multipath_hash()
Changes since v4: https://lore.kernel.org/netdev/[email protected]/
- Condition fl6->mp_hash on fib_multipath_hash_policy == 0 to preserve deterministic hash policies 1-3 (e.g., symmetric 5-tuple for policy 1)
- Set fl6->mp_hash in tcp_v6_connect() and cookie_v6_check() for
initial route lookup consistency; move sk_set_txhash() earlier
(Jakub Kicinski)
- Add policy 1 negative test; improve sysctl save/restore
- Add flowlabel leak test confirming mp_hash does not alter the
on-wire IPv6 flow label
- Add dst rebuild consistency tests (normal and syncookie) verifying
that route table changes do not cause unintended ECMP path changes
Changes since v3: https://lore.kernel.org/netdev/[email protected]/
- Use __sk_dst_reset() instead of sk_dst_reset() since the socket lock
is held in all three call sites (Eric Dumazet)
- Guard __sk_dst_reset() with sk->sk_family == AF_INET6 since IPv4 ECMP
does not use sk_txhash for path selection
- Guard __sk_dst_reset() in tcp_plb_check_rehash() with the return value
of sk_rethink_txhash()
- Move tcp_rsk(req)->txhash initialization before route_req() in tcp_conn_request() to avoid reading uninitialized memory
- Add CONFIG_TCP_CONG_DCTCP=m to selftests/net/config for PLB test
- Skip PLB test gracefully if DCTCP is not available
- Save and restore original congestion control algorithm in PLB test
- Default get_netstat_counter() to 0 when counter is not found
- Skip all tests if tcp_syn_linear_timeouts is not available
- Replace bash/pipe data sources with socat OPEN:/dev/zero for
cleaner process cleanup
- Fix shellcheck warnings
Changes since v2: https://lore.kernel.org/netdev/[email protected]/
- Retitle "ECMP" to "local ECMP" to distinguish from remote ECMP
(Neal Cardwell)
- Add fl6->mp_hash propagation in inet6_sk_rebuild_header() (af_inet6.c), covering the dst rebuild path used on established sockets
- Remove incorrect ir_iif update from tcp_check_req() in tcp_minisocks.c;
the SYN/ACK rehash is already handled by tcp_rtx_synack() re-rolling
txhash which feeds into inet6_csk_route_req()'s mp_hash
(Eric Dumazet)
- Add ACK rehash and PLB rehash selftests
- Improve selftest reliability
Changes since v1: https://lore.kernel.org/netdev/[email protected]/
- Use tcp_rsk(req)->txhash instead of jhash_1word(req->num_retrans, ...)
for ECMP path selection in inet6_csk_route_req(), making the request
socket path consistent with the established socket path (Eric Dumazet)
- Add comments explaining the >> 1 shift for 31-bit mp_hash range
- Use socat -u (unidirectional) in selftest to avoid SIGPIPE race
- Increase tcp_syn_retries and tcp_syn_linear_timeouts to 25 for
better rehash coverage
Neil Spring (2):
tcp: rehash onto different local ECMP path on retransmit timeout
selftests: net: add local ECMP rehash test
Documentation/networking/ip-sysctl.rst | 6 +- include/net/ipv6.h | 12 + include/net/sock.h | 14 + include/net/tcp.h | 20 +- net/ipv4/syncookies.c | 6 +- net/ipv4/tcp_input.c | 17 +- net/ipv4/tcp_plb.c | 2 +- net/ipv4/tcp_timer.c | 2 +- net/ipv6/af_inet6.c | 2 + net/ipv6/inet6_connection_sock.c | 5 + net/ipv6/syncookies.c | 2 + net/ipv6/tcp_ipv6.c | 19 +- tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/config | 2 + tools/testing/selftests/net/ecmp_rehash.sh | 1109 ++++++++++++++++++++ 15 files changed, 1203 insertions(+), 16 deletions(-) create mode 100755 tools/testing/selftests/net/ecmp_rehash.sh
Signature · 1 line
2.53.0-Meta