@@ -538,7 +538,8 @@ EXPORT_SYMBOL_GPL(__inet_lookup_established);
538538static int __inet_check_established (struct inet_timewait_death_row * death_row ,
539539 struct sock * sk , __u16 lport ,
540540 struct inet_timewait_sock * * twp ,
541- bool rcu_lookup )
541+ bool rcu_lookup ,
542+ u32 hash )
542543{
543544 struct inet_hashinfo * hinfo = death_row -> hashinfo ;
544545 struct inet_sock * inet = inet_sk (sk );
@@ -549,8 +550,6 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
549550 int sdif = l3mdev_master_ifindex_by_index (net , dif );
550551 INET_ADDR_COOKIE (acookie , saddr , daddr );
551552 const __portpair ports = INET_COMBINED_PORTS (inet -> inet_dport , lport );
552- unsigned int hash = inet_ehashfn (net , daddr , lport ,
553- saddr , inet -> inet_dport );
554553 struct inet_ehash_bucket * head = inet_ehash_bucket (hinfo , hash );
555554 struct inet_timewait_sock * tw = NULL ;
556555 const struct hlist_nulls_node * node ;
@@ -1007,9 +1006,10 @@ static u32 *table_perturb;
10071006
10081007int __inet_hash_connect (struct inet_timewait_death_row * death_row ,
10091008 struct sock * sk , u64 port_offset ,
1009+ u32 hash_port0 ,
10101010 int (* check_established )(struct inet_timewait_death_row * ,
10111011 struct sock * , __u16 , struct inet_timewait_sock * * ,
1012- bool rcu_lookup ))
1012+ bool rcu_lookup , u32 hash ))
10131013{
10141014 struct inet_hashinfo * hinfo = death_row -> hashinfo ;
10151015 struct inet_bind_hashbucket * head , * head2 ;
@@ -1027,7 +1027,8 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
10271027
10281028 if (port ) {
10291029 local_bh_disable ();
1030- ret = check_established (death_row , sk , port , NULL , false);
1030+ ret = check_established (death_row , sk , port , NULL , false,
1031+ hash_port0 + port );
10311032 local_bh_enable ();
10321033 return ret ;
10331034 }
@@ -1071,7 +1072,8 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
10711072 rcu_read_unlock ();
10721073 goto next_port ;
10731074 }
1074- if (!check_established (death_row , sk , port , & tw , true))
1075+ if (!check_established (death_row , sk , port , & tw , true,
1076+ hash_port0 + port ))
10751077 break ;
10761078 rcu_read_unlock ();
10771079 goto next_port ;
@@ -1090,7 +1092,8 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
10901092 goto next_port_unlock ;
10911093 WARN_ON (hlist_empty (& tb -> bhash2 ));
10921094 if (!check_established (death_row , sk ,
1093- port , & tw , false))
1095+ port , & tw , false,
1096+ hash_port0 + port ))
10941097 goto ok ;
10951098 goto next_port_unlock ;
10961099 }
@@ -1197,11 +1200,18 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
11971200int inet_hash_connect (struct inet_timewait_death_row * death_row ,
11981201 struct sock * sk )
11991202{
1203+ const struct inet_sock * inet = inet_sk (sk );
1204+ const struct net * net = sock_net (sk );
12001205 u64 port_offset = 0 ;
1206+ u32 hash_port0 ;
12011207
12021208 if (!inet_sk (sk )-> inet_num )
12031209 port_offset = inet_sk_port_offset (sk );
1204- return __inet_hash_connect (death_row , sk , port_offset ,
1210+
1211+ hash_port0 = inet_ehashfn (net , inet -> inet_rcv_saddr , 0 ,
1212+ inet -> inet_daddr , inet -> inet_dport );
1213+
1214+ return __inet_hash_connect (death_row , sk , port_offset , hash_port0 ,
12051215 __inet_check_established );
12061216}
12071217EXPORT_SYMBOL_GPL (inet_hash_connect );
0 commit comments