3
0
Fork 0
forked from mirrors/linux
kernel/include
Willem de Bruijn 65e9024643 ip: load balance tcp connections to single dst addr and port
Load balance new TCP connections across nexthops also when they
connect to the same service at a single remote address and port.

This affects only port-based multipath hashing:
fib_multipath_hash_policy 1 or 3.

Local connections must choose both a source address and port when
connecting to a remote service, in ip_route_connect. This
"chicken-and-egg problem" (commit 2d7192d6cb ("ipv4: Sanitize and
simplify ip_route_{connect,newports}()")) is resolved by first
selecting a source address, by looking up a route using the zero
wildcard source port and address.

As a result multiple connections to the same destination address and
port have no entropy in fib_multipath_hash.

This is not a problem when forwarding, as skb-based hashing has a
4-tuple. Nor when establishing UDP connections, as autobind there
selects a port before reaching ip_route_connect.

Load balance also TCP, by using a random port in fib_multipath_hash.
Port assignment in inet_hash_connect is not atomic with
ip_route_connect. Thus ports are unpredictable, effectively random.

Implementation details:

Do not actually pass a random fl4_sport, as that affects not only
hashing, but routing more broadly, and can match a source port based
policy route, which existing wildcard port 0 will not. Instead,
define a new wildcard flowi flag that is used only for hashing.

Selecting a random source is equivalent to just selecting a random
hash entirely. But for code clarity, follow the normal 4-tuple hash
process and only update this field.

fib_multipath_hash can be reached with zero sport from other code
paths, so explicitly pass this flowi flag, rather than trying to infer
this case in the function itself.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20250424143549.669426-3-willemdebruijn.kernel@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2025-04-29 16:22:25 +02:00
..
acpi gcc-15: acpi: sprinkle random '__nonstring' crumbles around 2025-04-20 11:57:54 -07:00
asm-generic RISC-V Patches for the 6.15 Merge Window, Part 1 2025-04-04 09:49:17 -07:00
clocksource
crypto Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-04-17 12:26:50 -07:00
cxl cxl for v6.15 2025-04-02 20:04:43 -07:00
drm Short summary of fixes pull: 2025-04-18 08:38:29 +10:00
dt-bindings Char/Misc/IIO driver updates for 6.15-rc1 2025-04-01 11:26:08 -07:00
hyperv
keys rxrpc: Add YFS RxGK (GSSAPI) security class 2025-04-14 17:36:41 -07:00
kunit kunit: Spelling s/slowm/slow/ 2025-04-08 14:57:24 -06:00
kvm
linux net: ethernet: mtk_wed: annotate RCU release in attach() 2025-04-24 18:22:05 -07:00
math-emu
media
memory
misc
net ip: load balance tcp connections to single dst addr and port 2025-04-29 16:22:25 +02:00
pcmcia
ras
rdma RDMA/mlx5: Fix compilation warning when USER_ACCESS isn't set 2025-04-07 15:14:34 -03:00
rv
scsi
soc
sound soundwire updates for 6.15 2025-04-01 12:43:13 -07:00
target
trace trace: tcp: Add const qualifier to skb parameter in tcp_probe event 2025-04-17 19:04:43 -07:00
uapi tcp: fastopen: pass TFO child indication through getsockopt 2025-04-24 18:21:04 -07:00
ufs scsi: ufs: core: Add device level exception support 2025-04-03 10:54:31 -04:00
vdso vdso: Address variable shadowing in macros 2025-04-10 11:07:10 +02:00
video
xen
Kbuild