mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
udp: udp_lib_get_port() fix
Now we can have a large udp hash table, udp_lib_get_port() loop should be converted to a do {} while (cond) form, or we dont enter it at all if hash table size is exactly 65536. Reported-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e1187b3be7
commit
5781b2356c
1 changed files with 3 additions and 4 deletions
|
@ -216,9 +216,8 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
|
||||||
* force rand to be an odd multiple of UDP_HTABLE_SIZE
|
* force rand to be an odd multiple of UDP_HTABLE_SIZE
|
||||||
*/
|
*/
|
||||||
rand = (rand | 1) * (udptable->mask + 1);
|
rand = (rand | 1) * (udptable->mask + 1);
|
||||||
for (last = first + udptable->mask + 1;
|
last = first + udptable->mask + 1;
|
||||||
first != last;
|
do {
|
||||||
first++) {
|
|
||||||
hslot = udp_hashslot(udptable, net, first);
|
hslot = udp_hashslot(udptable, net, first);
|
||||||
bitmap_zero(bitmap, PORTS_PER_CHAIN);
|
bitmap_zero(bitmap, PORTS_PER_CHAIN);
|
||||||
spin_lock_bh(&hslot->lock);
|
spin_lock_bh(&hslot->lock);
|
||||||
|
@ -238,7 +237,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
|
||||||
snum += rand;
|
snum += rand;
|
||||||
} while (snum != first);
|
} while (snum != first);
|
||||||
spin_unlock_bh(&hslot->lock);
|
spin_unlock_bh(&hslot->lock);
|
||||||
}
|
} while (++first != last);
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
hslot = udp_hashslot(udptable, net, snum);
|
hslot = udp_hashslot(udptable, net, snum);
|
||||||
|
|
Loading…
Reference in a new issue