]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - net/rxrpc/sendmsg.c
rxrpc: Schedule an ACK if the reply to a client call appears overdue
[mirror_ubuntu-artful-kernel.git] / net / rxrpc / sendmsg.c
CommitLineData
0b58b8a1
DH
1/* AF_RXRPC sendmsg() implementation.
2 *
3 * Copyright (C) 2007, 2016 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
14#include <linux/net.h>
15#include <linux/gfp.h>
16#include <linux/skbuff.h>
17#include <linux/export.h>
0b58b8a1
DH
18#include <net/sock.h>
19#include <net/af_rxrpc.h>
20#include "ar-internal.h"
21
3dc20f09
DH
22enum rxrpc_command {
23 RXRPC_CMD_SEND_DATA, /* send data message */
24 RXRPC_CMD_SEND_ABORT, /* request abort generation */
25 RXRPC_CMD_ACCEPT, /* [server] accept incoming call */
26 RXRPC_CMD_REJECT_BUSY, /* [server] reject a call as busy */
27};
28
0b58b8a1 29/*
df423a4a
DH
30 * wait for space to appear in the transmit/ACK window
31 * - caller holds the socket locked
0b58b8a1 32 */
df423a4a
DH
33static int rxrpc_wait_for_tx_window(struct rxrpc_sock *rx,
34 struct rxrpc_call *call,
35 long *timeo)
0b58b8a1 36{
df423a4a
DH
37 DECLARE_WAITQUEUE(myself, current);
38 int ret;
0b58b8a1 39
248f219c
DH
40 _enter(",{%u,%u,%u}",
41 call->tx_hard_ack, call->tx_top, call->tx_winsize);
0b58b8a1 42
df423a4a 43 add_wait_queue(&call->waitq, &myself);
0b58b8a1 44
df423a4a
DH
45 for (;;) {
46 set_current_state(TASK_INTERRUPTIBLE);
47 ret = 0;
248f219c 48 if (call->tx_top - call->tx_hard_ack < call->tx_winsize)
0b58b8a1 49 break;
248f219c
DH
50 if (call->state >= RXRPC_CALL_COMPLETE) {
51 ret = -call->error;
52 break;
53 }
df423a4a
DH
54 if (signal_pending(current)) {
55 ret = sock_intr_errno(*timeo);
0b58b8a1 56 break;
0b58b8a1 57 }
df423a4a 58
a124fe3e 59 trace_rxrpc_transmit(call, rxrpc_transmit_wait);
df423a4a
DH
60 release_sock(&rx->sk);
61 *timeo = schedule_timeout(*timeo);
62 lock_sock(&rx->sk);
0b58b8a1
DH
63 }
64
df423a4a
DH
65 remove_wait_queue(&call->waitq, &myself);
66 set_current_state(TASK_RUNNING);
67 _leave(" = %d", ret);
68 return ret;
0b58b8a1
DH
69}
70
71/*
248f219c 72 * Schedule an instant Tx resend.
0b58b8a1 73 */
248f219c 74static inline void rxrpc_instant_resend(struct rxrpc_call *call, int ix)
0b58b8a1 75{
248f219c
DH
76 spin_lock_bh(&call->lock);
77
78 if (call->state < RXRPC_CALL_COMPLETE) {
79 call->rxtx_annotations[ix] = RXRPC_TX_ANNO_RETRANS;
80 if (!test_and_set_bit(RXRPC_CALL_EV_RESEND, &call->events))
df423a4a 81 rxrpc_queue_call(call);
0b58b8a1 82 }
248f219c
DH
83
84 spin_unlock_bh(&call->lock);
0b58b8a1
DH
85}
86
87/*
248f219c
DH
88 * Queue a DATA packet for transmission, set the resend timeout and send the
89 * packet immediately
0b58b8a1 90 */
df423a4a
DH
91static void rxrpc_queue_packet(struct rxrpc_call *call, struct sk_buff *skb,
92 bool last)
0b58b8a1 93{
df423a4a 94 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
248f219c
DH
95 rxrpc_seq_t seq = sp->hdr.seq;
96 int ret, ix;
70790dbe 97 u8 annotation = RXRPC_TX_ANNO_UNACK;
248f219c
DH
98
99 _net("queue skb %p [%d]", skb, seq);
0b58b8a1 100
248f219c 101 ASSERTCMP(seq, ==, call->tx_top + 1);
0b58b8a1 102
70790dbe
DH
103 if (last)
104 annotation |= RXRPC_TX_ANNO_LAST;
105
b24d2891
DH
106 /* We have to set the timestamp before queueing as the retransmit
107 * algorithm can see the packet as soon as we queue it.
108 */
109 skb->tstamp = ktime_get_real();
110
248f219c 111 ix = seq & RXRPC_RXTX_BUFF_MASK;
71f3ca40 112 rxrpc_get_skb(skb, rxrpc_skb_tx_got);
70790dbe 113 call->rxtx_annotations[ix] = annotation;
df423a4a 114 smp_wmb();
248f219c
DH
115 call->rxtx_buffer[ix] = skb;
116 call->tx_top = seq;
70790dbe 117 if (last)
a124fe3e 118 trace_rxrpc_transmit(call, rxrpc_transmit_queue_last);
70790dbe 119 else
a124fe3e 120 trace_rxrpc_transmit(call, rxrpc_transmit_queue);
0b58b8a1 121
df423a4a
DH
122 if (last || call->state == RXRPC_CALL_SERVER_ACK_REQUEST) {
123 _debug("________awaiting reply/ACK__________");
124 write_lock_bh(&call->state_lock);
125 switch (call->state) {
126 case RXRPC_CALL_CLIENT_SEND_REQUEST:
127 call->state = RXRPC_CALL_CLIENT_AWAIT_REPLY;
128 break;
129 case RXRPC_CALL_SERVER_ACK_REQUEST:
130 call->state = RXRPC_CALL_SERVER_SEND_REPLY;
131 if (!last)
132 break;
133 case RXRPC_CALL_SERVER_SEND_REPLY:
134 call->state = RXRPC_CALL_SERVER_AWAIT_ACK;
135 break;
136 default:
137 break;
138 }
139 write_unlock_bh(&call->state_lock);
140 }
0b58b8a1 141
248f219c
DH
142 if (seq == 1 && rxrpc_is_client_call(call))
143 rxrpc_expose_client_call(call);
df423a4a 144
5a924b89 145 ret = rxrpc_send_data_packet(call, skb);
df423a4a
DH
146 if (ret < 0) {
147 _debug("need instant resend %d", ret);
248f219c 148 rxrpc_instant_resend(call, ix);
dfc3da44
DH
149 } else {
150 unsigned long resend_at;
151
152 resend_at = jiffies + msecs_to_jiffies(rxrpc_resend_timeout);
153
154 if (time_before(resend_at, call->resend_at)) {
155 call->resend_at = resend_at;
fc7ab6d2 156 rxrpc_set_timer(call, rxrpc_timer_set_for_send);
dfc3da44 157 }
df423a4a
DH
158 }
159
71f3ca40 160 rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
df423a4a 161 _leave("");
0b58b8a1
DH
162}
163
df423a4a
DH
164/*
165 * send data through a socket
166 * - must be called in process context
0b58b8a1 167 * - caller holds the socket locked
0b58b8a1 168 */
df423a4a
DH
169static int rxrpc_send_data(struct rxrpc_sock *rx,
170 struct rxrpc_call *call,
171 struct msghdr *msg, size_t len)
0b58b8a1 172{
df423a4a
DH
173 struct rxrpc_skb_priv *sp;
174 struct sk_buff *skb;
175 struct sock *sk = &rx->sk;
176 long timeo;
177 bool more;
178 int ret, copied;
0b58b8a1 179
df423a4a 180 timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
0b58b8a1 181
df423a4a
DH
182 /* this should be in poll */
183 sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
0b58b8a1 184
df423a4a
DH
185 if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
186 return -EPIPE;
0b58b8a1 187
df423a4a 188 more = msg->msg_flags & MSG_MORE;
0b58b8a1 189
df423a4a
DH
190 skb = call->tx_pending;
191 call->tx_pending = NULL;
71f3ca40 192 rxrpc_see_skb(skb, rxrpc_skb_tx_seen);
0b58b8a1 193
df423a4a
DH
194 copied = 0;
195 do {
7aa51da7
DH
196 /* Check to see if there's a ping ACK to reply to. */
197 if (call->ackr_reason == RXRPC_ACK_PING_RESPONSE)
198 rxrpc_send_call_packet(call, RXRPC_PACKET_TYPE_ACK);
199
df423a4a
DH
200 if (!skb) {
201 size_t size, chunk, max, space;
0b58b8a1 202
df423a4a 203 _debug("alloc");
0b58b8a1 204
248f219c
DH
205 if (call->tx_top - call->tx_hard_ack >=
206 call->tx_winsize) {
df423a4a
DH
207 ret = -EAGAIN;
208 if (msg->msg_flags & MSG_DONTWAIT)
209 goto maybe_error;
210 ret = rxrpc_wait_for_tx_window(rx, call,
211 &timeo);
212 if (ret < 0)
213 goto maybe_error;
214 }
0b58b8a1 215
182f5056 216 max = RXRPC_JUMBO_DATALEN;
df423a4a
DH
217 max -= call->conn->security_size;
218 max &= ~(call->conn->size_align - 1UL);
0b58b8a1 219
df423a4a
DH
220 chunk = max;
221 if (chunk > msg_data_left(msg) && !more)
222 chunk = msg_data_left(msg);
0b58b8a1 223
df423a4a
DH
224 space = chunk + call->conn->size_align;
225 space &= ~(call->conn->size_align - 1UL);
0b58b8a1 226
5a924b89 227 size = space + call->conn->security_size;
0b58b8a1 228
df423a4a 229 _debug("SIZE: %zu/%zu/%zu", chunk, space, size);
0b58b8a1 230
df423a4a
DH
231 /* create a buffer that we can retain until it's ACK'd */
232 skb = sock_alloc_send_skb(
233 sk, size, msg->msg_flags & MSG_DONTWAIT, &ret);
234 if (!skb)
235 goto maybe_error;
0b58b8a1 236
71f3ca40 237 rxrpc_new_skb(skb, rxrpc_skb_tx_new);
0b58b8a1 238
df423a4a 239 _debug("ALLOC SEND %p", skb);
0b58b8a1 240
df423a4a 241 ASSERTCMP(skb->mark, ==, 0);
0b58b8a1 242
5a924b89
DH
243 _debug("HS: %u", call->conn->security_size);
244 skb_reserve(skb, call->conn->security_size);
245 skb->len += call->conn->security_size;
0b58b8a1 246
df423a4a
DH
247 sp = rxrpc_skb(skb);
248 sp->remain = chunk;
249 if (sp->remain > skb_tailroom(skb))
250 sp->remain = skb_tailroom(skb);
0b58b8a1 251
df423a4a
DH
252 _net("skb: hr %d, tr %d, hl %d, rm %d",
253 skb_headroom(skb),
254 skb_tailroom(skb),
255 skb_headlen(skb),
256 sp->remain);
0b58b8a1 257
df423a4a
DH
258 skb->ip_summed = CHECKSUM_UNNECESSARY;
259 }
0b58b8a1 260
df423a4a
DH
261 _debug("append");
262 sp = rxrpc_skb(skb);
0b58b8a1 263
df423a4a
DH
264 /* append next segment of data to the current buffer */
265 if (msg_data_left(msg) > 0) {
266 int copy = skb_tailroom(skb);
267 ASSERTCMP(copy, >, 0);
268 if (copy > msg_data_left(msg))
269 copy = msg_data_left(msg);
270 if (copy > sp->remain)
271 copy = sp->remain;
0b58b8a1 272
df423a4a
DH
273 _debug("add");
274 ret = skb_add_data(skb, &msg->msg_iter, copy);
275 _debug("added");
276 if (ret < 0)
277 goto efault;
278 sp->remain -= copy;
279 skb->mark += copy;
280 copied += copy;
0b58b8a1
DH
281 }
282
df423a4a
DH
283 /* check for the far side aborting the call or a network error
284 * occurring */
285 if (call->state == RXRPC_CALL_COMPLETE)
286 goto call_terminated;
0b58b8a1 287
df423a4a
DH
288 /* add the packet to the send queue if it's now full */
289 if (sp->remain <= 0 ||
290 (msg_data_left(msg) == 0 && !more)) {
291 struct rxrpc_connection *conn = call->conn;
292 uint32_t seq;
293 size_t pad;
0b58b8a1 294
df423a4a
DH
295 /* pad out if we're using security */
296 if (conn->security_ix) {
297 pad = conn->security_size + skb->mark;
298 pad = conn->size_align - pad;
299 pad &= conn->size_align - 1;
300 _debug("pad %zu", pad);
301 if (pad)
302 memset(skb_put(skb, pad), 0, pad);
303 }
0b58b8a1 304
248f219c 305 seq = call->tx_top + 1;
0b58b8a1 306
df423a4a 307 sp->hdr.seq = seq;
df423a4a 308 sp->hdr._rsvd = 0;
5a924b89 309 sp->hdr.flags = conn->out_clientflag;
0b58b8a1 310
df423a4a
DH
311 if (msg_data_left(msg) == 0 && !more)
312 sp->hdr.flags |= RXRPC_LAST_PACKET;
248f219c
DH
313 else if (call->tx_top - call->tx_hard_ack <
314 call->tx_winsize)
df423a4a 315 sp->hdr.flags |= RXRPC_MORE_PACKETS;
0b58b8a1 316
df423a4a 317 ret = conn->security->secure_packet(
5a924b89 318 call, skb, skb->mark, skb->head);
df423a4a
DH
319 if (ret < 0)
320 goto out;
0b58b8a1 321
df423a4a
DH
322 rxrpc_queue_packet(call, skb, !msg_data_left(msg) && !more);
323 skb = NULL;
324 }
325 } while (msg_data_left(msg) > 0);
0b58b8a1 326
df423a4a
DH
327success:
328 ret = copied;
329out:
330 call->tx_pending = skb;
331 _leave(" = %d", ret);
332 return ret;
0b58b8a1 333
df423a4a 334call_terminated:
71f3ca40 335 rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
df423a4a 336 _leave(" = %d", -call->error);
248f219c 337 return -call->error;
0b58b8a1 338
df423a4a
DH
339maybe_error:
340 if (copied)
341 goto success;
342 goto out;
0b58b8a1 343
df423a4a
DH
344efault:
345 ret = -EFAULT;
346 goto out;
0b58b8a1
DH
347}
348
349/*
df423a4a 350 * extract control messages from the sendmsg() control buffer
0b58b8a1 351 */
df423a4a
DH
352static int rxrpc_sendmsg_cmsg(struct msghdr *msg,
353 unsigned long *user_call_ID,
354 enum rxrpc_command *command,
355 u32 *abort_code,
356 bool *_exclusive)
0b58b8a1 357{
df423a4a
DH
358 struct cmsghdr *cmsg;
359 bool got_user_ID = false;
360 int len;
0b58b8a1 361
df423a4a 362 *command = RXRPC_CMD_SEND_DATA;
0b58b8a1 363
df423a4a
DH
364 if (msg->msg_controllen == 0)
365 return -EINVAL;
0b58b8a1 366
df423a4a
DH
367 for_each_cmsghdr(cmsg, msg) {
368 if (!CMSG_OK(msg, cmsg))
369 return -EINVAL;
0b58b8a1 370
df423a4a
DH
371 len = cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr));
372 _debug("CMSG %d, %d, %d",
373 cmsg->cmsg_level, cmsg->cmsg_type, len);
0b58b8a1 374
df423a4a
DH
375 if (cmsg->cmsg_level != SOL_RXRPC)
376 continue;
0b58b8a1 377
df423a4a
DH
378 switch (cmsg->cmsg_type) {
379 case RXRPC_USER_CALL_ID:
380 if (msg->msg_flags & MSG_CMSG_COMPAT) {
381 if (len != sizeof(u32))
382 return -EINVAL;
383 *user_call_ID = *(u32 *) CMSG_DATA(cmsg);
384 } else {
385 if (len != sizeof(unsigned long))
386 return -EINVAL;
387 *user_call_ID = *(unsigned long *)
388 CMSG_DATA(cmsg);
389 }
390 _debug("User Call ID %lx", *user_call_ID);
391 got_user_ID = true;
392 break;
0b58b8a1 393
df423a4a
DH
394 case RXRPC_ABORT:
395 if (*command != RXRPC_CMD_SEND_DATA)
396 return -EINVAL;
397 *command = RXRPC_CMD_SEND_ABORT;
398 if (len != sizeof(*abort_code))
399 return -EINVAL;
400 *abort_code = *(unsigned int *) CMSG_DATA(cmsg);
401 _debug("Abort %x", *abort_code);
402 if (*abort_code == 0)
403 return -EINVAL;
404 break;
0b58b8a1 405
df423a4a
DH
406 case RXRPC_ACCEPT:
407 if (*command != RXRPC_CMD_SEND_DATA)
408 return -EINVAL;
409 *command = RXRPC_CMD_ACCEPT;
410 if (len != 0)
411 return -EINVAL;
412 break;
0b58b8a1 413
df423a4a
DH
414 case RXRPC_EXCLUSIVE_CALL:
415 *_exclusive = true;
416 if (len != 0)
417 return -EINVAL;
418 break;
419 default:
420 return -EINVAL;
421 }
422 }
0b58b8a1 423
df423a4a
DH
424 if (!got_user_ID)
425 return -EINVAL;
426 _leave(" = 0");
427 return 0;
428}
0b58b8a1 429
df423a4a
DH
430/*
431 * Create a new client call for sendmsg().
432 */
433static struct rxrpc_call *
434rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,
435 unsigned long user_call_ID, bool exclusive)
436{
437 struct rxrpc_conn_parameters cp;
438 struct rxrpc_call *call;
439 struct key *key;
0b58b8a1 440
df423a4a 441 DECLARE_SOCKADDR(struct sockaddr_rxrpc *, srx, msg->msg_name);
0b58b8a1 442
df423a4a 443 _enter("");
0b58b8a1 444
df423a4a
DH
445 if (!msg->msg_name)
446 return ERR_PTR(-EDESTADDRREQ);
0b58b8a1 447
df423a4a
DH
448 key = rx->key;
449 if (key && !rx->key->payload.data[0])
450 key = NULL;
0b58b8a1 451
df423a4a
DH
452 memset(&cp, 0, sizeof(cp));
453 cp.local = rx->local;
454 cp.key = rx->key;
455 cp.security_level = rx->min_sec_level;
456 cp.exclusive = rx->exclusive | exclusive;
457 cp.service_id = srx->srx_service;
458 call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, GFP_KERNEL);
0b58b8a1 459
df423a4a
DH
460 _leave(" = %p\n", call);
461 return call;
462}
0b58b8a1 463
df423a4a
DH
464/*
465 * send a message forming part of a client call through an RxRPC socket
466 * - caller holds the socket locked
467 * - the socket may be either a client socket or a server socket
468 */
469int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
470{
471 enum rxrpc_command cmd;
472 struct rxrpc_call *call;
473 unsigned long user_call_ID = 0;
474 bool exclusive = false;
475 u32 abort_code = 0;
476 int ret;
0b58b8a1 477
df423a4a 478 _enter("");
0b58b8a1 479
df423a4a
DH
480 ret = rxrpc_sendmsg_cmsg(msg, &user_call_ID, &cmd, &abort_code,
481 &exclusive);
482 if (ret < 0)
483 return ret;
0b58b8a1 484
df423a4a
DH
485 if (cmd == RXRPC_CMD_ACCEPT) {
486 if (rx->sk.sk_state != RXRPC_SERVER_LISTENING)
487 return -EINVAL;
488 call = rxrpc_accept_call(rx, user_call_ID, NULL);
489 if (IS_ERR(call))
490 return PTR_ERR(call);
fff72429 491 rxrpc_put_call(call, rxrpc_call_put);
df423a4a
DH
492 return 0;
493 }
0b58b8a1 494
df423a4a
DH
495 call = rxrpc_find_call_by_user_ID(rx, user_call_ID);
496 if (!call) {
497 if (cmd != RXRPC_CMD_SEND_DATA)
498 return -EBADSLT;
499 call = rxrpc_new_client_call_for_sendmsg(rx, msg, user_call_ID,
500 exclusive);
501 if (IS_ERR(call))
502 return PTR_ERR(call);
503 }
0b58b8a1 504
df423a4a
DH
505 _debug("CALL %d USR %lx ST %d on CONN %p",
506 call->debug_id, call->user_call_ID, call->state, call->conn);
0b58b8a1 507
df423a4a
DH
508 if (call->state >= RXRPC_CALL_COMPLETE) {
509 /* it's too late for this call */
510 ret = -ESHUTDOWN;
511 } else if (cmd == RXRPC_CMD_SEND_ABORT) {
df423a4a 512 ret = 0;
248f219c
DH
513 if (rxrpc_abort_call("CMD", call, 0, abort_code, ECONNABORTED))
514 ret = rxrpc_send_call_packet(call,
515 RXRPC_PACKET_TYPE_ABORT);
df423a4a
DH
516 } else if (cmd != RXRPC_CMD_SEND_DATA) {
517 ret = -EINVAL;
518 } else if (rxrpc_is_client_call(call) &&
519 call->state != RXRPC_CALL_CLIENT_SEND_REQUEST) {
520 /* request phase complete for this client call */
521 ret = -EPROTO;
522 } else if (rxrpc_is_service_call(call) &&
523 call->state != RXRPC_CALL_SERVER_ACK_REQUEST &&
524 call->state != RXRPC_CALL_SERVER_SEND_REPLY) {
525 /* Reply phase not begun or not complete for service call. */
526 ret = -EPROTO;
527 } else {
528 ret = rxrpc_send_data(rx, call, msg, len);
529 }
0b58b8a1 530
fff72429 531 rxrpc_put_call(call, rxrpc_call_put);
df423a4a
DH
532 _leave(" = %d", ret);
533 return ret;
534}
0b58b8a1 535
df423a4a
DH
536/**
537 * rxrpc_kernel_send_data - Allow a kernel service to send data on a call
538 * @sock: The socket the call is on
539 * @call: The call to send data through
540 * @msg: The data to send
541 * @len: The amount of data to send
542 *
543 * Allow a kernel service to send data on a call. The call must be in an state
544 * appropriate to sending data. No control data should be supplied in @msg,
545 * nor should an address be supplied. MSG_MORE should be flagged if there's
546 * more data to come, otherwise this data will end the transmission phase.
547 */
548int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
549 struct msghdr *msg, size_t len)
550{
551 int ret;
0b58b8a1 552
df423a4a 553 _enter("{%d,%s},", call->debug_id, rxrpc_call_states[call->state]);
0b58b8a1 554
df423a4a
DH
555 ASSERTCMP(msg->msg_name, ==, NULL);
556 ASSERTCMP(msg->msg_control, ==, NULL);
0b58b8a1 557
df423a4a 558 lock_sock(sock->sk);
0b58b8a1 559
df423a4a
DH
560 _debug("CALL %d USR %lx ST %d on CONN %p",
561 call->debug_id, call->user_call_ID, call->state, call->conn);
0b58b8a1 562
df423a4a
DH
563 if (call->state >= RXRPC_CALL_COMPLETE) {
564 ret = -ESHUTDOWN; /* it's too late for this call */
565 } else if (call->state != RXRPC_CALL_CLIENT_SEND_REQUEST &&
566 call->state != RXRPC_CALL_SERVER_ACK_REQUEST &&
567 call->state != RXRPC_CALL_SERVER_SEND_REPLY) {
568 ret = -EPROTO; /* request phase complete for this client call */
569 } else {
570 ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len);
571 }
572
573 release_sock(sock->sk);
0b58b8a1
DH
574 _leave(" = %d", ret);
575 return ret;
df423a4a
DH
576}
577EXPORT_SYMBOL(rxrpc_kernel_send_data);
0b58b8a1 578
df423a4a
DH
579/**
580 * rxrpc_kernel_abort_call - Allow a kernel service to abort a call
581 * @sock: The socket the call is on
582 * @call: The call to be aborted
583 * @abort_code: The abort code to stick into the ABORT packet
5a42976d
DH
584 * @error: Local error value
585 * @why: 3-char string indicating why.
df423a4a
DH
586 *
587 * Allow a kernel service to abort a call, if it's still in an abortable state.
588 */
589void rxrpc_kernel_abort_call(struct socket *sock, struct rxrpc_call *call,
5a42976d 590 u32 abort_code, int error, const char *why)
df423a4a 591{
5a42976d 592 _enter("{%d},%d,%d,%s", call->debug_id, abort_code, error, why);
0b58b8a1 593
df423a4a 594 lock_sock(sock->sk);
0b58b8a1 595
248f219c
DH
596 if (rxrpc_abort_call(why, call, 0, abort_code, error))
597 rxrpc_send_call_packet(call, RXRPC_PACKET_TYPE_ABORT);
df423a4a
DH
598
599 release_sock(sock->sk);
600 _leave("");
0b58b8a1 601}
df423a4a
DH
602
603EXPORT_SYMBOL(rxrpc_kernel_abort_call);