diff options
author | David Miller <davem@davemloft.net> | 2006-12-22 11:56:21 -0800 |
---|---|---|
committer | Chris Wright <chrisw@sous-sol.org> | 2007-01-10 11:05:20 -0800 |
commit | 3629bc276335cfc6650c6b7119ea8b1e2518ec6c (patch) | |
tree | 4fd81ef539abb342c1fe12644500de9cc3aa6f12 /net | |
parent | 31ce2d6a3a9a9164cb535d64f7ce2eb2e3f1debe (diff) |
[PATCH] UDP: Fix reversed logic in udp_get_port()
When this code was converted to use sk_for_each() the
logic for the "best hash chain length" code was reversed,
breaking everything.
The original code was of the form:
size = 0;
do {
if (++size >= best_size_so_far)
goto next;
} while ((sk = sk->next) != NULL);
best_size_so_far = size;
best = result;
next:;
and this got converted into:
sk_for_each(sk2, node, head)
if (++size < best_size_so_far) {
best_size_so_far = size;
best = result;
}
Which does something very very different from the original.
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/udp.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 9e1bd374875..404dd214796 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -167,11 +167,14 @@ int udp_get_port(struct sock *sk, unsigned short snum, goto gotit; } size = 0; - sk_for_each(sk2, node, head) - if (++size < best_size_so_far) { - best_size_so_far = size; - best = result; - } + sk_for_each(sk2, node, head) { + if (++size >= best_size_so_far) + goto next; + } + best_size_so_far = size; + best = result; + next: + ; } result = best; for(i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) { |