]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: fix off-by-one in udp_flow_src_port() / psp_write_headers()
authorEric Dumazet <edumazet@google.com>
Mon, 2 Mar 2026 16:39:33 +0000 (16:39 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 5 Mar 2026 00:51:10 +0000 (16:51 -0800)
commitc26b8c4e291c55c7b2138d7bcb27348ca3a5ae59
treedb9a44805f438b49c9272ef9e93e1f665396a375
parent98d95000bb1207f86a0e5876755ac2308ac86d2d
net: fix off-by-one in udp_flow_src_port() / psp_write_headers()

udp_flow_src_port() and psp_write_headers() use ip_local_port_range.

ip_local_port_range is inclusive : all ports between min and max
can be used.

Before this patch, if ip_local_port_range was set to 40000-40001
40001 would not be used as a source port.

Use reciprocal_scale() to help code readability.

Not tagged for stable trees, as this change could break user
expectations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20260302163933.1754393-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/udp.h
net/psp/psp_main.c