aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-12-22 14:42:26 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-22 14:42:26 -0500
commit5c668704b7fa5a4ebf21a490ddfbd6dc2e01fc97 (patch)
treea5b4ee5df56025c077646a2b8cbdf5a23c2a1b89 /net
parentb23e3536667373e44f52a907f63cb55f75969490 (diff)
[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>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/udp.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 035915fc9ed3..cfff930f2baf 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -165,11 +165,14 @@ int __udp_lib_get_port(struct sock *sk, unsigned short snum,
165 goto gotit; 165 goto gotit;
166 } 166 }
167 size = 0; 167 size = 0;
168 sk_for_each(sk2, node, head) 168 sk_for_each(sk2, node, head) {
169 if (++size < best_size_so_far) { 169 if (++size >= best_size_so_far)
170 best_size_so_far = size; 170 goto next;
171 best = result; 171 }
172 } 172 best_size_so_far = size;
173 best = result;
174 next:
175 ;
173 } 176 }
174 result = best; 177 result = best;
175 for(i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) { 178 for(i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) {