Anton Arapov wrote:
So, now the way suggested by Denis looks reasonable.
What do you think?
If that's the case then you should fix __udp_lib_get_port() the same way.
Prevent division by zero in __udp_lib_get_port() when only one
unsecured port is available.
-Brian
Signed-off-by: Brian Haley <[EMAIL PROTECTED]>
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index ef4d901..61faa38 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -150,10 +150,11 @@ int __udp_lib_get_port(struct sock *sk, unsigned short snum,
int i;
int low = sysctl_local_port_range[0];
int high = sysctl_local_port_range[1];
+ int remaining = (high - low) + 1;
unsigned rover, best, best_size_so_far;
best_size_so_far = UINT_MAX;
- best = rover = net_random() % (high - low) + low;
+ best = rover = net_random() % remaining + low;
/* 1st pass: look for empty (or shortest) hash chain */
for (i = 0; i < UDP_HTABLE_SIZE; i++) {