2007-04-27 06:48:28 +08:00
|
|
|
/* RxRPC individual remote procedure call handling
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2016-06-03 03:08:52 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
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>
|
2007-04-27 06:48:28 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/circ_buf.h>
|
2014-03-04 07:04:45 +08:00
|
|
|
#include <linux/hashtable.h>
|
|
|
|
#include <linux/spinlock_types.h>
|
2007-04-27 06:48:28 +08:00
|
|
|
#include <net/sock.h>
|
|
|
|
#include <net/af_rxrpc.h>
|
|
|
|
#include "ar-internal.h"
|
|
|
|
|
2014-02-08 02:58:44 +08:00
|
|
|
/*
|
|
|
|
* Maximum lifetime of a call (in jiffies).
|
|
|
|
*/
|
2016-03-10 07:22:56 +08:00
|
|
|
unsigned int rxrpc_max_call_lifetime = 60 * HZ;
|
2014-02-08 02:58:44 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Time till dead call expires after last use (in jiffies).
|
|
|
|
*/
|
2016-03-10 07:22:56 +08:00
|
|
|
unsigned int rxrpc_dead_call_expiry = 2 * HZ;
|
2014-02-08 02:58:44 +08:00
|
|
|
|
2016-03-04 23:53:46 +08:00
|
|
|
const char *const rxrpc_call_states[NR__RXRPC_CALL_STATES] = {
|
2016-06-17 22:42:35 +08:00
|
|
|
[RXRPC_CALL_UNINITIALISED] = "Uninit",
|
|
|
|
[RXRPC_CALL_CLIENT_AWAIT_CONN] = "ClWtConn",
|
2007-05-23 07:14:24 +08:00
|
|
|
[RXRPC_CALL_CLIENT_SEND_REQUEST] = "ClSndReq",
|
|
|
|
[RXRPC_CALL_CLIENT_AWAIT_REPLY] = "ClAwtRpl",
|
|
|
|
[RXRPC_CALL_CLIENT_RECV_REPLY] = "ClRcvRpl",
|
|
|
|
[RXRPC_CALL_CLIENT_FINAL_ACK] = "ClFnlACK",
|
|
|
|
[RXRPC_CALL_SERVER_SECURING] = "SvSecure",
|
|
|
|
[RXRPC_CALL_SERVER_ACCEPTING] = "SvAccept",
|
|
|
|
[RXRPC_CALL_SERVER_RECV_REQUEST] = "SvRcvReq",
|
|
|
|
[RXRPC_CALL_SERVER_ACK_REQUEST] = "SvAckReq",
|
|
|
|
[RXRPC_CALL_SERVER_SEND_REPLY] = "SvSndRpl",
|
|
|
|
[RXRPC_CALL_SERVER_AWAIT_ACK] = "SvAwtACK",
|
|
|
|
[RXRPC_CALL_COMPLETE] = "Complete",
|
|
|
|
[RXRPC_CALL_SERVER_BUSY] = "SvBusy ",
|
|
|
|
[RXRPC_CALL_REMOTELY_ABORTED] = "RmtAbort",
|
|
|
|
[RXRPC_CALL_LOCALLY_ABORTED] = "LocAbort",
|
|
|
|
[RXRPC_CALL_NETWORK_ERROR] = "NetError",
|
|
|
|
[RXRPC_CALL_DEAD] = "Dead ",
|
|
|
|
};
|
|
|
|
|
2007-04-27 06:48:28 +08:00
|
|
|
struct kmem_cache *rxrpc_call_jar;
|
|
|
|
LIST_HEAD(rxrpc_calls);
|
|
|
|
DEFINE_RWLOCK(rxrpc_call_lock);
|
|
|
|
|
|
|
|
static void rxrpc_destroy_call(struct work_struct *work);
|
|
|
|
static void rxrpc_call_life_expired(unsigned long _call);
|
|
|
|
static void rxrpc_dead_call_expired(unsigned long _call);
|
|
|
|
static void rxrpc_ack_time_expired(unsigned long _call);
|
|
|
|
static void rxrpc_resend_time_expired(unsigned long _call);
|
|
|
|
|
2014-03-04 07:04:45 +08:00
|
|
|
static DEFINE_SPINLOCK(rxrpc_call_hash_lock);
|
|
|
|
static DEFINE_HASHTABLE(rxrpc_call_hash, 10);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hash function for rxrpc_call_hash
|
|
|
|
*/
|
|
|
|
static unsigned long rxrpc_call_hashfunc(
|
2016-03-04 23:53:46 +08:00
|
|
|
u8 in_clientflag,
|
|
|
|
u32 cid,
|
|
|
|
u32 call_id,
|
|
|
|
u32 epoch,
|
|
|
|
u16 service_id,
|
2016-04-04 21:00:36 +08:00
|
|
|
sa_family_t family,
|
2014-03-04 07:04:45 +08:00
|
|
|
void *localptr,
|
|
|
|
unsigned int addr_size,
|
|
|
|
const u8 *peer_addr)
|
|
|
|
{
|
|
|
|
const u16 *p;
|
|
|
|
unsigned int i;
|
|
|
|
unsigned long key;
|
|
|
|
|
|
|
|
_enter("");
|
|
|
|
|
|
|
|
key = (unsigned long)localptr;
|
|
|
|
/* We just want to add up the __be32 values, so forcing the
|
|
|
|
* cast should be okay.
|
|
|
|
*/
|
2016-03-04 23:53:46 +08:00
|
|
|
key += epoch;
|
|
|
|
key += service_id;
|
|
|
|
key += call_id;
|
|
|
|
key += (cid & RXRPC_CIDMASK) >> RXRPC_CIDSHIFT;
|
|
|
|
key += cid & RXRPC_CHANNELMASK;
|
|
|
|
key += in_clientflag;
|
2016-04-04 21:00:36 +08:00
|
|
|
key += family;
|
2014-03-04 07:04:45 +08:00
|
|
|
/* Step through the peer address in 16-bit portions for speed */
|
|
|
|
for (i = 0, p = (const u16 *)peer_addr; i < addr_size >> 1; i++, p++)
|
|
|
|
key += *p;
|
|
|
|
_leave(" key = 0x%lx", key);
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a call to the hashtable
|
|
|
|
*/
|
|
|
|
static void rxrpc_call_hash_add(struct rxrpc_call *call)
|
|
|
|
{
|
|
|
|
unsigned long key;
|
|
|
|
unsigned int addr_size = 0;
|
|
|
|
|
|
|
|
_enter("");
|
2016-04-04 21:00:36 +08:00
|
|
|
switch (call->family) {
|
2014-03-04 07:04:45 +08:00
|
|
|
case AF_INET:
|
|
|
|
addr_size = sizeof(call->peer_ip.ipv4_addr);
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
addr_size = sizeof(call->peer_ip.ipv6_addr);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
key = rxrpc_call_hashfunc(call->in_clientflag, call->cid,
|
|
|
|
call->call_id, call->epoch,
|
2016-04-04 21:00:36 +08:00
|
|
|
call->service_id, call->family,
|
2016-04-04 21:00:36 +08:00
|
|
|
call->conn->params.local, addr_size,
|
2014-03-04 07:04:45 +08:00
|
|
|
call->peer_ip.ipv6_addr);
|
|
|
|
/* Store the full key in the call */
|
|
|
|
call->hash_key = key;
|
|
|
|
spin_lock(&rxrpc_call_hash_lock);
|
|
|
|
hash_add_rcu(rxrpc_call_hash, &call->hash_node, key);
|
|
|
|
spin_unlock(&rxrpc_call_hash_lock);
|
|
|
|
_leave("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove a call from the hashtable
|
|
|
|
*/
|
|
|
|
static void rxrpc_call_hash_del(struct rxrpc_call *call)
|
|
|
|
{
|
|
|
|
_enter("");
|
|
|
|
spin_lock(&rxrpc_call_hash_lock);
|
|
|
|
hash_del_rcu(&call->hash_node);
|
|
|
|
spin_unlock(&rxrpc_call_hash_lock);
|
|
|
|
_leave("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find a call in the hashtable and return it, or NULL if it
|
|
|
|
* isn't there.
|
|
|
|
*/
|
|
|
|
struct rxrpc_call *rxrpc_find_call_hash(
|
2016-03-04 23:53:46 +08:00
|
|
|
struct rxrpc_host_header *hdr,
|
2014-03-04 07:04:45 +08:00
|
|
|
void *localptr,
|
2016-04-04 21:00:36 +08:00
|
|
|
sa_family_t family,
|
2016-03-04 23:53:46 +08:00
|
|
|
const void *peer_addr)
|
2014-03-04 07:04:45 +08:00
|
|
|
{
|
|
|
|
unsigned long key;
|
|
|
|
unsigned int addr_size = 0;
|
|
|
|
struct rxrpc_call *call = NULL;
|
|
|
|
struct rxrpc_call *ret = NULL;
|
2016-03-04 23:53:46 +08:00
|
|
|
u8 in_clientflag = hdr->flags & RXRPC_CLIENT_INITIATED;
|
2014-03-04 07:04:45 +08:00
|
|
|
|
|
|
|
_enter("");
|
2016-04-04 21:00:36 +08:00
|
|
|
switch (family) {
|
2014-03-04 07:04:45 +08:00
|
|
|
case AF_INET:
|
|
|
|
addr_size = sizeof(call->peer_ip.ipv4_addr);
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
addr_size = sizeof(call->peer_ip.ipv6_addr);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:53:46 +08:00
|
|
|
key = rxrpc_call_hashfunc(in_clientflag, hdr->cid, hdr->callNumber,
|
|
|
|
hdr->epoch, hdr->serviceId,
|
2016-04-04 21:00:36 +08:00
|
|
|
family, localptr, addr_size,
|
2014-03-04 07:04:45 +08:00
|
|
|
peer_addr);
|
|
|
|
hash_for_each_possible_rcu(rxrpc_call_hash, call, hash_node, key) {
|
|
|
|
if (call->hash_key == key &&
|
2016-03-04 23:53:46 +08:00
|
|
|
call->call_id == hdr->callNumber &&
|
|
|
|
call->cid == hdr->cid &&
|
|
|
|
call->in_clientflag == in_clientflag &&
|
|
|
|
call->service_id == hdr->serviceId &&
|
2016-04-04 21:00:36 +08:00
|
|
|
call->family == family &&
|
2014-03-04 07:04:45 +08:00
|
|
|
call->local == localptr &&
|
|
|
|
memcmp(call->peer_ip.ipv6_addr, peer_addr,
|
2016-03-04 23:53:46 +08:00
|
|
|
addr_size) == 0 &&
|
|
|
|
call->epoch == hdr->epoch) {
|
2014-03-04 07:04:45 +08:00
|
|
|
ret = call;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_leave(" = %p", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-06-10 06:02:51 +08:00
|
|
|
/*
|
|
|
|
* find an extant server call
|
|
|
|
* - called in process context with IRQs enabled
|
|
|
|
*/
|
|
|
|
struct rxrpc_call *rxrpc_find_call_by_user_ID(struct rxrpc_sock *rx,
|
|
|
|
unsigned long user_call_ID)
|
|
|
|
{
|
|
|
|
struct rxrpc_call *call;
|
|
|
|
struct rb_node *p;
|
|
|
|
|
|
|
|
_enter("%p,%lx", rx, user_call_ID);
|
|
|
|
|
|
|
|
read_lock(&rx->call_lock);
|
|
|
|
|
|
|
|
p = rx->calls.rb_node;
|
|
|
|
while (p) {
|
|
|
|
call = rb_entry(p, struct rxrpc_call, sock_node);
|
|
|
|
|
|
|
|
if (user_call_ID < call->user_call_ID)
|
|
|
|
p = p->rb_left;
|
|
|
|
else if (user_call_ID > call->user_call_ID)
|
|
|
|
p = p->rb_right;
|
|
|
|
else
|
|
|
|
goto found_extant_call;
|
|
|
|
}
|
|
|
|
|
|
|
|
read_unlock(&rx->call_lock);
|
|
|
|
_leave(" = NULL");
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
found_extant_call:
|
|
|
|
rxrpc_get_call(call);
|
|
|
|
read_unlock(&rx->call_lock);
|
|
|
|
_leave(" = %p [%d]", call, atomic_read(&call->usage));
|
|
|
|
return call;
|
|
|
|
}
|
|
|
|
|
2007-04-27 06:48:28 +08:00
|
|
|
/*
|
|
|
|
* allocate a new call
|
|
|
|
*/
|
|
|
|
static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct rxrpc_call *call;
|
|
|
|
|
|
|
|
call = kmem_cache_zalloc(rxrpc_call_jar, gfp);
|
|
|
|
if (!call)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
call->acks_winsz = 16;
|
|
|
|
call->acks_window = kmalloc(call->acks_winsz * sizeof(unsigned long),
|
|
|
|
gfp);
|
|
|
|
if (!call->acks_window) {
|
|
|
|
kmem_cache_free(rxrpc_call_jar, call);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_timer(&call->lifetimer, &rxrpc_call_life_expired,
|
|
|
|
(unsigned long) call);
|
|
|
|
setup_timer(&call->deadspan, &rxrpc_dead_call_expired,
|
|
|
|
(unsigned long) call);
|
|
|
|
setup_timer(&call->ack_timer, &rxrpc_ack_time_expired,
|
|
|
|
(unsigned long) call);
|
|
|
|
setup_timer(&call->resend_timer, &rxrpc_resend_time_expired,
|
|
|
|
(unsigned long) call);
|
|
|
|
INIT_WORK(&call->destroyer, &rxrpc_destroy_call);
|
|
|
|
INIT_WORK(&call->processor, &rxrpc_process_call);
|
2016-06-17 22:42:35 +08:00
|
|
|
INIT_LIST_HEAD(&call->link);
|
2007-04-27 06:48:28 +08:00
|
|
|
INIT_LIST_HEAD(&call->accept_link);
|
|
|
|
skb_queue_head_init(&call->rx_queue);
|
|
|
|
skb_queue_head_init(&call->rx_oos_queue);
|
|
|
|
init_waitqueue_head(&call->tx_waitq);
|
|
|
|
spin_lock_init(&call->lock);
|
|
|
|
rwlock_init(&call->state_lock);
|
|
|
|
atomic_set(&call->usage, 1);
|
|
|
|
call->debug_id = atomic_inc_return(&rxrpc_debug_id);
|
|
|
|
|
|
|
|
memset(&call->sock_node, 0xed, sizeof(call->sock_node));
|
|
|
|
|
|
|
|
call->rx_data_expect = 1;
|
|
|
|
call->rx_data_eaten = 0;
|
|
|
|
call->rx_first_oos = 0;
|
2014-02-08 02:10:30 +08:00
|
|
|
call->ackr_win_top = call->rx_data_eaten + 1 + rxrpc_rx_window_size;
|
2007-04-27 06:48:28 +08:00
|
|
|
call->creation_jif = jiffies;
|
|
|
|
return call;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-06-17 22:42:35 +08:00
|
|
|
* Allocate a new client call.
|
2007-04-27 06:48:28 +08:00
|
|
|
*/
|
2016-06-17 17:06:56 +08:00
|
|
|
static struct rxrpc_call *rxrpc_alloc_client_call(struct rxrpc_sock *rx,
|
|
|
|
struct sockaddr_rxrpc *srx,
|
|
|
|
gfp_t gfp)
|
2007-04-27 06:48:28 +08:00
|
|
|
{
|
|
|
|
struct rxrpc_call *call;
|
|
|
|
|
|
|
|
_enter("");
|
|
|
|
|
2016-06-17 22:42:35 +08:00
|
|
|
ASSERT(rx->local != NULL);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
|
|
|
call = rxrpc_alloc_call(gfp);
|
|
|
|
if (!call)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
2016-06-17 22:42:35 +08:00
|
|
|
call->state = RXRPC_CALL_CLIENT_AWAIT_CONN;
|
2007-04-27 06:48:28 +08:00
|
|
|
|
|
|
|
sock_hold(&rx->sk);
|
|
|
|
call->socket = rx;
|
|
|
|
call->rx_data_post = 1;
|
|
|
|
|
2014-03-04 07:04:45 +08:00
|
|
|
/* Record copies of information for hashtable lookup */
|
2016-04-04 21:00:36 +08:00
|
|
|
call->family = rx->family;
|
2016-06-17 22:42:35 +08:00
|
|
|
call->local = rx->local;
|
2016-04-04 21:00:36 +08:00
|
|
|
switch (call->family) {
|
2014-03-04 07:04:45 +08:00
|
|
|
case AF_INET:
|
2016-06-17 22:42:35 +08:00
|
|
|
call->peer_ip.ipv4_addr = srx->transport.sin.sin_addr.s_addr;
|
2014-03-04 07:04:45 +08:00
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
memcpy(call->peer_ip.ipv6_addr,
|
2016-06-17 22:42:35 +08:00
|
|
|
srx->transport.sin6.sin6_addr.in6_u.u6_addr8,
|
2014-03-04 07:04:45 +08:00
|
|
|
sizeof(call->peer_ip.ipv6_addr));
|
|
|
|
break;
|
|
|
|
}
|
2016-06-17 22:42:35 +08:00
|
|
|
|
|
|
|
call->service_id = srx->srx_service;
|
|
|
|
call->in_clientflag = 0;
|
|
|
|
|
|
|
|
_leave(" = %p", call);
|
|
|
|
return call;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Begin client call.
|
|
|
|
*/
|
|
|
|
static int rxrpc_begin_client_call(struct rxrpc_call *call,
|
|
|
|
struct rxrpc_conn_parameters *cp,
|
|
|
|
struct sockaddr_rxrpc *srx,
|
|
|
|
gfp_t gfp)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Set up or get a connection record and set the protocol parameters,
|
|
|
|
* including channel number and call ID.
|
|
|
|
*/
|
2016-06-17 17:06:56 +08:00
|
|
|
ret = rxrpc_connect_call(call, cp, srx, gfp);
|
2016-06-17 22:42:35 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
|
|
|
|
|
2014-03-04 07:04:45 +08:00
|
|
|
/* Add the new call to the hashtable */
|
|
|
|
rxrpc_call_hash_add(call);
|
|
|
|
|
2016-04-04 21:00:36 +08:00
|
|
|
spin_lock(&call->conn->params.peer->lock);
|
|
|
|
hlist_add_head(&call->error_link, &call->conn->params.peer->error_targets);
|
|
|
|
spin_unlock(&call->conn->params.peer->lock);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2014-02-08 02:58:44 +08:00
|
|
|
call->lifetimer.expires = jiffies + rxrpc_max_call_lifetime;
|
2007-04-27 06:48:28 +08:00
|
|
|
add_timer(&call->lifetimer);
|
2016-06-17 22:42:35 +08:00
|
|
|
return 0;
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set up a call for the given data
|
|
|
|
* - called in process context with IRQs enabled
|
|
|
|
*/
|
2016-06-10 06:02:51 +08:00
|
|
|
struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,
|
2016-04-04 21:00:36 +08:00
|
|
|
struct rxrpc_conn_parameters *cp,
|
2016-06-17 22:42:35 +08:00
|
|
|
struct sockaddr_rxrpc *srx,
|
2007-04-27 06:48:28 +08:00
|
|
|
unsigned long user_call_ID,
|
|
|
|
gfp_t gfp)
|
|
|
|
{
|
2016-06-10 06:02:51 +08:00
|
|
|
struct rxrpc_call *call, *xcall;
|
|
|
|
struct rb_node *parent, **pp;
|
2016-06-17 22:42:35 +08:00
|
|
|
int ret;
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-06-17 22:42:35 +08:00
|
|
|
_enter("%p,%lx", rx, user_call_ID);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-06-17 17:06:56 +08:00
|
|
|
call = rxrpc_alloc_client_call(rx, srx, gfp);
|
2016-06-10 06:02:51 +08:00
|
|
|
if (IS_ERR(call)) {
|
|
|
|
_leave(" = %ld", PTR_ERR(call));
|
|
|
|
return call;
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
2016-06-17 22:42:35 +08:00
|
|
|
/* Publish the call, even though it is incompletely set up as yet */
|
2016-06-10 06:02:51 +08:00
|
|
|
call->user_call_ID = user_call_ID;
|
|
|
|
__set_bit(RXRPC_CALL_HAS_USERID, &call->flags);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
|
|
|
write_lock(&rx->call_lock);
|
|
|
|
|
|
|
|
pp = &rx->calls.rb_node;
|
|
|
|
parent = NULL;
|
|
|
|
while (*pp) {
|
|
|
|
parent = *pp;
|
2016-06-10 06:02:51 +08:00
|
|
|
xcall = rb_entry(parent, struct rxrpc_call, sock_node);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-06-10 06:02:51 +08:00
|
|
|
if (user_call_ID < xcall->user_call_ID)
|
2007-04-27 06:48:28 +08:00
|
|
|
pp = &(*pp)->rb_left;
|
2016-06-10 06:02:51 +08:00
|
|
|
else if (user_call_ID > xcall->user_call_ID)
|
2007-04-27 06:48:28 +08:00
|
|
|
pp = &(*pp)->rb_right;
|
|
|
|
else
|
2016-06-10 06:02:51 +08:00
|
|
|
goto found_user_ID_now_present;
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
rxrpc_get_call(call);
|
|
|
|
|
|
|
|
rb_link_node(&call->sock_node, parent, pp);
|
|
|
|
rb_insert_color(&call->sock_node, &rx->calls);
|
|
|
|
write_unlock(&rx->call_lock);
|
|
|
|
|
|
|
|
write_lock_bh(&rxrpc_call_lock);
|
|
|
|
list_add_tail(&call->link, &rxrpc_calls);
|
|
|
|
write_unlock_bh(&rxrpc_call_lock);
|
|
|
|
|
2016-06-17 17:06:56 +08:00
|
|
|
ret = rxrpc_begin_client_call(call, cp, srx, gfp);
|
2016-06-17 22:42:35 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto error;
|
|
|
|
|
2007-04-27 06:48:28 +08:00
|
|
|
_net("CALL new %d on CONN %d", call->debug_id, call->conn->debug_id);
|
|
|
|
|
|
|
|
_leave(" = %p [new]", call);
|
|
|
|
return call;
|
|
|
|
|
2016-06-17 22:42:35 +08:00
|
|
|
error:
|
|
|
|
write_lock(&rx->call_lock);
|
|
|
|
rb_erase(&call->sock_node, &rx->calls);
|
|
|
|
write_unlock(&rx->call_lock);
|
|
|
|
rxrpc_put_call(call);
|
|
|
|
|
|
|
|
write_lock_bh(&rxrpc_call_lock);
|
2016-04-04 21:00:39 +08:00
|
|
|
list_del_init(&call->link);
|
2016-06-17 22:42:35 +08:00
|
|
|
write_unlock_bh(&rxrpc_call_lock);
|
|
|
|
|
2016-04-04 21:00:39 +08:00
|
|
|
call->state = RXRPC_CALL_DEAD;
|
2016-06-17 22:42:35 +08:00
|
|
|
rxrpc_put_call(call);
|
|
|
|
_leave(" = %d", ret);
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
|
2016-06-10 06:02:51 +08:00
|
|
|
/* We unexpectedly found the user ID in the list after taking
|
|
|
|
* the call_lock. This shouldn't happen unless the user races
|
|
|
|
* with itself and tries to add the same user ID twice at the
|
|
|
|
* same time in different threads.
|
|
|
|
*/
|
|
|
|
found_user_ID_now_present:
|
2007-04-27 06:48:28 +08:00
|
|
|
write_unlock(&rx->call_lock);
|
2016-04-04 21:00:39 +08:00
|
|
|
call->state = RXRPC_CALL_DEAD;
|
2016-06-10 06:02:51 +08:00
|
|
|
rxrpc_put_call(call);
|
|
|
|
_leave(" = -EEXIST [%p]", call);
|
|
|
|
return ERR_PTR(-EEXIST);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set up an incoming call
|
|
|
|
* - called in process context with IRQs enabled
|
|
|
|
*/
|
|
|
|
struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
|
|
|
|
struct rxrpc_connection *conn,
|
2016-06-16 20:31:07 +08:00
|
|
|
struct sk_buff *skb)
|
2007-04-27 06:48:28 +08:00
|
|
|
{
|
2016-06-16 20:31:07 +08:00
|
|
|
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
|
2007-04-27 06:48:28 +08:00
|
|
|
struct rxrpc_call *call, *candidate;
|
|
|
|
struct rb_node **p, *parent;
|
2016-03-04 23:53:46 +08:00
|
|
|
u32 call_id;
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-08 00:23:37 +08:00
|
|
|
_enter(",%d", conn->debug_id);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
|
|
|
ASSERT(rx != NULL);
|
|
|
|
|
2016-04-08 00:23:37 +08:00
|
|
|
candidate = rxrpc_alloc_call(GFP_NOIO);
|
2007-04-27 06:48:28 +08:00
|
|
|
if (!candidate)
|
|
|
|
return ERR_PTR(-EBUSY);
|
|
|
|
|
2016-06-16 20:31:07 +08:00
|
|
|
candidate->socket = rx;
|
|
|
|
candidate->conn = conn;
|
|
|
|
candidate->cid = sp->hdr.cid;
|
|
|
|
candidate->call_id = sp->hdr.callNumber;
|
|
|
|
candidate->channel = sp->hdr.cid & RXRPC_CHANNELMASK;
|
|
|
|
candidate->rx_data_post = 0;
|
|
|
|
candidate->state = RXRPC_CALL_SERVER_ACCEPTING;
|
2007-04-27 06:48:28 +08:00
|
|
|
if (conn->security_ix > 0)
|
|
|
|
candidate->state = RXRPC_CALL_SERVER_SECURING;
|
|
|
|
|
|
|
|
write_lock_bh(&conn->lock);
|
|
|
|
|
|
|
|
/* set the channel for this call */
|
|
|
|
call = conn->channels[candidate->channel];
|
|
|
|
_debug("channel[%u] is %p", candidate->channel, call);
|
2016-06-16 20:31:07 +08:00
|
|
|
if (call && call->call_id == sp->hdr.callNumber) {
|
2007-04-27 06:48:28 +08:00
|
|
|
/* already set; must've been a duplicate packet */
|
|
|
|
_debug("extant call [%d]", call->state);
|
|
|
|
ASSERTCMP(call->conn, ==, conn);
|
|
|
|
|
|
|
|
read_lock(&call->state_lock);
|
|
|
|
switch (call->state) {
|
|
|
|
case RXRPC_CALL_LOCALLY_ABORTED:
|
2016-03-04 23:53:46 +08:00
|
|
|
if (!test_and_set_bit(RXRPC_CALL_EV_ABORT, &call->events))
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
rxrpc_queue_call(call);
|
2007-04-27 06:48:28 +08:00
|
|
|
case RXRPC_CALL_REMOTELY_ABORTED:
|
|
|
|
read_unlock(&call->state_lock);
|
|
|
|
goto aborted_call;
|
|
|
|
default:
|
|
|
|
rxrpc_get_call(call);
|
|
|
|
read_unlock(&call->state_lock);
|
|
|
|
goto extant_call;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (call) {
|
|
|
|
/* it seems the channel is still in use from the previous call
|
|
|
|
* - ditch the old binding if its call is now complete */
|
|
|
|
_debug("CALL: %u { %s }",
|
|
|
|
call->debug_id, rxrpc_call_states[call->state]);
|
|
|
|
|
|
|
|
if (call->state >= RXRPC_CALL_COMPLETE) {
|
|
|
|
conn->channels[call->channel] = NULL;
|
|
|
|
} else {
|
|
|
|
write_unlock_bh(&conn->lock);
|
|
|
|
kmem_cache_free(rxrpc_call_jar, candidate);
|
|
|
|
_leave(" = -EBUSY");
|
|
|
|
return ERR_PTR(-EBUSY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check the call number isn't duplicate */
|
|
|
|
_debug("check dup");
|
2016-06-16 20:31:07 +08:00
|
|
|
call_id = sp->hdr.callNumber;
|
2007-04-27 06:48:28 +08:00
|
|
|
p = &conn->calls.rb_node;
|
|
|
|
parent = NULL;
|
|
|
|
while (*p) {
|
|
|
|
parent = *p;
|
|
|
|
call = rb_entry(parent, struct rxrpc_call, conn_node);
|
|
|
|
|
2014-03-04 07:04:45 +08:00
|
|
|
/* The tree is sorted in order of the __be32 value without
|
|
|
|
* turning it into host order.
|
|
|
|
*/
|
2016-03-04 23:53:46 +08:00
|
|
|
if (call_id < call->call_id)
|
2007-04-27 06:48:28 +08:00
|
|
|
p = &(*p)->rb_left;
|
2016-03-04 23:53:46 +08:00
|
|
|
else if (call_id > call->call_id)
|
2007-04-27 06:48:28 +08:00
|
|
|
p = &(*p)->rb_right;
|
|
|
|
else
|
|
|
|
goto old_call;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make the call available */
|
|
|
|
_debug("new call");
|
|
|
|
call = candidate;
|
|
|
|
candidate = NULL;
|
|
|
|
rb_link_node(&call->conn_node, parent, p);
|
|
|
|
rb_insert_color(&call->conn_node, &conn->calls);
|
|
|
|
conn->channels[call->channel] = call;
|
|
|
|
sock_hold(&rx->sk);
|
2016-04-04 21:00:38 +08:00
|
|
|
rxrpc_get_connection(conn);
|
2007-04-27 06:48:28 +08:00
|
|
|
write_unlock_bh(&conn->lock);
|
|
|
|
|
2016-04-04 21:00:36 +08:00
|
|
|
spin_lock(&conn->params.peer->lock);
|
|
|
|
hlist_add_head(&call->error_link, &conn->params.peer->error_targets);
|
|
|
|
spin_unlock(&conn->params.peer->lock);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
|
|
|
write_lock_bh(&rxrpc_call_lock);
|
|
|
|
list_add_tail(&call->link, &rxrpc_calls);
|
|
|
|
write_unlock_bh(&rxrpc_call_lock);
|
|
|
|
|
2014-03-04 07:04:45 +08:00
|
|
|
/* Record copies of information for hashtable lookup */
|
2016-04-04 21:00:36 +08:00
|
|
|
call->family = rx->family;
|
2016-04-04 21:00:36 +08:00
|
|
|
call->local = conn->params.local;
|
2016-04-04 21:00:36 +08:00
|
|
|
switch (call->family) {
|
2014-03-04 07:04:45 +08:00
|
|
|
case AF_INET:
|
|
|
|
call->peer_ip.ipv4_addr =
|
2016-04-04 21:00:36 +08:00
|
|
|
conn->params.peer->srx.transport.sin.sin_addr.s_addr;
|
2014-03-04 07:04:45 +08:00
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
memcpy(call->peer_ip.ipv6_addr,
|
2016-04-04 21:00:36 +08:00
|
|
|
conn->params.peer->srx.transport.sin6.sin6_addr.in6_u.u6_addr8,
|
2014-03-04 07:04:45 +08:00
|
|
|
sizeof(call->peer_ip.ipv6_addr));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-04-04 21:00:36 +08:00
|
|
|
call->epoch = conn->proto.epoch;
|
|
|
|
call->service_id = conn->params.service_id;
|
|
|
|
call->in_clientflag = conn->proto.in_clientflag;
|
2014-03-04 07:04:45 +08:00
|
|
|
/* Add the new call to the hashtable */
|
|
|
|
rxrpc_call_hash_add(call);
|
|
|
|
|
2007-04-27 06:48:28 +08:00
|
|
|
_net("CALL incoming %d on CONN %d", call->debug_id, call->conn->debug_id);
|
|
|
|
|
2014-02-08 02:58:44 +08:00
|
|
|
call->lifetimer.expires = jiffies + rxrpc_max_call_lifetime;
|
2007-04-27 06:48:28 +08:00
|
|
|
add_timer(&call->lifetimer);
|
|
|
|
_leave(" = %p {%d} [new]", call, call->debug_id);
|
|
|
|
return call;
|
|
|
|
|
|
|
|
extant_call:
|
|
|
|
write_unlock_bh(&conn->lock);
|
|
|
|
kmem_cache_free(rxrpc_call_jar, candidate);
|
|
|
|
_leave(" = %p {%d} [extant]", call, call ? call->debug_id : -1);
|
|
|
|
return call;
|
|
|
|
|
|
|
|
aborted_call:
|
|
|
|
write_unlock_bh(&conn->lock);
|
|
|
|
kmem_cache_free(rxrpc_call_jar, candidate);
|
|
|
|
_leave(" = -ECONNABORTED");
|
|
|
|
return ERR_PTR(-ECONNABORTED);
|
|
|
|
|
|
|
|
old_call:
|
|
|
|
write_unlock_bh(&conn->lock);
|
|
|
|
kmem_cache_free(rxrpc_call_jar, candidate);
|
|
|
|
_leave(" = -ECONNRESET [old]");
|
|
|
|
return ERR_PTR(-ECONNRESET);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* detach a call from a socket and set up for release
|
|
|
|
*/
|
|
|
|
void rxrpc_release_call(struct rxrpc_call *call)
|
|
|
|
{
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
struct rxrpc_connection *conn = call->conn;
|
2007-04-27 06:48:28 +08:00
|
|
|
struct rxrpc_sock *rx = call->socket;
|
|
|
|
|
|
|
|
_enter("{%d,%d,%d,%d}",
|
|
|
|
call->debug_id, atomic_read(&call->usage),
|
|
|
|
atomic_read(&call->ackr_not_idle),
|
|
|
|
call->rx_first_oos);
|
|
|
|
|
|
|
|
spin_lock_bh(&call->lock);
|
|
|
|
if (test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags))
|
|
|
|
BUG();
|
|
|
|
spin_unlock_bh(&call->lock);
|
|
|
|
|
|
|
|
/* dissociate from the socket
|
|
|
|
* - the socket's ref on the call is passed to the death timer
|
|
|
|
*/
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
_debug("RELEASE CALL %p (%d CONN %p)", call, call->debug_id, conn);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:38 +08:00
|
|
|
spin_lock(&conn->params.peer->lock);
|
|
|
|
hlist_del_init(&call->error_link);
|
|
|
|
spin_unlock(&conn->params.peer->lock);
|
|
|
|
|
2007-04-27 06:48:28 +08:00
|
|
|
write_lock_bh(&rx->call_lock);
|
|
|
|
if (!list_empty(&call->accept_link)) {
|
|
|
|
_debug("unlinking once-pending call %p { e=%lx f=%lx }",
|
|
|
|
call, call->events, call->flags);
|
|
|
|
ASSERT(!test_bit(RXRPC_CALL_HAS_USERID, &call->flags));
|
|
|
|
list_del_init(&call->accept_link);
|
|
|
|
sk_acceptq_removed(&rx->sk);
|
|
|
|
} else if (test_bit(RXRPC_CALL_HAS_USERID, &call->flags)) {
|
|
|
|
rb_erase(&call->sock_node, &rx->calls);
|
|
|
|
memset(&call->sock_node, 0xdd, sizeof(call->sock_node));
|
|
|
|
clear_bit(RXRPC_CALL_HAS_USERID, &call->flags);
|
|
|
|
}
|
|
|
|
write_unlock_bh(&rx->call_lock);
|
|
|
|
|
|
|
|
/* free up the channel for reuse */
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
write_lock_bh(&conn->lock);
|
|
|
|
write_lock(&call->state_lock);
|
|
|
|
|
2007-04-27 06:48:28 +08:00
|
|
|
if (call->state < RXRPC_CALL_COMPLETE &&
|
|
|
|
call->state != RXRPC_CALL_CLIENT_FINAL_ACK) {
|
|
|
|
_debug("+++ ABORTING STATE %d +++\n", call->state);
|
|
|
|
call->state = RXRPC_CALL_LOCALLY_ABORTED;
|
2016-04-08 00:23:30 +08:00
|
|
|
call->local_abort = RX_CALL_DEAD;
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
write_unlock(&call->state_lock);
|
2016-04-04 21:00:38 +08:00
|
|
|
|
|
|
|
rb_erase(&call->conn_node, &conn->calls);
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
write_unlock_bh(&conn->lock);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2016-04-04 21:00:38 +08:00
|
|
|
rxrpc_disconnect_call(call);
|
|
|
|
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
/* clean up the Rx queue */
|
2007-04-27 06:48:28 +08:00
|
|
|
if (!skb_queue_empty(&call->rx_queue) ||
|
|
|
|
!skb_queue_empty(&call->rx_oos_queue)) {
|
|
|
|
struct rxrpc_skb_priv *sp;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
_debug("purge Rx queues");
|
|
|
|
|
|
|
|
spin_lock_bh(&call->lock);
|
|
|
|
while ((skb = skb_dequeue(&call->rx_queue)) ||
|
|
|
|
(skb = skb_dequeue(&call->rx_oos_queue))) {
|
|
|
|
sp = rxrpc_skb(skb);
|
|
|
|
if (sp->call) {
|
|
|
|
ASSERTCMP(sp->call, ==, call);
|
|
|
|
rxrpc_put_call(call);
|
|
|
|
sp->call = NULL;
|
|
|
|
}
|
|
|
|
skb->destructor = NULL;
|
|
|
|
spin_unlock_bh(&call->lock);
|
|
|
|
|
|
|
|
_debug("- zap %s %%%u #%u",
|
|
|
|
rxrpc_pkts[sp->hdr.type],
|
2016-03-04 23:53:46 +08:00
|
|
|
sp->hdr.serial, sp->hdr.seq);
|
2007-04-27 06:48:28 +08:00
|
|
|
rxrpc_free_skb(skb);
|
|
|
|
spin_lock_bh(&call->lock);
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&call->lock);
|
|
|
|
|
|
|
|
ASSERTCMP(call->state, !=, RXRPC_CALL_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
del_timer_sync(&call->resend_timer);
|
|
|
|
del_timer_sync(&call->ack_timer);
|
|
|
|
del_timer_sync(&call->lifetimer);
|
2014-02-08 02:58:44 +08:00
|
|
|
call->deadspan.expires = jiffies + rxrpc_dead_call_expiry;
|
2007-04-27 06:48:28 +08:00
|
|
|
add_timer(&call->deadspan);
|
|
|
|
|
|
|
|
_leave("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* handle a dead call being ready for reaping
|
|
|
|
*/
|
|
|
|
static void rxrpc_dead_call_expired(unsigned long _call)
|
|
|
|
{
|
|
|
|
struct rxrpc_call *call = (struct rxrpc_call *) _call;
|
|
|
|
|
|
|
|
_enter("{%d}", call->debug_id);
|
|
|
|
|
|
|
|
write_lock_bh(&call->state_lock);
|
|
|
|
call->state = RXRPC_CALL_DEAD;
|
|
|
|
write_unlock_bh(&call->state_lock);
|
|
|
|
rxrpc_put_call(call);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mark a call as to be released, aborting it if it's still in progress
|
|
|
|
* - called with softirqs disabled
|
|
|
|
*/
|
|
|
|
static void rxrpc_mark_call_released(struct rxrpc_call *call)
|
|
|
|
{
|
|
|
|
bool sched;
|
|
|
|
|
|
|
|
write_lock(&call->state_lock);
|
|
|
|
if (call->state < RXRPC_CALL_DEAD) {
|
|
|
|
sched = false;
|
|
|
|
if (call->state < RXRPC_CALL_COMPLETE) {
|
|
|
|
_debug("abort call %p", call);
|
|
|
|
call->state = RXRPC_CALL_LOCALLY_ABORTED;
|
2016-04-08 00:23:30 +08:00
|
|
|
call->local_abort = RX_CALL_DEAD;
|
2016-03-04 23:53:46 +08:00
|
|
|
if (!test_and_set_bit(RXRPC_CALL_EV_ABORT, &call->events))
|
2007-04-27 06:48:28 +08:00
|
|
|
sched = true;
|
|
|
|
}
|
2016-03-04 23:53:46 +08:00
|
|
|
if (!test_and_set_bit(RXRPC_CALL_EV_RELEASE, &call->events))
|
2007-04-27 06:48:28 +08:00
|
|
|
sched = true;
|
|
|
|
if (sched)
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
rxrpc_queue_call(call);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
write_unlock(&call->state_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* release all the calls associated with a socket
|
|
|
|
*/
|
|
|
|
void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx)
|
|
|
|
{
|
|
|
|
struct rxrpc_call *call;
|
|
|
|
struct rb_node *p;
|
|
|
|
|
|
|
|
_enter("%p", rx);
|
|
|
|
|
|
|
|
read_lock_bh(&rx->call_lock);
|
|
|
|
|
|
|
|
/* mark all the calls as no longer wanting incoming packets */
|
|
|
|
for (p = rb_first(&rx->calls); p; p = rb_next(p)) {
|
|
|
|
call = rb_entry(p, struct rxrpc_call, sock_node);
|
|
|
|
rxrpc_mark_call_released(call);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* kill the not-yet-accepted incoming calls */
|
|
|
|
list_for_each_entry(call, &rx->secureq, accept_link) {
|
|
|
|
rxrpc_mark_call_released(call);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry(call, &rx->acceptq, accept_link) {
|
|
|
|
rxrpc_mark_call_released(call);
|
|
|
|
}
|
|
|
|
|
|
|
|
read_unlock_bh(&rx->call_lock);
|
|
|
|
_leave("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* release a call
|
|
|
|
*/
|
|
|
|
void __rxrpc_put_call(struct rxrpc_call *call)
|
|
|
|
{
|
|
|
|
ASSERT(call != NULL);
|
|
|
|
|
|
|
|
_enter("%p{u=%d}", call, atomic_read(&call->usage));
|
|
|
|
|
|
|
|
ASSERTCMP(atomic_read(&call->usage), >, 0);
|
|
|
|
|
|
|
|
if (atomic_dec_and_test(&call->usage)) {
|
|
|
|
_debug("call %d dead", call->debug_id);
|
|
|
|
ASSERTCMP(call->state, ==, RXRPC_CALL_DEAD);
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
rxrpc_queue_work(&call->destroyer);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
_leave("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clean up a call
|
|
|
|
*/
|
|
|
|
static void rxrpc_cleanup_call(struct rxrpc_call *call)
|
|
|
|
{
|
|
|
|
_net("DESTROY CALL %d", call->debug_id);
|
|
|
|
|
|
|
|
ASSERT(call->socket);
|
|
|
|
|
|
|
|
memset(&call->sock_node, 0xcd, sizeof(call->sock_node));
|
|
|
|
|
|
|
|
del_timer_sync(&call->lifetimer);
|
|
|
|
del_timer_sync(&call->deadspan);
|
|
|
|
del_timer_sync(&call->ack_timer);
|
|
|
|
del_timer_sync(&call->resend_timer);
|
|
|
|
|
|
|
|
ASSERT(test_bit(RXRPC_CALL_RELEASED, &call->flags));
|
|
|
|
ASSERTCMP(call->events, ==, 0);
|
|
|
|
if (work_pending(&call->processor)) {
|
|
|
|
_debug("defer destroy");
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
rxrpc_queue_work(&call->destroyer);
|
2007-04-27 06:48:28 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-04 21:00:38 +08:00
|
|
|
ASSERTCMP(call->conn, ==, NULL);
|
2007-04-27 06:48:28 +08:00
|
|
|
|
2014-03-04 07:04:45 +08:00
|
|
|
/* Remove the call from the hash */
|
|
|
|
rxrpc_call_hash_del(call);
|
|
|
|
|
2007-04-27 06:48:28 +08:00
|
|
|
if (call->acks_window) {
|
|
|
|
_debug("kill Tx window %d",
|
|
|
|
CIRC_CNT(call->acks_head, call->acks_tail,
|
|
|
|
call->acks_winsz));
|
|
|
|
smp_mb();
|
|
|
|
while (CIRC_CNT(call->acks_head, call->acks_tail,
|
|
|
|
call->acks_winsz) > 0) {
|
|
|
|
struct rxrpc_skb_priv *sp;
|
|
|
|
unsigned long _skb;
|
|
|
|
|
|
|
|
_skb = call->acks_window[call->acks_tail] & ~1;
|
2016-03-04 23:53:46 +08:00
|
|
|
sp = rxrpc_skb((struct sk_buff *)_skb);
|
|
|
|
_debug("+++ clear Tx %u", sp->hdr.seq);
|
|
|
|
rxrpc_free_skb((struct sk_buff *)_skb);
|
2007-04-27 06:48:28 +08:00
|
|
|
call->acks_tail =
|
|
|
|
(call->acks_tail + 1) & (call->acks_winsz - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(call->acks_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
rxrpc_free_skb(call->tx_pending);
|
|
|
|
|
|
|
|
rxrpc_purge_queue(&call->rx_queue);
|
|
|
|
ASSERT(skb_queue_empty(&call->rx_oos_queue));
|
|
|
|
sock_put(&call->socket->sk);
|
|
|
|
kmem_cache_free(rxrpc_call_jar, call);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* destroy a call
|
|
|
|
*/
|
|
|
|
static void rxrpc_destroy_call(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct rxrpc_call *call =
|
|
|
|
container_of(work, struct rxrpc_call, destroyer);
|
|
|
|
|
|
|
|
_enter("%p{%d,%d,%p}",
|
|
|
|
call, atomic_read(&call->usage), call->channel, call->conn);
|
|
|
|
|
|
|
|
ASSERTCMP(call->state, ==, RXRPC_CALL_DEAD);
|
|
|
|
|
|
|
|
write_lock_bh(&rxrpc_call_lock);
|
|
|
|
list_del_init(&call->link);
|
|
|
|
write_unlock_bh(&rxrpc_call_lock);
|
|
|
|
|
|
|
|
rxrpc_cleanup_call(call);
|
|
|
|
_leave("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* preemptively destroy all the call records from a transport endpoint rather
|
|
|
|
* than waiting for them to time out
|
|
|
|
*/
|
|
|
|
void __exit rxrpc_destroy_all_calls(void)
|
|
|
|
{
|
|
|
|
struct rxrpc_call *call;
|
|
|
|
|
|
|
|
_enter("");
|
|
|
|
write_lock_bh(&rxrpc_call_lock);
|
|
|
|
|
|
|
|
while (!list_empty(&rxrpc_calls)) {
|
|
|
|
call = list_entry(rxrpc_calls.next, struct rxrpc_call, link);
|
|
|
|
_debug("Zapping call %p", call);
|
|
|
|
|
|
|
|
list_del_init(&call->link);
|
|
|
|
|
|
|
|
switch (atomic_read(&call->usage)) {
|
|
|
|
case 0:
|
|
|
|
ASSERTCMP(call->state, ==, RXRPC_CALL_DEAD);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (del_timer_sync(&call->deadspan) != 0 &&
|
|
|
|
call->state != RXRPC_CALL_DEAD)
|
|
|
|
rxrpc_dead_call_expired((unsigned long) call);
|
|
|
|
if (call->state != RXRPC_CALL_DEAD)
|
|
|
|
break;
|
|
|
|
default:
|
2016-06-03 03:08:52 +08:00
|
|
|
pr_err("Call %p still in use (%d,%d,%s,%lx,%lx)!\n",
|
2007-04-27 06:48:28 +08:00
|
|
|
call, atomic_read(&call->usage),
|
|
|
|
atomic_read(&call->ackr_not_idle),
|
|
|
|
rxrpc_call_states[call->state],
|
|
|
|
call->flags, call->events);
|
|
|
|
if (!skb_queue_empty(&call->rx_queue))
|
2016-06-03 03:08:52 +08:00
|
|
|
pr_err("Rx queue occupied\n");
|
2007-04-27 06:48:28 +08:00
|
|
|
if (!skb_queue_empty(&call->rx_oos_queue))
|
2016-06-03 03:08:52 +08:00
|
|
|
pr_err("OOS queue occupied\n");
|
2007-04-27 06:48:28 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
write_unlock_bh(&rxrpc_call_lock);
|
|
|
|
cond_resched();
|
|
|
|
write_lock_bh(&rxrpc_call_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
write_unlock_bh(&rxrpc_call_lock);
|
|
|
|
_leave("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* handle call lifetime being exceeded
|
|
|
|
*/
|
|
|
|
static void rxrpc_call_life_expired(unsigned long _call)
|
|
|
|
{
|
|
|
|
struct rxrpc_call *call = (struct rxrpc_call *) _call;
|
|
|
|
|
|
|
|
if (call->state >= RXRPC_CALL_COMPLETE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_enter("{%d}", call->debug_id);
|
|
|
|
read_lock_bh(&call->state_lock);
|
|
|
|
if (call->state < RXRPC_CALL_COMPLETE) {
|
2016-03-04 23:53:46 +08:00
|
|
|
set_bit(RXRPC_CALL_EV_LIFE_TIMER, &call->events);
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
rxrpc_queue_call(call);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
read_unlock_bh(&call->state_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* handle resend timer expiry
|
2010-08-04 10:34:17 +08:00
|
|
|
* - may not take call->state_lock as this can deadlock against del_timer_sync()
|
2007-04-27 06:48:28 +08:00
|
|
|
*/
|
|
|
|
static void rxrpc_resend_time_expired(unsigned long _call)
|
|
|
|
{
|
|
|
|
struct rxrpc_call *call = (struct rxrpc_call *) _call;
|
|
|
|
|
|
|
|
_enter("{%d}", call->debug_id);
|
|
|
|
|
|
|
|
if (call->state >= RXRPC_CALL_COMPLETE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags);
|
2016-03-04 23:53:46 +08:00
|
|
|
if (!test_and_set_bit(RXRPC_CALL_EV_RESEND_TIMER, &call->events))
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
rxrpc_queue_call(call);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* handle ACK timer expiry
|
|
|
|
*/
|
|
|
|
static void rxrpc_ack_time_expired(unsigned long _call)
|
|
|
|
{
|
|
|
|
struct rxrpc_call *call = (struct rxrpc_call *) _call;
|
|
|
|
|
|
|
|
_enter("{%d}", call->debug_id);
|
|
|
|
|
|
|
|
if (call->state >= RXRPC_CALL_COMPLETE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
read_lock_bh(&call->state_lock);
|
|
|
|
if (call->state < RXRPC_CALL_COMPLETE &&
|
2016-03-04 23:53:46 +08:00
|
|
|
!test_and_set_bit(RXRPC_CALL_EV_ACK, &call->events))
|
[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use
Add an interface to the AF_RXRPC module so that the AFS filesystem module can
more easily make use of the services available. AFS still opens a socket but
then uses the action functions in lieu of sendmsg() and registers an intercept
functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of
a socket. This is done instead by AFS at the point of open(), unlink() or
other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to
Documentation/networking/rxrpc.txt:
=========================
AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities
such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket
rather than having to open a whole slew of sockets, one for each key it
might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or
opening of a socket. Instead the utility is responsible for requesting a
key at the appropriate point. AFS, for instance, would do this during VFS
operations such as open() or unlink(). The key is then handed through
when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be
intercepted before they get put into the socket Rx queue and the socket
buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
bind an addess as appropriate and listen if it's to be a server socket, but
then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call *
rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx,
struct key *key,
unsigned long user_call_ID,
gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns
call and connection numbers. The call will be made on the UDP port that
the socket is bound to. The call will go to the destination address of a
connected client socket unless an alternative is supplied (srx is
non-NULL).
If a key is supplied then this will be used to secure the call instead of
the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls
secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the
control data buffer. It is entirely feasible to use this to point to a
kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged
from AF_RXRPC's knowledge and will not be seen again in association with
the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the
reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the
data buffers to be used. msg_iov may not be NULL and must point
exclusively to in-kernel virtual addresses. msg.msg_flags may be given
MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags
other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The
abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID,
struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket.
All messages that would otherwise wind up in the socket's Rx queue are
then diverted to this function. Note that care must be taken to process
the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket
and handling the incoming message, the ID assigned by the kernel utility
to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code().
The two error messages can be probed with rxrpc_kernel_get_error_number().
A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of
socket buffer manipulation functions. A data message can be determined to
be the last one in a sequence with rxrpc_kernel_is_data_last(). When a
data message has been used up, rxrpc_kernel_data_delivered() should be
called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
of. It is possible to get extra refs on all types of message for later
freeing, but this may pin the state of a call until the message is finally
freed.
(*) Accept an incoming call.
struct rxrpc_call *
rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This
function is similar to rxrpc_kernel_begin_call() and calls accepted must
be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is
returned. The caller now holds a reference on this and it must be
properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with
a BUSY message. -ENODATA is returned if there were no incoming calls.
Other errors may be returned if the call had been aborted (-ECONNABORTED)
or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to
update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.
(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message
to be received for a call (true will be returned if it does, false
if not).
The data message will be part of the reply on a client call and the
request on an incoming call. In the latter case there will be more
messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.
(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either
a local error occurred or a network error occurred.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-27 06:50:17 +08:00
|
|
|
rxrpc_queue_call(call);
|
2007-04-27 06:48:28 +08:00
|
|
|
read_unlock_bh(&call->state_lock);
|
|
|
|
}
|