12 #include <linux/slab.h>
13 #include <linux/module.h>
20 [RXRPC_CALL_CLIENT_SEND_REQUEST] =
"ClSndReq",
21 [RXRPC_CALL_CLIENT_AWAIT_REPLY] =
"ClAwtRpl",
22 [RXRPC_CALL_CLIENT_RECV_REPLY] =
"ClRcvRpl",
23 [RXRPC_CALL_CLIENT_FINAL_ACK] =
"ClFnlACK",
24 [RXRPC_CALL_SERVER_SECURING] =
"SvSecure",
25 [RXRPC_CALL_SERVER_ACCEPTING] =
"SvAccept",
26 [RXRPC_CALL_SERVER_RECV_REQUEST] =
"SvRcvReq",
27 [RXRPC_CALL_SERVER_ACK_REQUEST] =
"SvAckReq",
28 [RXRPC_CALL_SERVER_SEND_REPLY] =
"SvSndRpl",
29 [RXRPC_CALL_SERVER_AWAIT_ACK] =
"SvAwtACK",
30 [RXRPC_CALL_COMPLETE] =
"Complete",
31 [RXRPC_CALL_SERVER_BUSY] =
"SvBusy ",
32 [RXRPC_CALL_REMOTELY_ABORTED] =
"RmtAbort",
33 [RXRPC_CALL_LOCALLY_ABORTED] =
"LocAbort",
34 [RXRPC_CALL_NETWORK_ERROR] =
"NetError",
35 [RXRPC_CALL_DEAD] =
"Dead ",
41 static unsigned int rxrpc_call_max_lifetime = 60;
42 static unsigned int rxrpc_dead_call_timeout = 2;
45 static void rxrpc_call_life_expired(
unsigned long _call);
46 static void rxrpc_dead_call_expired(
unsigned long _call);
47 static void rxrpc_ack_time_expired(
unsigned long _call);
48 static void rxrpc_resend_time_expired(
unsigned long _call);
57 call = kmem_cache_zalloc(rxrpc_call_jar, gfp);
70 (
unsigned long) call);
72 (
unsigned long) call);
74 (
unsigned long) call);
76 (
unsigned long) call);
80 skb_queue_head_init(&call->
rx_queue);
102 static struct rxrpc_call *rxrpc_alloc_client_call(
117 call = rxrpc_alloc_call(gfp);
131 spin_lock(&call->
conn->trans->peer->lock);
132 list_add(&call->
error_link, &call->
conn->trans->peer->error_targets);
133 spin_unlock(&call->
conn->trans->peer->lock);
158 user_call_ID, create);
164 p = rx->
calls.rb_node;
168 if (user_call_ID < call->user_call_ID)
173 goto found_extant_call;
178 if (!create || !trans)
183 candidate = rxrpc_alloc_client_call(rx, trans, bundle, gfp);
184 if (IS_ERR(candidate)) {
185 _leave(
" = %ld", PTR_ERR(candidate));
194 pp = &rx->
calls.rb_node;
200 if (user_call_ID < call->user_call_ID)
205 goto found_extant_second;
213 rb_link_node(&call->
sock_node, parent, pp);
223 _leave(
" = %p [new]", call);
259 candidate = rxrpc_alloc_call(gfp);
261 return ERR_PTR(-
EBUSY);
264 candidate->
conn = conn;
265 candidate->
cid = hdr->
cid;
269 candidate->
state = RXRPC_CALL_SERVER_ACCEPTING;
271 candidate->
state = RXRPC_CALL_SERVER_SECURING;
284 switch (call->
state) {
285 case RXRPC_CALL_LOCALLY_ABORTED:
288 case RXRPC_CALL_REMOTELY_ABORTED:
304 if (call->
state >= RXRPC_CALL_COMPLETE) {
310 return ERR_PTR(-
EBUSY);
317 p = &conn->
calls.rb_node;
323 if (call_id < call->call_id)
325 else if (call_id > call->
call_id)
335 rb_link_node(&call->
conn_node, parent, p);
342 spin_lock(&conn->
trans->peer->lock);
344 spin_unlock(&conn->
trans->peer->lock);
366 _leave(
" = -ECONNABORTED");
372 _leave(
" = -ECONNRESET [old]");
386 _enter(
"%p,%lx", rx, user_call_ID);
392 p = rx->
calls.rb_node;
396 if (user_call_ID < call->user_call_ID)
401 goto found_extant_call;
429 spin_lock_bh(&call->
lock);
432 spin_unlock_bh(&call->
lock);
437 _debug(
"RELEASE CALL %p (%d CONN %p)", call, call->
debug_id, conn);
441 _debug(
"unlinking once-pending call %p { e=%lx f=%lx }",
445 sk_acceptq_removed(&rx->
sk);
454 spin_lock(&conn->
trans->client_lock);
466 &conn->
bundle->avail_conns);
475 &conn->
bundle->unused_conns);
488 spin_unlock(&conn->
trans->client_lock);
490 if (call->
state < RXRPC_CALL_COMPLETE &&
491 call->
state != RXRPC_CALL_CLIENT_FINAL_ACK) {
492 _debug(
"+++ ABORTING STATE %d +++\n", call->
state);
493 call->
state = RXRPC_CALL_LOCALLY_ABORTED;
502 if (!skb_queue_empty(&call->
rx_queue) ||
507 _debug(
"purge Rx queues");
509 spin_lock_bh(&call->
lock);
519 spin_unlock_bh(&call->
lock);
521 _debug(
"- zap %s %%%u #%u",
526 spin_lock_bh(&call->
lock);
528 spin_unlock_bh(&call->
lock);
545 static void rxrpc_dead_call_expired(
unsigned long _call)
561 static void rxrpc_mark_call_released(
struct rxrpc_call *call)
569 _debug(
"abort call %p", call);
598 rxrpc_mark_call_released(call);
603 rxrpc_mark_call_released(call);
607 rxrpc_mark_call_released(call);
636 static void rxrpc_cleanup_call(
struct rxrpc_call *call)
658 spin_lock(&call->
conn->trans->peer->lock);
660 spin_unlock(&call->
conn->trans->peer->lock);
669 _debug(
"kill Tx window %d",
693 sock_put(&call->
socket->sk);
711 list_del_init(&call->
link);
714 rxrpc_cleanup_call(call);
731 _debug(
"Zapping call %p", call);
733 list_del_init(&call->
link);
742 rxrpc_dead_call_expired((
unsigned long) call);
747 " Call %p still in use (%d,%d,%s,%lx,%lx)!\n",
751 call->flags, call->events);
752 if (!skb_queue_empty(&call->rx_queue))
754 if (!skb_queue_empty(&call->rx_oos_queue))
771 static void rxrpc_call_life_expired(
unsigned long _call)
791 static void rxrpc_resend_time_expired(
unsigned long _call)
808 static void rxrpc_ack_time_expired(
unsigned long _call)