diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-12-13 19:32:39 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-13 19:32:39 -0800 |
commit | 5781b2356cbecb0b73b06ec8c3897cabdfdd0928 (patch) | |
tree | 7da5613b163aa7a942561aabc0284950583ee314 /net/ipv4/udp.c | |
parent | e1187b3be72be59625e445b186007e6eae27fef1 (diff) | |
download | lwn-5781b2356cbecb0b73b06ec8c3897cabdfdd0928.tar.gz lwn-5781b2356cbecb0b73b06ec8c3897cabdfdd0928.zip |
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>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r-- | net/ipv4/udp.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 1f9534846ca9..f0126fdd7e04 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -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 */ rand = (rand | 1) * (udptable->mask + 1); - for (last = first + udptable->mask + 1; - first != last; - first++) { + last = first + udptable->mask + 1; + do { hslot = udp_hashslot(udptable, net, first); bitmap_zero(bitmap, PORTS_PER_CHAIN); spin_lock_bh(&hslot->lock); @@ -238,7 +237,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum, snum += rand; } while (snum != first); spin_unlock_bh(&hslot->lock); - } + } while (++first != last); goto fail; } else { hslot = udp_hashslot(udptable, net, snum); |