ipv6: fix inet6_lookup_listener()
authorEric Dumazet <edumazet@google.com>
Sat, 9 Apr 2016 15:01:13 +0000 (08:01 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 9 Apr 2016 20:53:52 +0000 (16:53 -0400)
A stupid refactoring bug in inet6_lookup_listener() needs to be fixed
in order to get proper SO_REUSEPORT behavior.

Fixes: 3b24d854cb35 ("tcp/dccp: do not touch listener sk_refcnt under synflood")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/inet6_hashtables.c

index 607da088344d6abe778aa458c66bc1e4af90410c..f1678388fb0da410f19df59925b41f504d925af6 100644 (file)
@@ -137,7 +137,7 @@ struct sock *inet6_lookup_listener(struct net *net,
        sk_for_each(sk, &ilb->head) {
                score = compute_score(sk, net, hnum, daddr, dif);
                if (score > hiscore) {
-                       hiscore = score;
+                       reuseport = sk->sk_reuseport;
                        if (reuseport) {
                                phash = inet6_ehashfn(net, daddr, hnum,
                                                      saddr, sport);
@@ -148,7 +148,7 @@ struct sock *inet6_lookup_listener(struct net *net,
                                matches = 1;
                        }
                        result = sk;
-                       reuseport = sk->sk_reuseport;
+                       hiscore = score;
                } else if (score == hiscore && reuseport) {
                        matches++;
                        if (reciprocal_scale(phash, matches) == 0)