summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorFernando Fernandez Mancera <fmancera@suse.de>2026-03-09 05:39:45 +0300
committerJakub Kicinski <kuba@kernel.org>2026-03-11 04:59:39 +0300
commit7da62262ec96a4b345d207b6bcd2ddf5231b7f7d (patch)
tree90ceca3b452b376c2c57496778829de62be18260 /include/linux
parentae95cbaedb754633b9c0d35712a024b16a70962e (diff)
downloadlinux-7da62262ec96a4b345d207b6bcd2ddf5231b7f7d.tar.xz
inet: add ip_local_port_step_width sysctl to improve port usage distribution
With the current port selection algorithm, ports after a reserved port range or long time used port are used more often than others [1]. This causes an uneven port usage distribution. This combines with cloud environments blocking connections between the application server and the database server if there was a previous connection with the same source port, leading to connectivity problems between applications on cloud environments. The real issue here is that these firewalls cannot cope with standards-compliant port reuse. This is a workaround for such situations and an improvement on the distribution of ports selected. The proposed solution is to implement a variant of RFC 6056 Algorithm 5. The step size is selected randomly on every connect() call ensuring it is a coprime with respect to the size of the range of ports we want to scan. This way, we can ensure that all ports within the range are scanned before returning an error. To enable this algorithm, the user must configure the new sysctl option "net.ipv4.ip_local_port_step_width". In addition, on graphs generated we can observe that the distribution of source ports is more even with the proposed approach. [2] [1] https://0xffsoftware.com/port_graph_current_alg.html [2] https://0xffsoftware.com/port_graph_random_step_alg.html Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de> Link: https://patch.msgid.link/20260309023946.5473-2-fmancera@suse.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions