blob: 0906e51d3cfb57d89181200e4fb7954f093fc1b6 [file] [log] [blame]
David Howells87563612016-04-04 14:00:34 +01001/* Local endpoint object management
David Howells17926a72007-04-26 15:48:28 -07002 *
David Howells4f95dd72016-04-04 14:00:35 +01003 * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
David Howells17926a72007-04-26 15:48:28 -07004 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
David Howells87563612016-04-04 14:00:34 +01007 * modify it under the terms of the GNU General Public Licence
David Howells17926a72007-04-26 15:48:28 -07008 * as published by the Free Software Foundation; either version
David Howells87563612016-04-04 14:00:34 +01009 * 2 of the Licence, or (at your option) any later version.
David Howells17926a72007-04-26 15:48:28 -070010 */
11
Joe Perches9b6d5392016-06-02 12:08:52 -070012#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
David Howells17926a72007-04-26 15:48:28 -070014#include <linux/module.h>
15#include <linux/net.h>
16#include <linux/skbuff.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
David Howells44ba0692015-04-01 16:31:26 +010018#include <linux/udp.h>
19#include <linux/ip.h>
David Howells4f95dd72016-04-04 14:00:35 +010020#include <linux/hashtable.h>
David Howells17926a72007-04-26 15:48:28 -070021#include <net/sock.h>
David Howells52719532018-10-04 11:10:51 +010022#include <net/udp.h>
David Howells17926a72007-04-26 15:48:28 -070023#include <net/af_rxrpc.h>
24#include "ar-internal.h"
25
David Howells4f95dd72016-04-04 14:00:35 +010026static void rxrpc_local_processor(struct work_struct *);
27static void rxrpc_local_rcu(struct rcu_head *);
David Howells17926a72007-04-26 15:48:28 -070028
David Howells17926a72007-04-26 15:48:28 -070029/*
David Howells4f95dd72016-04-04 14:00:35 +010030 * Compare a local to an address. Return -ve, 0 or +ve to indicate less than,
31 * same or greater than.
32 *
33 * We explicitly don't compare the RxRPC service ID as we want to reject
34 * conflicting uses by differing services. Further, we don't want to share
35 * addresses with different options (IPv6), so we don't compare those bits
36 * either.
David Howells17926a72007-04-26 15:48:28 -070037 */
David Howells4f95dd72016-04-04 14:00:35 +010038static long rxrpc_local_cmp_key(const struct rxrpc_local *local,
39 const struct sockaddr_rxrpc *srx)
40{
41 long diff;
42
43 diff = ((local->srx.transport_type - srx->transport_type) ?:
44 (local->srx.transport_len - srx->transport_len) ?:
45 (local->srx.transport.family - srx->transport.family));
46 if (diff != 0)
47 return diff;
48
49 switch (srx->transport.family) {
50 case AF_INET:
51 /* If the choice of UDP port is left up to the transport, then
52 * the endpoint record doesn't match.
53 */
54 return ((u16 __force)local->srx.transport.sin.sin_port -
55 (u16 __force)srx->transport.sin.sin_port) ?:
56 memcmp(&local->srx.transport.sin.sin_addr,
57 &srx->transport.sin.sin_addr,
58 sizeof(struct in_addr));
David Howellsd1912742016-09-17 07:26:01 +010059#ifdef CONFIG_AF_RXRPC_IPV6
David Howells75b54cb2016-09-13 08:49:05 +010060 case AF_INET6:
61 /* If the choice of UDP6 port is left up to the transport, then
62 * the endpoint record doesn't match.
63 */
64 return ((u16 __force)local->srx.transport.sin6.sin6_port -
65 (u16 __force)srx->transport.sin6.sin6_port) ?:
66 memcmp(&local->srx.transport.sin6.sin6_addr,
67 &srx->transport.sin6.sin6_addr,
68 sizeof(struct in6_addr));
David Howellsd1912742016-09-17 07:26:01 +010069#endif
David Howells4f95dd72016-04-04 14:00:35 +010070 default:
71 BUG();
72 }
73}
74
75/*
76 * Allocate a new local endpoint.
77 */
David Howells2baec2c2017-05-24 17:02:32 +010078static struct rxrpc_local *rxrpc_alloc_local(struct rxrpc_net *rxnet,
79 const struct sockaddr_rxrpc *srx)
David Howells17926a72007-04-26 15:48:28 -070080{
81 struct rxrpc_local *local;
82
83 local = kzalloc(sizeof(struct rxrpc_local), GFP_KERNEL);
84 if (local) {
David Howells4f95dd72016-04-04 14:00:35 +010085 atomic_set(&local->usage, 1);
David Howells2baec2c2017-05-24 17:02:32 +010086 local->rxnet = rxnet;
David Howells17926a72007-04-26 15:48:28 -070087 INIT_LIST_HEAD(&local->link);
David Howells4f95dd72016-04-04 14:00:35 +010088 INIT_WORK(&local->processor, rxrpc_local_processor);
David Howells17926a72007-04-26 15:48:28 -070089 init_rwsem(&local->defrag_sem);
David Howells17926a72007-04-26 15:48:28 -070090 skb_queue_head_init(&local->reject_queue);
David Howells44ba0692015-04-01 16:31:26 +010091 skb_queue_head_init(&local->event_queue);
David Howells999b69f2016-06-17 15:42:35 +010092 local->client_conns = RB_ROOT;
93 spin_lock_init(&local->client_conns_lock);
David Howells17926a72007-04-26 15:48:28 -070094 spin_lock_init(&local->lock);
95 rwlock_init(&local->services_lock);
David Howells17926a72007-04-26 15:48:28 -070096 local->debug_id = atomic_inc_return(&rxrpc_debug_id);
97 memcpy(&local->srx, srx, sizeof(*srx));
David Howells28036f42017-06-05 14:30:49 +010098 local->srx.srx_service = 0;
David Howells09d2bf52018-03-30 21:05:28 +010099 trace_rxrpc_local(local, rxrpc_local_new, 1, NULL);
David Howells17926a72007-04-26 15:48:28 -0700100 }
101
102 _leave(" = %p", local);
103 return local;
104}
105
106/*
107 * create the local socket
David Howells4f95dd72016-04-04 14:00:35 +0100108 * - must be called with rxrpc_local_mutex locked
David Howells17926a72007-04-26 15:48:28 -0700109 */
David Howells2baec2c2017-05-24 17:02:32 +0100110static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
David Howells17926a72007-04-26 15:48:28 -0700111{
David Howells52719532018-10-04 11:10:51 +0100112 struct sock *usk;
David Howells17926a72007-04-26 15:48:28 -0700113 int ret, opt;
114
David Howells75b54cb2016-09-13 08:49:05 +0100115 _enter("%p{%d,%d}",
116 local, local->srx.transport_type, local->srx.transport.family);
David Howells17926a72007-04-26 15:48:28 -0700117
118 /* create a socket to represent the local endpoint */
David Howells2baec2c2017-05-24 17:02:32 +0100119 ret = sock_create_kern(net, local->srx.transport.family,
David Howellsaaa31cb2016-09-13 08:49:05 +0100120 local->srx.transport_type, 0, &local->socket);
David Howells17926a72007-04-26 15:48:28 -0700121 if (ret < 0) {
122 _leave(" = %d [socket]", ret);
123 return ret;
124 }
125
David Howells2cfa2272018-10-05 14:05:35 +0100126 /* set the socket up */
David Howells52719532018-10-04 11:10:51 +0100127 usk = local->socket->sk;
128 inet_sk(usk)->mc_loop = 0;
129
130 /* Enable CHECKSUM_UNNECESSARY to CHECKSUM_COMPLETE conversion */
131 inet_inc_convert_csum(usk);
132
133 rcu_assign_sk_user_data(usk, local);
134
135 udp_sk(usk)->encap_type = UDP_ENCAP_RXRPC;
136 udp_sk(usk)->encap_rcv = rxrpc_input_packet;
137 udp_sk(usk)->encap_destroy = NULL;
138 udp_sk(usk)->gro_receive = NULL;
139 udp_sk(usk)->gro_complete = NULL;
140
141 udp_encap_enable();
David Howells7ec8dc92018-10-12 16:38:36 +0100142#if IS_ENABLED(CONFIG_AF_RXRPC_IPV6)
David Howells52719532018-10-04 11:10:51 +0100143 if (local->srx.transport.family == AF_INET6)
144 udpv6_encap_enable();
145#endif
146 usk->sk_error_report = rxrpc_error_report;
David Howells2cfa2272018-10-05 14:05:35 +0100147
David Howells17926a72007-04-26 15:48:28 -0700148 /* if a local address was supplied then bind it */
149 if (local->srx.transport_len > sizeof(sa_family_t)) {
150 _debug("bind");
151 ret = kernel_bind(local->socket,
David Howells4f95dd72016-04-04 14:00:35 +0100152 (struct sockaddr *)&local->srx.transport,
David Howells17926a72007-04-26 15:48:28 -0700153 local->srx.transport_len);
154 if (ret < 0) {
David Howells4f95dd72016-04-04 14:00:35 +0100155 _debug("bind failed %d", ret);
David Howells17926a72007-04-26 15:48:28 -0700156 goto error;
157 }
158 }
159
David Howellsf2aeed32018-05-10 23:26:00 +0100160 switch (local->srx.transport.family) {
David Howells37a675e2018-09-27 15:13:09 +0100161 case AF_INET6:
162 /* we want to receive ICMPv6 errors */
163 opt = 1;
164 ret = kernel_setsockopt(local->socket, SOL_IPV6, IPV6_RECVERR,
165 (char *) &opt, sizeof(opt));
166 if (ret < 0) {
167 _debug("setsockopt failed");
168 goto error;
169 }
170
171 /* we want to set the don't fragment bit */
172 opt = IPV6_PMTUDISC_DO;
173 ret = kernel_setsockopt(local->socket, SOL_IPV6, IPV6_MTU_DISCOVER,
174 (char *) &opt, sizeof(opt));
175 if (ret < 0) {
176 _debug("setsockopt failed");
177 goto error;
178 }
179
180 /* Fall through and set IPv4 options too otherwise we don't get
181 * errors from IPv4 packets sent through the IPv6 socket.
182 */
183
David Howellsf2aeed32018-05-10 23:26:00 +0100184 case AF_INET:
185 /* we want to receive ICMP errors */
186 opt = 1;
187 ret = kernel_setsockopt(local->socket, SOL_IP, IP_RECVERR,
188 (char *) &opt, sizeof(opt));
189 if (ret < 0) {
190 _debug("setsockopt failed");
191 goto error;
192 }
David Howells17926a72007-04-26 15:48:28 -0700193
David Howellsf2aeed32018-05-10 23:26:00 +0100194 /* we want to set the don't fragment bit */
195 opt = IP_PMTUDISC_DO;
196 ret = kernel_setsockopt(local->socket, SOL_IP, IP_MTU_DISCOVER,
197 (char *) &opt, sizeof(opt));
198 if (ret < 0) {
199 _debug("setsockopt failed");
200 goto error;
201 }
David Howellsb604dd92018-09-27 15:13:08 +0100202
203 /* We want receive timestamps. */
204 opt = 1;
205 ret = kernel_setsockopt(local->socket, SOL_SOCKET, SO_TIMESTAMPNS,
206 (char *)&opt, sizeof(opt));
207 if (ret < 0) {
208 _debug("setsockopt failed");
209 goto error;
210 }
David Howellsf2aeed32018-05-10 23:26:00 +0100211 break;
212
213 default:
214 BUG();
David Howells17926a72007-04-26 15:48:28 -0700215 }
216
David Howells17926a72007-04-26 15:48:28 -0700217 _leave(" = 0");
218 return 0;
219
220error:
Trond Myklebust91cf45f2007-11-12 18:10:39 -0800221 kernel_sock_shutdown(local->socket, SHUT_RDWR);
David Howells17926a72007-04-26 15:48:28 -0700222 local->socket->sk->sk_user_data = NULL;
223 sock_release(local->socket);
224 local->socket = NULL;
225
226 _leave(" = %d", ret);
227 return ret;
228}
229
230/*
David Howells4f95dd72016-04-04 14:00:35 +0100231 * Look up or create a new local endpoint using the specified local address.
David Howells17926a72007-04-26 15:48:28 -0700232 */
David Howells2baec2c2017-05-24 17:02:32 +0100233struct rxrpc_local *rxrpc_lookup_local(struct net *net,
234 const struct sockaddr_rxrpc *srx)
David Howells17926a72007-04-26 15:48:28 -0700235{
236 struct rxrpc_local *local;
David Howells2baec2c2017-05-24 17:02:32 +0100237 struct rxrpc_net *rxnet = rxrpc_net(net);
David Howells4f95dd72016-04-04 14:00:35 +0100238 struct list_head *cursor;
239 const char *age;
240 long diff;
David Howells17926a72007-04-26 15:48:28 -0700241 int ret;
242
David Howells75b54cb2016-09-13 08:49:05 +0100243 _enter("{%d,%d,%pISp}",
244 srx->transport_type, srx->transport.family, &srx->transport);
David Howells17926a72007-04-26 15:48:28 -0700245
David Howells2baec2c2017-05-24 17:02:32 +0100246 mutex_lock(&rxnet->local_mutex);
David Howells17926a72007-04-26 15:48:28 -0700247
David Howells2baec2c2017-05-24 17:02:32 +0100248 for (cursor = rxnet->local_endpoints.next;
249 cursor != &rxnet->local_endpoints;
David Howells4f95dd72016-04-04 14:00:35 +0100250 cursor = cursor->next) {
251 local = list_entry(cursor, struct rxrpc_local, link);
David Howells17926a72007-04-26 15:48:28 -0700252
David Howells4f95dd72016-04-04 14:00:35 +0100253 diff = rxrpc_local_cmp_key(local, srx);
254 if (diff < 0)
David Howells17926a72007-04-26 15:48:28 -0700255 continue;
David Howells4f95dd72016-04-04 14:00:35 +0100256 if (diff > 0)
257 break;
David Howells17926a72007-04-26 15:48:28 -0700258
David Howells4f95dd72016-04-04 14:00:35 +0100259 /* Services aren't allowed to share transport sockets, so
260 * reject that here. It is possible that the object is dying -
261 * but it may also still have the local transport address that
262 * we want bound.
263 */
264 if (srx->srx_service) {
265 local = NULL;
266 goto addr_in_use;
David Howells17926a72007-04-26 15:48:28 -0700267 }
David Howells4f95dd72016-04-04 14:00:35 +0100268
269 /* Found a match. We replace a dying object. Attempting to
270 * bind the transport socket may still fail if we're attempting
271 * to use a local address that the dying object is still using.
272 */
David Howells5627cc82016-04-04 14:00:38 +0100273 if (!rxrpc_get_local_maybe(local)) {
David Howells4f95dd72016-04-04 14:00:35 +0100274 cursor = cursor->next;
275 list_del_init(&local->link);
276 break;
277 }
278
279 age = "old";
280 goto found;
David Howells17926a72007-04-26 15:48:28 -0700281 }
282
David Howells2baec2c2017-05-24 17:02:32 +0100283 local = rxrpc_alloc_local(rxnet, srx);
David Howells4f95dd72016-04-04 14:00:35 +0100284 if (!local)
285 goto nomem;
David Howells17926a72007-04-26 15:48:28 -0700286
David Howells2baec2c2017-05-24 17:02:32 +0100287 ret = rxrpc_open_socket(local, net);
David Howells4f95dd72016-04-04 14:00:35 +0100288 if (ret < 0)
289 goto sock_error;
David Howells17926a72007-04-26 15:48:28 -0700290
David Howells4f95dd72016-04-04 14:00:35 +0100291 list_add_tail(&local->link, cursor);
292 age = "new";
David Howells17926a72007-04-26 15:48:28 -0700293
David Howells4f95dd72016-04-04 14:00:35 +0100294found:
David Howells2baec2c2017-05-24 17:02:32 +0100295 mutex_unlock(&rxnet->local_mutex);
David Howells4f95dd72016-04-04 14:00:35 +0100296
David Howells75b54cb2016-09-13 08:49:05 +0100297 _net("LOCAL %s %d {%pISp}",
298 age, local->debug_id, &local->srx.transport);
David Howells17926a72007-04-26 15:48:28 -0700299
David Howells4f95dd72016-04-04 14:00:35 +0100300 _leave(" = %p", local);
David Howells17926a72007-04-26 15:48:28 -0700301 return local;
302
David Howells4f95dd72016-04-04 14:00:35 +0100303nomem:
304 ret = -ENOMEM;
305sock_error:
David Howells2baec2c2017-05-24 17:02:32 +0100306 mutex_unlock(&rxnet->local_mutex);
David Howells4f95dd72016-04-04 14:00:35 +0100307 kfree(local);
308 _leave(" = %d", ret);
309 return ERR_PTR(ret);
David Howells17926a72007-04-26 15:48:28 -0700310
David Howells4f95dd72016-04-04 14:00:35 +0100311addr_in_use:
David Howells2baec2c2017-05-24 17:02:32 +0100312 mutex_unlock(&rxnet->local_mutex);
David Howells4f95dd72016-04-04 14:00:35 +0100313 _leave(" = -EADDRINUSE");
314 return ERR_PTR(-EADDRINUSE);
David Howells17926a72007-04-26 15:48:28 -0700315}
316
317/*
David Howells09d2bf52018-03-30 21:05:28 +0100318 * Get a ref on a local endpoint.
319 */
320struct rxrpc_local *rxrpc_get_local(struct rxrpc_local *local)
321{
322 const void *here = __builtin_return_address(0);
323 int n;
324
325 n = atomic_inc_return(&local->usage);
326 trace_rxrpc_local(local, rxrpc_local_got, n, here);
327 return local;
328}
329
330/*
331 * Get a ref on a local endpoint unless its usage has already reached 0.
332 */
333struct rxrpc_local *rxrpc_get_local_maybe(struct rxrpc_local *local)
334{
335 const void *here = __builtin_return_address(0);
336
337 if (local) {
Mark Rutlandbfc18e32018-06-21 13:13:04 +0100338 int n = atomic_fetch_add_unless(&local->usage, 1, 0);
David Howells09d2bf52018-03-30 21:05:28 +0100339 if (n > 0)
340 trace_rxrpc_local(local, rxrpc_local_got, n + 1, here);
341 else
342 local = NULL;
343 }
344 return local;
345}
346
347/*
348 * Queue a local endpoint.
349 */
350void rxrpc_queue_local(struct rxrpc_local *local)
351{
352 const void *here = __builtin_return_address(0);
353
354 if (rxrpc_queue_work(&local->processor))
355 trace_rxrpc_local(local, rxrpc_local_queued,
356 atomic_read(&local->usage), here);
357}
358
359/*
David Howells4f95dd72016-04-04 14:00:35 +0100360 * A local endpoint reached its end of life.
David Howells17926a72007-04-26 15:48:28 -0700361 */
David Howells09d2bf52018-03-30 21:05:28 +0100362static void __rxrpc_put_local(struct rxrpc_local *local)
David Howells17926a72007-04-26 15:48:28 -0700363{
David Howells4f95dd72016-04-04 14:00:35 +0100364 _enter("%d", local->debug_id);
365 rxrpc_queue_work(&local->processor);
David Howells17926a72007-04-26 15:48:28 -0700366}
367
368/*
David Howells09d2bf52018-03-30 21:05:28 +0100369 * Drop a ref on a local endpoint.
370 */
371void rxrpc_put_local(struct rxrpc_local *local)
372{
373 const void *here = __builtin_return_address(0);
374 int n;
375
376 if (local) {
377 n = atomic_dec_return(&local->usage);
378 trace_rxrpc_local(local, rxrpc_local_put, n, here);
379
380 if (n == 0)
381 __rxrpc_put_local(local);
382 }
383}
384
385/*
David Howells4f95dd72016-04-04 14:00:35 +0100386 * Destroy a local endpoint's socket and then hand the record to RCU to dispose
387 * of.
388 *
389 * Closing the socket cannot be done from bottom half context or RCU callback
390 * context because it might sleep.
David Howells17926a72007-04-26 15:48:28 -0700391 */
David Howells4f95dd72016-04-04 14:00:35 +0100392static void rxrpc_local_destroyer(struct rxrpc_local *local)
David Howells17926a72007-04-26 15:48:28 -0700393{
David Howells4f95dd72016-04-04 14:00:35 +0100394 struct socket *socket = local->socket;
David Howells2baec2c2017-05-24 17:02:32 +0100395 struct rxrpc_net *rxnet = local->rxnet;
David Howells17926a72007-04-26 15:48:28 -0700396
David Howells4f95dd72016-04-04 14:00:35 +0100397 _enter("%d", local->debug_id);
David Howells17926a72007-04-26 15:48:28 -0700398
David Howells4f95dd72016-04-04 14:00:35 +0100399 /* We can get a race between an incoming call packet queueing the
400 * processor again and the work processor starting the destruction
401 * process which will shut down the UDP socket.
402 */
403 if (local->dead) {
404 _leave(" [already dead]");
David Howells17926a72007-04-26 15:48:28 -0700405 return;
406 }
David Howells4f95dd72016-04-04 14:00:35 +0100407 local->dead = true;
David Howells17926a72007-04-26 15:48:28 -0700408
David Howells2baec2c2017-05-24 17:02:32 +0100409 mutex_lock(&rxnet->local_mutex);
David Howells4f95dd72016-04-04 14:00:35 +0100410 list_del_init(&local->link);
David Howells2baec2c2017-05-24 17:02:32 +0100411 mutex_unlock(&rxnet->local_mutex);
David Howells17926a72007-04-26 15:48:28 -0700412
David Howells999b69f2016-06-17 15:42:35 +0100413 ASSERT(RB_EMPTY_ROOT(&local->client_conns));
David Howells1e9e5c92016-09-29 22:37:15 +0100414 ASSERT(!local->service);
David Howells17926a72007-04-26 15:48:28 -0700415
David Howells4f95dd72016-04-04 14:00:35 +0100416 if (socket) {
417 local->socket = NULL;
418 kernel_sock_shutdown(socket, SHUT_RDWR);
419 socket->sk->sk_user_data = NULL;
420 sock_release(socket);
421 }
422
423 /* At this point, there should be no more packets coming in to the
424 * local endpoint.
425 */
David Howells17926a72007-04-26 15:48:28 -0700426 rxrpc_purge_queue(&local->reject_queue);
David Howells44ba0692015-04-01 16:31:26 +0100427 rxrpc_purge_queue(&local->event_queue);
David Howells17926a72007-04-26 15:48:28 -0700428
David Howells4f95dd72016-04-04 14:00:35 +0100429 _debug("rcu local %d", local->debug_id);
430 call_rcu(&local->rcu, rxrpc_local_rcu);
431}
432
433/*
434 * Process events on an endpoint
435 */
436static void rxrpc_local_processor(struct work_struct *work)
437{
438 struct rxrpc_local *local =
439 container_of(work, struct rxrpc_local, processor);
440 bool again;
441
David Howells09d2bf52018-03-30 21:05:28 +0100442 trace_rxrpc_local(local, rxrpc_local_processing,
443 atomic_read(&local->usage), NULL);
David Howells4f95dd72016-04-04 14:00:35 +0100444
445 do {
446 again = false;
447 if (atomic_read(&local->usage) == 0)
448 return rxrpc_local_destroyer(local);
449
David Howells4f95dd72016-04-04 14:00:35 +0100450 if (!skb_queue_empty(&local->reject_queue)) {
451 rxrpc_reject_packets(local);
452 again = true;
453 }
454
455 if (!skb_queue_empty(&local->event_queue)) {
456 rxrpc_process_local_events(local);
457 again = true;
458 }
459 } while (again);
460}
461
462/*
463 * Destroy a local endpoint after the RCU grace period expires.
464 */
465static void rxrpc_local_rcu(struct rcu_head *rcu)
466{
467 struct rxrpc_local *local = container_of(rcu, struct rxrpc_local, rcu);
468
469 _enter("%d", local->debug_id);
470
471 ASSERT(!work_pending(&local->processor));
David Howells17926a72007-04-26 15:48:28 -0700472
473 _net("DESTROY LOCAL %d", local->debug_id);
474 kfree(local);
David Howells17926a72007-04-26 15:48:28 -0700475 _leave("");
476}
477
478/*
David Howells4f95dd72016-04-04 14:00:35 +0100479 * Verify the local endpoint list is empty by this point.
David Howells17926a72007-04-26 15:48:28 -0700480 */
David Howells2baec2c2017-05-24 17:02:32 +0100481void rxrpc_destroy_all_locals(struct rxrpc_net *rxnet)
David Howells17926a72007-04-26 15:48:28 -0700482{
David Howells4f95dd72016-04-04 14:00:35 +0100483 struct rxrpc_local *local;
David Howells17926a72007-04-26 15:48:28 -0700484
485 _enter("");
486
David Howellsdee46362016-06-27 17:11:19 +0100487 flush_workqueue(rxrpc_workqueue);
David Howells17926a72007-04-26 15:48:28 -0700488
David Howells2baec2c2017-05-24 17:02:32 +0100489 if (!list_empty(&rxnet->local_endpoints)) {
490 mutex_lock(&rxnet->local_mutex);
491 list_for_each_entry(local, &rxnet->local_endpoints, link) {
David Howellsdee46362016-06-27 17:11:19 +0100492 pr_err("AF_RXRPC: Leaked local %p {%d}\n",
493 local, atomic_read(&local->usage));
494 }
David Howells2baec2c2017-05-24 17:02:32 +0100495 mutex_unlock(&rxnet->local_mutex);
David Howellsdee46362016-06-27 17:11:19 +0100496 BUG();
David Howells17926a72007-04-26 15:48:28 -0700497 }
David Howells17926a72007-04-26 15:48:28 -0700498}