@@ -82,7 +82,7 @@ static struct rxrpc_local *rxrpc_alloc_local(struct rxrpc_net *rxnet,
8282 atomic_set (& local -> usage , 1 );
8383 atomic_set (& local -> active_users , 1 );
8484 local -> rxnet = rxnet ;
85- INIT_LIST_HEAD (& local -> link );
85+ INIT_HLIST_NODE (& local -> link );
8686 INIT_WORK (& local -> processor , rxrpc_local_processor );
8787 init_rwsem (& local -> defrag_sem );
8888 skb_queue_head_init (& local -> reject_queue );
@@ -180,7 +180,7 @@ struct rxrpc_local *rxrpc_lookup_local(struct net *net,
180180{
181181 struct rxrpc_local * local ;
182182 struct rxrpc_net * rxnet = rxrpc_net (net );
183- struct list_head * cursor ;
183+ struct hlist_node * cursor ;
184184 const char * age ;
185185 long diff ;
186186 int ret ;
@@ -190,16 +190,12 @@ struct rxrpc_local *rxrpc_lookup_local(struct net *net,
190190
191191 mutex_lock (& rxnet -> local_mutex );
192192
193- for (cursor = rxnet -> local_endpoints .next ;
194- cursor != & rxnet -> local_endpoints ;
195- cursor = cursor -> next ) {
196- local = list_entry (cursor , struct rxrpc_local , link );
193+ hlist_for_each (cursor , & rxnet -> local_endpoints ) {
194+ local = hlist_entry (cursor , struct rxrpc_local , link );
197195
198196 diff = rxrpc_local_cmp_key (local , srx );
199- if (diff < 0 )
197+ if (diff != 0 )
200198 continue ;
201- if (diff > 0 )
202- break ;
203199
204200 /* Services aren't allowed to share transport sockets, so
205201 * reject that here. It is possible that the object is dying -
@@ -211,9 +207,10 @@ struct rxrpc_local *rxrpc_lookup_local(struct net *net,
211207 goto addr_in_use ;
212208 }
213209
214- /* Found a match. We replace a dying object. Attempting to
215- * bind the transport socket may still fail if we're attempting
216- * to use a local address that the dying object is still using.
210+ /* Found a match. We want to replace a dying object.
211+ * Attempting to bind the transport socket may still fail if
212+ * we're attempting to use a local address that the dying
213+ * object is still using.
217214 */
218215 if (!rxrpc_use_local (local ))
219216 break ;
@@ -230,10 +227,12 @@ struct rxrpc_local *rxrpc_lookup_local(struct net *net,
230227 if (ret < 0 )
231228 goto sock_error ;
232229
233- if (cursor != & rxnet -> local_endpoints )
234- list_replace_init (cursor , & local -> link );
235- else
236- list_add_tail (& local -> link , cursor );
230+ if (cursor ) {
231+ hlist_replace_rcu (cursor , & local -> link );
232+ cursor -> pprev = NULL ;
233+ } else {
234+ hlist_add_head_rcu (& local -> link , & rxnet -> local_endpoints );
235+ }
237236 age = "new" ;
238237
239238found :
@@ -374,7 +373,7 @@ static void rxrpc_local_destroyer(struct rxrpc_local *local)
374373 local -> dead = true;
375374
376375 mutex_lock (& rxnet -> local_mutex );
377- list_del_init (& local -> link );
376+ hlist_del_init_rcu (& local -> link );
378377 mutex_unlock (& rxnet -> local_mutex );
379378
380379 rxrpc_clean_up_local_conns (local );
@@ -458,9 +457,9 @@ void rxrpc_destroy_all_locals(struct rxrpc_net *rxnet)
458457
459458 flush_workqueue (rxrpc_workqueue );
460459
461- if (!list_empty (& rxnet -> local_endpoints )) {
460+ if (!hlist_empty (& rxnet -> local_endpoints )) {
462461 mutex_lock (& rxnet -> local_mutex );
463- list_for_each_entry (local , & rxnet -> local_endpoints , link ) {
462+ hlist_for_each_entry (local , & rxnet -> local_endpoints , link ) {
464463 pr_err ("AF_RXRPC: Leaked local %p {%d}\n" ,
465464 local , atomic_read (& local -> usage ));
466465 }
0 commit comments