|
@@ -237,12 +237,14 @@ struct sock *__inet_lookup_established(struct net *net,
|
|
rcu_read_lock();
|
|
rcu_read_lock();
|
|
begin:
|
|
begin:
|
|
sk_nulls_for_each_rcu(sk, node, &head->chain) {
|
|
sk_nulls_for_each_rcu(sk, node, &head->chain) {
|
|
- if (INET_MATCH(sk, net, hash, acookie,
|
|
|
|
- saddr, daddr, ports, dif)) {
|
|
|
|
|
|
+ if (sk->sk_hash != hash)
|
|
|
|
+ continue;
|
|
|
|
+ if (likely(INET_MATCH(sk, net, acookie,
|
|
|
|
+ saddr, daddr, ports, dif))) {
|
|
if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt)))
|
|
if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt)))
|
|
goto begintw;
|
|
goto begintw;
|
|
- if (unlikely(!INET_MATCH(sk, net, hash, acookie,
|
|
|
|
- saddr, daddr, ports, dif))) {
|
|
|
|
|
|
+ if (unlikely(!INET_MATCH(sk, net, acookie,
|
|
|
|
+ saddr, daddr, ports, dif))) {
|
|
sock_put(sk);
|
|
sock_put(sk);
|
|
goto begin;
|
|
goto begin;
|
|
}
|
|
}
|
|
@@ -260,14 +262,18 @@ begin:
|
|
begintw:
|
|
begintw:
|
|
/* Must check for a TIME_WAIT'er before going to listener hash. */
|
|
/* Must check for a TIME_WAIT'er before going to listener hash. */
|
|
sk_nulls_for_each_rcu(sk, node, &head->twchain) {
|
|
sk_nulls_for_each_rcu(sk, node, &head->twchain) {
|
|
- if (INET_TW_MATCH(sk, net, hash, acookie,
|
|
|
|
- saddr, daddr, ports, dif)) {
|
|
|
|
|
|
+ if (sk->sk_hash != hash)
|
|
|
|
+ continue;
|
|
|
|
+ if (likely(INET_TW_MATCH(sk, net, acookie,
|
|
|
|
+ saddr, daddr, ports,
|
|
|
|
+ dif))) {
|
|
if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt))) {
|
|
if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt))) {
|
|
sk = NULL;
|
|
sk = NULL;
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
- if (unlikely(!INET_TW_MATCH(sk, net, hash, acookie,
|
|
|
|
- saddr, daddr, ports, dif))) {
|
|
|
|
|
|
+ if (unlikely(!INET_TW_MATCH(sk, net, acookie,
|
|
|
|
+ saddr, daddr, ports,
|
|
|
|
+ dif))) {
|
|
sock_put(sk);
|
|
sock_put(sk);
|
|
goto begintw;
|
|
goto begintw;
|
|
}
|
|
}
|
|
@@ -314,10 +320,12 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
|
|
|
|
|
|
/* Check TIME-WAIT sockets first. */
|
|
/* Check TIME-WAIT sockets first. */
|
|
sk_nulls_for_each(sk2, node, &head->twchain) {
|
|
sk_nulls_for_each(sk2, node, &head->twchain) {
|
|
- tw = inet_twsk(sk2);
|
|
|
|
|
|
+ if (sk2->sk_hash != hash)
|
|
|
|
+ continue;
|
|
|
|
|
|
- if (INET_TW_MATCH(sk2, net, hash, acookie,
|
|
|
|
- saddr, daddr, ports, dif)) {
|
|
|
|
|
|
+ if (likely(INET_TW_MATCH(sk2, net, acookie,
|
|
|
|
+ saddr, daddr, ports, dif))) {
|
|
|
|
+ tw = inet_twsk(sk2);
|
|
if (twsk_unique(sk, sk2, twp))
|
|
if (twsk_unique(sk, sk2, twp))
|
|
goto unique;
|
|
goto unique;
|
|
else
|
|
else
|
|
@@ -328,8 +336,10 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
|
|
|
|
|
|
/* And established part... */
|
|
/* And established part... */
|
|
sk_nulls_for_each(sk2, node, &head->chain) {
|
|
sk_nulls_for_each(sk2, node, &head->chain) {
|
|
- if (INET_MATCH(sk2, net, hash, acookie,
|
|
|
|
- saddr, daddr, ports, dif))
|
|
|
|
|
|
+ if (sk2->sk_hash != hash)
|
|
|
|
+ continue;
|
|
|
|
+ if (likely(INET_MATCH(sk2, net, acookie,
|
|
|
|
+ saddr, daddr, ports, dif)))
|
|
goto not_unique;
|
|
goto not_unique;
|
|
}
|
|
}
|
|
|
|
|