Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5c668704b7fa5a4ebf21a490ddfbd6dc2e01fc97
Commit:     5c668704b7fa5a4ebf21a490ddfbd6dc2e01fc97
Parent:     b23e3536667373e44f52a907f63cb55f75969490
Author:     David S. Miller <[EMAIL PROTECTED]>
AuthorDate: Fri Dec 22 11:42:26 2006 -0800
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Fri Dec 22 11:42:26 2006 -0800

    [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 <[EMAIL PROTECTED]>
---
 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 035915f..cfff930 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,
                                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) {
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to