2016-04-04 21:00:34 +08:00
|
|
|
/* Local endpoint object management
|
2007-04-27 06:48:28 +08:00
|
|
|
*
|
2016-04-04 21:00:35 +08:00
|
|
|
* Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
|
2007-04-27 06:48:28 +08:00
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
2016-04-04 21:00:34 +08:00
|
|
|
* modify it under the terms of the GNU General Public Licence
|
2007-04-27 06:48:28 +08:00
|
|
|
* as published by the Free Software Foundation; either version
|
2016-04-04 21:00:34 +08:00
|
|
|
* 2 of the Licence, or (at your option) any later version.
|
2007-04-27 06:48:28 +08:00
|
|
|
*/
|
|
|
|
|
2016-06-03 03:08:52 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2007-04-27 06:48:28 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/net.h>
|
|
|
|
#include <linux/skbuff.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2015-04-01 23:31:26 +08:00
|
|
|
#include <linux/udp.h>
|
|
|
|
#include <linux/ip.h>
|
2016-04-04 21:00:35 +08:00
|
|
|
#include <linux/hashtable.h>
|
2007-04-27 06:48:28 +08:00
|
|
|
#include <net/sock.h>
|
|
|
|
#include <net/af_rxrpc.h>
|
|
|
|
#include "ar-internal.h"
|
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
static void rxrpc_local_processor(struct work_struct *);
|
|
|
|
static void rxrpc_local_rcu(struct rcu_head *);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
|
|
|
/*
|
2016-04-04 21:00:35 +08:00
|
|
|
* Compare a local to an address. Return -ve, 0 or +ve to indicate less than,
|
|
|
|
* same or greater than.
|
|
|
|
*
|
|
|
|
* We explicitly don't compare the RxRPC service ID as we want to reject
|
|
|
|
* conflicting uses by differing services. Further, we don't want to share
|
|
|
|
* addresses with different options (IPv6), so we don't compare those bits
|
|
|
|
* either.
|
2007-04-27 06:48:28 +08:00
|
|
|
*/
|
2016-04-04 21:00:35 +08:00
|
|
|
static long rxrpc_local_cmp_key(const struct rxrpc_local *local,
|
|
|
|
const struct sockaddr_rxrpc *srx)
|
|
|
|
{
|
|
|
|
long diff;
|
|
|
|
|
|
|
|
diff = ((local->srx.transport_type - srx->transport_type) ?:
|
|
|
|
(local->srx.transport_len - srx->transport_len) ?:
|
|
|
|
(local->srx.transport.family - srx->transport.family));
|
|
|
|
if (diff != 0)
|
|
|
|
return diff;
|
|
|
|
|
|
|
|
switch (srx->transport.family) {
|
|
|
|
case AF_INET:
|
|
|
|
/* If the choice of UDP port is left up to the transport, then
|
|
|
|
* the endpoint record doesn't match.
|
|
|
|
*/
|
|
|
|
return ((u16 __force)local->srx.transport.sin.sin_port -
|
|
|
|
(u16 __force)srx->transport.sin.sin_port) ?:
|
|
|
|
memcmp(&local->srx.transport.sin.sin_addr,
|
|
|
|
&srx->transport.sin.sin_addr,
|
|
|
|
sizeof(struct in_addr));
|
2016-09-17 14:26:01 +08:00
|
|
|
#ifdef CONFIG_AF_RXRPC_IPV6
|
2016-09-13 15:49:05 +08:00
|
|
|
case AF_INET6:
|
|
|
|
/* If the choice of UDP6 port is left up to the transport, then
|
|
|
|
* the endpoint record doesn't match.
|
|
|
|
*/
|
|
|
|
return ((u16 __force)local->srx.transport.sin6.sin6_port -
|
|
|
|
(u16 __force)srx->transport.sin6.sin6_port) ?:
|
|
|
|
memcmp(&local->srx.transport.sin6.sin6_addr,
|
|
|
|
&srx->transport.sin6.sin6_addr,
|
|
|
|
sizeof(struct in6_addr));
|
2016-09-17 14:26:01 +08:00
|
|
|
#endif
|
2016-04-04 21:00:35 +08:00
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a new local endpoint.
|
|
|
|
*/
|
2017-05-25 00:02:32 +08:00
|
|
|
static struct rxrpc_local *rxrpc_alloc_local(struct rxrpc_net *rxnet,
|
|
|
|
const struct sockaddr_rxrpc *srx)
|
2007-04-27 06:48:28 +08:00
|
|
|
{
|
|
|
|
struct rxrpc_local *local;
|
|
|
|
|
|
|
|
local = kzalloc(sizeof(struct rxrpc_local), GFP_KERNEL);
|
|
|
|
if (local) {
|
2016-04-04 21:00:35 +08:00
|
|
|
atomic_set(&local->usage, 1);
|
2017-05-25 00:02:32 +08:00
|
|
|
local->rxnet = rxnet;
|
2007-04-27 06:48:28 +08:00
|
|
|
INIT_LIST_HEAD(&local->link);
|
2016-04-04 21:00:35 +08:00
|
|
|
INIT_WORK(&local->processor, rxrpc_local_processor);
|
2007-04-27 06:48:28 +08:00
|
|
|
init_rwsem(&local->defrag_sem);
|
|
|
|
skb_queue_head_init(&local->reject_queue);
|
2015-04-01 23:31:26 +08:00
|
|
|
skb_queue_head_init(&local->event_queue);
|
2016-06-17 22:42:35 +08:00
|
|
|
local->client_conns = RB_ROOT;
|
|
|
|
spin_lock_init(&local->client_conns_lock);
|
2007-04-27 06:48:28 +08:00
|
|
|
spin_lock_init(&local->lock);
|
|
|
|
rwlock_init(&local->services_lock);
|
|
|
|
local->debug_id = atomic_inc_return(&rxrpc_debug_id);
|
|
|
|
memcpy(&local->srx, srx, sizeof(*srx));
|
2017-06-05 21:30:49 +08:00
|
|
|
local->srx.srx_service = 0;
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
_leave(" = %p", local);
|
|
|
|
return local;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* create the local socket
|
2016-04-04 21:00:35 +08:00
|
|
|
* - must be called with rxrpc_local_mutex locked
|
2007-04-27 06:48:28 +08:00
|
|
|
*/
|
2017-05-25 00:02:32 +08:00
|
|
|
static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
|
2007-04-27 06:48:28 +08:00
|
|
|
{
|
|
|
|
struct sock *sock;
|
|
|
|
int ret, opt;
|
|
|
|
|
2016-09-13 15:49:05 +08:00
|
|
|
_enter("%p{%d,%d}",
|
|
|
|
local, local->srx.transport_type, local->srx.transport.family);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
|
|
|
/* create a socket to represent the local endpoint */
|
2017-05-25 00:02:32 +08:00
|
|
|
ret = sock_create_kern(net, local->srx.transport.family,
|
2016-09-13 15:49:05 +08:00
|
|
|
local->srx.transport_type, 0, &local->socket);
|
2007-04-27 06:48:28 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
_leave(" = %d [socket]", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if a local address was supplied then bind it */
|
|
|
|
if (local->srx.transport_len > sizeof(sa_family_t)) {
|
|
|
|
_debug("bind");
|
|
|
|
ret = kernel_bind(local->socket,
|
2016-04-04 21:00:35 +08:00
|
|
|
(struct sockaddr *)&local->srx.transport,
|
2007-04-27 06:48:28 +08:00
|
|
|
local->srx.transport_len);
|
|
|
|
if (ret < 0) {
|
2016-04-04 21:00:35 +08:00
|
|
|
_debug("bind failed %d", ret);
|
2007-04-27 06:48:28 +08:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we want to receive ICMP errors */
|
|
|
|
opt = 1;
|
|
|
|
ret = kernel_setsockopt(local->socket, SOL_IP, IP_RECVERR,
|
|
|
|
(char *) &opt, sizeof(opt));
|
|
|
|
if (ret < 0) {
|
|
|
|
_debug("setsockopt failed");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we want to set the don't fragment bit */
|
|
|
|
opt = IP_PMTUDISC_DO;
|
|
|
|
ret = kernel_setsockopt(local->socket, SOL_IP, IP_MTU_DISCOVER,
|
|
|
|
(char *) &opt, sizeof(opt));
|
|
|
|
if (ret < 0) {
|
|
|
|
_debug("setsockopt failed");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the socket up */
|
|
|
|
sock = local->socket->sk;
|
|
|
|
sock->sk_user_data = local;
|
|
|
|
sock->sk_data_ready = rxrpc_data_ready;
|
2016-04-04 21:00:32 +08:00
|
|
|
sock->sk_error_report = rxrpc_error_report;
|
2007-04-27 06:48:28 +08:00
|
|
|
_leave(" = 0");
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
2007-11-13 10:10:39 +08:00
|
|
|
kernel_sock_shutdown(local->socket, SHUT_RDWR);
|
2007-04-27 06:48:28 +08:00
|
|
|
local->socket->sk->sk_user_data = NULL;
|
|
|
|
sock_release(local->socket);
|
|
|
|
local->socket = NULL;
|
|
|
|
|
|
|
|
_leave(" = %d", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-04-04 21:00:35 +08:00
|
|
|
* Look up or create a new local endpoint using the specified local address.
|
2007-04-27 06:48:28 +08:00
|
|
|
*/
|
2017-05-25 00:02:32 +08:00
|
|
|
struct rxrpc_local *rxrpc_lookup_local(struct net *net,
|
|
|
|
const struct sockaddr_rxrpc *srx)
|
2007-04-27 06:48:28 +08:00
|
|
|
{
|
|
|
|
struct rxrpc_local *local;
|
2017-05-25 00:02:32 +08:00
|
|
|
struct rxrpc_net *rxnet = rxrpc_net(net);
|
2016-04-04 21:00:35 +08:00
|
|
|
struct list_head *cursor;
|
|
|
|
const char *age;
|
|
|
|
long diff;
|
2007-04-27 06:48:28 +08:00
|
|
|
int ret;
|
|
|
|
|
2016-09-13 15:49:05 +08:00
|
|
|
_enter("{%d,%d,%pISp}",
|
|
|
|
srx->transport_type, srx->transport.family, &srx->transport);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2017-05-25 00:02:32 +08:00
|
|
|
mutex_lock(&rxnet->local_mutex);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2017-05-25 00:02:32 +08:00
|
|
|
for (cursor = rxnet->local_endpoints.next;
|
|
|
|
cursor != &rxnet->local_endpoints;
|
2016-04-04 21:00:35 +08:00
|
|
|
cursor = cursor->next) {
|
|
|
|
local = list_entry(cursor, struct rxrpc_local, link);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
diff = rxrpc_local_cmp_key(local, srx);
|
|
|
|
if (diff < 0)
|
2007-04-27 06:48:28 +08:00
|
|
|
continue;
|
2016-04-04 21:00:35 +08:00
|
|
|
if (diff > 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Services aren't allowed to share transport sockets, so
|
|
|
|
* reject that here. It is possible that the object is dying -
|
|
|
|
* but it may also still have the local transport address that
|
|
|
|
* we want bound.
|
|
|
|
*/
|
|
|
|
if (srx->srx_service) {
|
|
|
|
local = NULL;
|
|
|
|
goto addr_in_use;
|
|
|
|
}
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
/* Found a match. We replace a dying object. Attempting to
|
|
|
|
* bind the transport socket may still fail if we're attempting
|
|
|
|
* to use a local address that the dying object is still using.
|
|
|
|
*/
|
2016-04-04 21:00:38 +08:00
|
|
|
if (!rxrpc_get_local_maybe(local)) {
|
2016-04-04 21:00:35 +08:00
|
|
|
cursor = cursor->next;
|
|
|
|
list_del_init(&local->link);
|
|
|
|
break;
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
age = "old";
|
|
|
|
goto found;
|
|
|
|
}
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2017-05-25 00:02:32 +08:00
|
|
|
local = rxrpc_alloc_local(rxnet, srx);
|
2016-04-04 21:00:35 +08:00
|
|
|
if (!local)
|
|
|
|
goto nomem;
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2017-05-25 00:02:32 +08:00
|
|
|
ret = rxrpc_open_socket(local, net);
|
2016-04-04 21:00:35 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto sock_error;
|
|
|
|
|
|
|
|
list_add_tail(&local->link, cursor);
|
|
|
|
age = "new";
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
found:
|
2017-05-25 00:02:32 +08:00
|
|
|
mutex_unlock(&rxnet->local_mutex);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-09-13 15:49:05 +08:00
|
|
|
_net("LOCAL %s %d {%pISp}",
|
|
|
|
age, local->debug_id, &local->srx.transport);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
_leave(" = %p", local);
|
2007-04-27 06:48:28 +08:00
|
|
|
return local;
|
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
nomem:
|
|
|
|
ret = -ENOMEM;
|
|
|
|
sock_error:
|
2017-05-25 00:02:32 +08:00
|
|
|
mutex_unlock(&rxnet->local_mutex);
|
2016-04-04 21:00:35 +08:00
|
|
|
kfree(local);
|
|
|
|
_leave(" = %d", ret);
|
|
|
|
return ERR_PTR(ret);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
addr_in_use:
|
2017-05-25 00:02:32 +08:00
|
|
|
mutex_unlock(&rxnet->local_mutex);
|
2016-04-04 21:00:35 +08:00
|
|
|
_leave(" = -EADDRINUSE");
|
|
|
|
return ERR_PTR(-EADDRINUSE);
|
|
|
|
}
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
/*
|
|
|
|
* A local endpoint reached its end of life.
|
|
|
|
*/
|
|
|
|
void __rxrpc_put_local(struct rxrpc_local *local)
|
|
|
|
{
|
|
|
|
_enter("%d", local->debug_id);
|
|
|
|
rxrpc_queue_work(&local->processor);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-04-04 21:00:35 +08:00
|
|
|
* Destroy a local endpoint's socket and then hand the record to RCU to dispose
|
|
|
|
* of.
|
|
|
|
*
|
|
|
|
* Closing the socket cannot be done from bottom half context or RCU callback
|
|
|
|
* context because it might sleep.
|
2007-04-27 06:48:28 +08:00
|
|
|
*/
|
2016-04-04 21:00:35 +08:00
|
|
|
static void rxrpc_local_destroyer(struct rxrpc_local *local)
|
2007-04-27 06:48:28 +08:00
|
|
|
{
|
2016-04-04 21:00:35 +08:00
|
|
|
struct socket *socket = local->socket;
|
2017-05-25 00:02:32 +08:00
|
|
|
struct rxrpc_net *rxnet = local->rxnet;
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
_enter("%d", local->debug_id);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
/* We can get a race between an incoming call packet queueing the
|
|
|
|
* processor again and the work processor starting the destruction
|
|
|
|
* process which will shut down the UDP socket.
|
|
|
|
*/
|
|
|
|
if (local->dead) {
|
|
|
|
_leave(" [already dead]");
|
|
|
|
return;
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
2016-04-04 21:00:35 +08:00
|
|
|
local->dead = true;
|
|
|
|
|
2017-05-25 00:02:32 +08:00
|
|
|
mutex_lock(&rxnet->local_mutex);
|
2016-04-04 21:00:35 +08:00
|
|
|
list_del_init(&local->link);
|
2017-05-25 00:02:32 +08:00
|
|
|
mutex_unlock(&rxnet->local_mutex);
|
2016-04-04 21:00:35 +08:00
|
|
|
|
2016-06-17 22:42:35 +08:00
|
|
|
ASSERT(RB_EMPTY_ROOT(&local->client_conns));
|
2016-09-30 05:37:15 +08:00
|
|
|
ASSERT(!local->service);
|
2016-04-04 21:00:35 +08:00
|
|
|
|
|
|
|
if (socket) {
|
|
|
|
local->socket = NULL;
|
|
|
|
kernel_sock_shutdown(socket, SHUT_RDWR);
|
|
|
|
socket->sk->sk_user_data = NULL;
|
|
|
|
sock_release(socket);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* At this point, there should be no more packets coming in to the
|
|
|
|
* local endpoint.
|
|
|
|
*/
|
|
|
|
rxrpc_purge_queue(&local->reject_queue);
|
|
|
|
rxrpc_purge_queue(&local->event_queue);
|
|
|
|
|
|
|
|
_debug("rcu local %d", local->debug_id);
|
|
|
|
call_rcu(&local->rcu, rxrpc_local_rcu);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-04-04 21:00:35 +08:00
|
|
|
* Process events on an endpoint
|
2007-04-27 06:48:28 +08:00
|
|
|
*/
|
2016-04-04 21:00:35 +08:00
|
|
|
static void rxrpc_local_processor(struct work_struct *work)
|
2007-04-27 06:48:28 +08:00
|
|
|
{
|
|
|
|
struct rxrpc_local *local =
|
2016-04-04 21:00:35 +08:00
|
|
|
container_of(work, struct rxrpc_local, processor);
|
|
|
|
bool again;
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
_enter("%d", local->debug_id);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
do {
|
|
|
|
again = false;
|
|
|
|
if (atomic_read(&local->usage) == 0)
|
|
|
|
return rxrpc_local_destroyer(local);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
if (!skb_queue_empty(&local->reject_queue)) {
|
|
|
|
rxrpc_reject_packets(local);
|
|
|
|
again = true;
|
|
|
|
}
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
if (!skb_queue_empty(&local->event_queue)) {
|
|
|
|
rxrpc_process_local_events(local);
|
|
|
|
again = true;
|
|
|
|
}
|
|
|
|
} while (again);
|
|
|
|
}
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
/*
|
|
|
|
* Destroy a local endpoint after the RCU grace period expires.
|
|
|
|
*/
|
|
|
|
static void rxrpc_local_rcu(struct rcu_head *rcu)
|
|
|
|
{
|
|
|
|
struct rxrpc_local *local = container_of(rcu, struct rxrpc_local, rcu);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
_enter("%d", local->debug_id);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:35 +08:00
|
|
|
ASSERT(!work_pending(&local->processor));
|
2007-04-27 06:48:28 +08:00
|
|
|
|
|
|
|
_net("DESTROY LOCAL %d", local->debug_id);
|
|
|
|
kfree(local);
|
|
|
|
_leave("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-04-04 21:00:35 +08:00
|
|
|
* Verify the local endpoint list is empty by this point.
|
2007-04-27 06:48:28 +08:00
|
|
|
*/
|
2017-05-25 00:02:32 +08:00
|
|
|
void rxrpc_destroy_all_locals(struct rxrpc_net *rxnet)
|
2007-04-27 06:48:28 +08:00
|
|
|
{
|
2016-04-04 21:00:35 +08:00
|
|
|
struct rxrpc_local *local;
|
2007-04-27 06:48:28 +08:00
|
|
|
|
|
|
|
_enter("");
|
|
|
|
|
2016-06-28 00:11:19 +08:00
|
|
|
flush_workqueue(rxrpc_workqueue);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2017-05-25 00:02:32 +08:00
|
|
|
if (!list_empty(&rxnet->local_endpoints)) {
|
|
|
|
mutex_lock(&rxnet->local_mutex);
|
|
|
|
list_for_each_entry(local, &rxnet->local_endpoints, link) {
|
2016-06-28 00:11:19 +08:00
|
|
|
pr_err("AF_RXRPC: Leaked local %p {%d}\n",
|
|
|
|
local, atomic_read(&local->usage));
|
|
|
|
}
|
2017-05-25 00:02:32 +08:00
|
|
|
mutex_unlock(&rxnet->local_mutex);
|
2016-06-28 00:11:19 +08:00
|
|
|
BUG();
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
}
|