]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - net/rxrpc/sendmsg.c
rxrpc: Use before_eq() and friends to compare serial numbers
[mirror_ubuntu-zesty-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;
97
98 _net("queue skb %p [%d]", skb, seq);
0b58b8a1 99
248f219c 100 ASSERTCMP(seq, ==, call->tx_top + 1);
0b58b8a1 101
b24d2891
DH
102 /* We have to set the timestamp before queueing as the retransmit
103 * algorithm can see the packet as soon as we queue it.
104 */
105 skb->tstamp = ktime_get_real();
106
248f219c 107 ix = seq & RXRPC_RXTX_BUFF_MASK;
71f3ca40 108 rxrpc_get_skb(skb, rxrpc_skb_tx_got);
248f219c 109 call->rxtx_annotations[ix] = RXRPC_TX_ANNO_UNACK;
df423a4a 110 smp_wmb();
248f219c
DH
111 call->rxtx_buffer[ix] = skb;
112 call->tx_top = seq;
a124fe3e 113 if (last) {
248f219c 114 set_bit(RXRPC_CALL_TX_LAST, &call->flags);
a124fe3e
DH
115 trace_rxrpc_transmit(call, rxrpc_transmit_queue_last);
116 } else if (sp->hdr.flags & RXRPC_REQUEST_ACK) {
117 trace_rxrpc_transmit(call, rxrpc_transmit_queue_reqack);
118 } else {
119 trace_rxrpc_transmit(call, rxrpc_transmit_queue);
120 }
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);
df423a4a
DH
149 }
150
71f3ca40 151 rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
df423a4a 152 _leave("");
0b58b8a1
DH
153}
154
df423a4a
DH
155/*
156 * send data through a socket
157 * - must be called in process context
0b58b8a1 158 * - caller holds the socket locked
0b58b8a1 159 */
df423a4a
DH
160static int rxrpc_send_data(struct rxrpc_sock *rx,
161 struct rxrpc_call *call,
162 struct msghdr *msg, size_t len)
0b58b8a1 163{
df423a4a
DH
164 struct rxrpc_skb_priv *sp;
165 struct sk_buff *skb;
166 struct sock *sk = &rx->sk;
167 long timeo;
168 bool more;
169 int ret, copied;
0b58b8a1 170
df423a4a 171 timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
0b58b8a1 172
df423a4a
DH
173 /* this should be in poll */
174 sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
0b58b8a1 175
df423a4a
DH
176 if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
177 return -EPIPE;
0b58b8a1 178
df423a4a 179 more = msg->msg_flags & MSG_MORE;
0b58b8a1 180
df423a4a
DH
181 skb = call->tx_pending;
182 call->tx_pending = NULL;
71f3ca40 183 rxrpc_see_skb(skb, rxrpc_skb_tx_seen);
0b58b8a1 184
df423a4a
DH
185 copied = 0;
186 do {
7aa51da7
DH
187 /* Check to see if there's a ping ACK to reply to. */
188 if (call->ackr_reason == RXRPC_ACK_PING_RESPONSE)
189 rxrpc_send_call_packet(call, RXRPC_PACKET_TYPE_ACK);
190
df423a4a
DH
191 if (!skb) {
192 size_t size, chunk, max, space;
0b58b8a1 193
df423a4a 194 _debug("alloc");
0b58b8a1 195
248f219c
DH
196 if (call->tx_top - call->tx_hard_ack >=
197 call->tx_winsize) {
df423a4a
DH
198 ret = -EAGAIN;
199 if (msg->msg_flags & MSG_DONTWAIT)
200 goto maybe_error;
201 ret = rxrpc_wait_for_tx_window(rx, call,
202 &timeo);
203 if (ret < 0)
204 goto maybe_error;
205 }
0b58b8a1 206
182f5056 207 max = RXRPC_JUMBO_DATALEN;
df423a4a
DH
208 max -= call->conn->security_size;
209 max &= ~(call->conn->size_align - 1UL);
0b58b8a1 210
df423a4a
DH
211 chunk = max;
212 if (chunk > msg_data_left(msg) && !more)
213 chunk = msg_data_left(msg);
0b58b8a1 214
df423a4a
DH
215 space = chunk + call->conn->size_align;
216 space &= ~(call->conn->size_align - 1UL);
0b58b8a1 217
5a924b89 218 size = space + call->conn->security_size;
0b58b8a1 219
df423a4a 220 _debug("SIZE: %zu/%zu/%zu", chunk, space, size);
0b58b8a1 221
df423a4a
DH
222 /* create a buffer that we can retain until it's ACK'd */
223 skb = sock_alloc_send_skb(
224 sk, size, msg->msg_flags & MSG_DONTWAIT, &ret);
225 if (!skb)
226 goto maybe_error;
0b58b8a1 227
71f3ca40 228 rxrpc_new_skb(skb, rxrpc_skb_tx_new);
0b58b8a1 229
df423a4a 230 _debug("ALLOC SEND %p", skb);
0b58b8a1 231
df423a4a 232 ASSERTCMP(skb->mark, ==, 0);
0b58b8a1 233
5a924b89
DH
234 _debug("HS: %u", call->conn->security_size);
235 skb_reserve(skb, call->conn->security_size);
236 skb->len += call->conn->security_size;
0b58b8a1 237
df423a4a
DH
238 sp = rxrpc_skb(skb);
239 sp->remain = chunk;
240 if (sp->remain > skb_tailroom(skb))
241 sp->remain = skb_tailroom(skb);
0b58b8a1 242
df423a4a
DH
243 _net("skb: hr %d, tr %d, hl %d, rm %d",
244 skb_headroom(skb),
245 skb_tailroom(skb),
246 skb_headlen(skb),
247 sp->remain);
0b58b8a1 248
df423a4a
DH
249 skb->ip_summed = CHECKSUM_UNNECESSARY;
250 }
0b58b8a1 251
df423a4a
DH
252 _debug("append");
253 sp = rxrpc_skb(skb);
0b58b8a1 254
df423a4a
DH
255 /* append next segment of data to the current buffer */
256 if (msg_data_left(msg) > 0) {
257 int copy = skb_tailroom(skb);
258 ASSERTCMP(copy, >, 0);
259 if (copy > msg_data_left(msg))
260 copy = msg_data_left(msg);
261 if (copy > sp->remain)
262 copy = sp->remain;
0b58b8a1 263
df423a4a
DH
264 _debug("add");
265 ret = skb_add_data(skb, &msg->msg_iter, copy);
266 _debug("added");
267 if (ret < 0)
268 goto efault;
269 sp->remain -= copy;
270 skb->mark += copy;
271 copied += copy;
0b58b8a1
DH
272 }
273
df423a4a
DH
274 /* check for the far side aborting the call or a network error
275 * occurring */
276 if (call->state == RXRPC_CALL_COMPLETE)
277 goto call_terminated;
0b58b8a1 278
df423a4a
DH
279 /* add the packet to the send queue if it's now full */
280 if (sp->remain <= 0 ||
281 (msg_data_left(msg) == 0 && !more)) {
282 struct rxrpc_connection *conn = call->conn;
283 uint32_t seq;
284 size_t pad;
0b58b8a1 285
df423a4a
DH
286 /* pad out if we're using security */
287 if (conn->security_ix) {
288 pad = conn->security_size + skb->mark;
289 pad = conn->size_align - pad;
290 pad &= conn->size_align - 1;
291 _debug("pad %zu", pad);
292 if (pad)
293 memset(skb_put(skb, pad), 0, pad);
294 }
0b58b8a1 295
248f219c 296 seq = call->tx_top + 1;
0b58b8a1 297
df423a4a 298 sp->hdr.seq = seq;
df423a4a 299 sp->hdr._rsvd = 0;
5a924b89 300 sp->hdr.flags = conn->out_clientflag;
0b58b8a1 301
df423a4a
DH
302 if (msg_data_left(msg) == 0 && !more)
303 sp->hdr.flags |= RXRPC_LAST_PACKET;
248f219c
DH
304 else if (call->tx_top - call->tx_hard_ack <
305 call->tx_winsize)
df423a4a 306 sp->hdr.flags |= RXRPC_MORE_PACKETS;
0b58b8a1 307
df423a4a 308 ret = conn->security->secure_packet(
5a924b89 309 call, skb, skb->mark, skb->head);
df423a4a
DH
310 if (ret < 0)
311 goto out;
0b58b8a1 312
df423a4a
DH
313 rxrpc_queue_packet(call, skb, !msg_data_left(msg) && !more);
314 skb = NULL;
315 }
316 } while (msg_data_left(msg) > 0);
0b58b8a1 317
df423a4a
DH
318success:
319 ret = copied;
320out:
321 call->tx_pending = skb;
322 _leave(" = %d", ret);
323 return ret;
0b58b8a1 324
df423a4a 325call_terminated:
71f3ca40 326 rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
df423a4a 327 _leave(" = %d", -call->error);
248f219c 328 return -call->error;
0b58b8a1 329
df423a4a
DH
330maybe_error:
331 if (copied)
332 goto success;
333 goto out;
0b58b8a1 334
df423a4a
DH
335efault:
336 ret = -EFAULT;
337 goto out;
0b58b8a1
DH
338}
339
340/*
df423a4a 341 * extract control messages from the sendmsg() control buffer
0b58b8a1 342 */
df423a4a
DH
343static int rxrpc_sendmsg_cmsg(struct msghdr *msg,
344 unsigned long *user_call_ID,
345 enum rxrpc_command *command,
346 u32 *abort_code,
347 bool *_exclusive)
0b58b8a1 348{
df423a4a
DH
349 struct cmsghdr *cmsg;
350 bool got_user_ID = false;
351 int len;
0b58b8a1 352
df423a4a 353 *command = RXRPC_CMD_SEND_DATA;
0b58b8a1 354
df423a4a
DH
355 if (msg->msg_controllen == 0)
356 return -EINVAL;
0b58b8a1 357
df423a4a
DH
358 for_each_cmsghdr(cmsg, msg) {
359 if (!CMSG_OK(msg, cmsg))
360 return -EINVAL;
0b58b8a1 361
df423a4a
DH
362 len = cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr));
363 _debug("CMSG %d, %d, %d",
364 cmsg->cmsg_level, cmsg->cmsg_type, len);
0b58b8a1 365
df423a4a
DH
366 if (cmsg->cmsg_level != SOL_RXRPC)
367 continue;
0b58b8a1 368
df423a4a
DH
369 switch (cmsg->cmsg_type) {
370 case RXRPC_USER_CALL_ID:
371 if (msg->msg_flags & MSG_CMSG_COMPAT) {
372 if (len != sizeof(u32))
373 return -EINVAL;
374 *user_call_ID = *(u32 *) CMSG_DATA(cmsg);
375 } else {
376 if (len != sizeof(unsigned long))
377 return -EINVAL;
378 *user_call_ID = *(unsigned long *)
379 CMSG_DATA(cmsg);
380 }
381 _debug("User Call ID %lx", *user_call_ID);
382 got_user_ID = true;
383 break;
0b58b8a1 384
df423a4a
DH
385 case RXRPC_ABORT:
386 if (*command != RXRPC_CMD_SEND_DATA)
387 return -EINVAL;
388 *command = RXRPC_CMD_SEND_ABORT;
389 if (len != sizeof(*abort_code))
390 return -EINVAL;
391 *abort_code = *(unsigned int *) CMSG_DATA(cmsg);
392 _debug("Abort %x", *abort_code);
393 if (*abort_code == 0)
394 return -EINVAL;
395 break;
0b58b8a1 396
df423a4a
DH
397 case RXRPC_ACCEPT:
398 if (*command != RXRPC_CMD_SEND_DATA)
399 return -EINVAL;
400 *command = RXRPC_CMD_ACCEPT;
401 if (len != 0)
402 return -EINVAL;
403 break;
0b58b8a1 404
df423a4a
DH
405 case RXRPC_EXCLUSIVE_CALL:
406 *_exclusive = true;
407 if (len != 0)
408 return -EINVAL;
409 break;
410 default:
411 return -EINVAL;
412 }
413 }
0b58b8a1 414
df423a4a
DH
415 if (!got_user_ID)
416 return -EINVAL;
417 _leave(" = 0");
418 return 0;
419}
0b58b8a1 420
df423a4a
DH
421/*
422 * Create a new client call for sendmsg().
423 */
424static struct rxrpc_call *
425rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,
426 unsigned long user_call_ID, bool exclusive)
427{
428 struct rxrpc_conn_parameters cp;
429 struct rxrpc_call *call;
430 struct key *key;
0b58b8a1 431
df423a4a 432 DECLARE_SOCKADDR(struct sockaddr_rxrpc *, srx, msg->msg_name);
0b58b8a1 433
df423a4a 434 _enter("");
0b58b8a1 435
df423a4a
DH
436 if (!msg->msg_name)
437 return ERR_PTR(-EDESTADDRREQ);
0b58b8a1 438
df423a4a
DH
439 key = rx->key;
440 if (key && !rx->key->payload.data[0])
441 key = NULL;
0b58b8a1 442
df423a4a
DH
443 memset(&cp, 0, sizeof(cp));
444 cp.local = rx->local;
445 cp.key = rx->key;
446 cp.security_level = rx->min_sec_level;
447 cp.exclusive = rx->exclusive | exclusive;
448 cp.service_id = srx->srx_service;
449 call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, GFP_KERNEL);
0b58b8a1 450
df423a4a
DH
451 _leave(" = %p\n", call);
452 return call;
453}
0b58b8a1 454
df423a4a
DH
455/*
456 * send a message forming part of a client call through an RxRPC socket
457 * - caller holds the socket locked
458 * - the socket may be either a client socket or a server socket
459 */
460int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
461{
462 enum rxrpc_command cmd;
463 struct rxrpc_call *call;
464 unsigned long user_call_ID = 0;
465 bool exclusive = false;
466 u32 abort_code = 0;
467 int ret;
0b58b8a1 468
df423a4a 469 _enter("");
0b58b8a1 470
df423a4a
DH
471 ret = rxrpc_sendmsg_cmsg(msg, &user_call_ID, &cmd, &abort_code,
472 &exclusive);
473 if (ret < 0)
474 return ret;
0b58b8a1 475
df423a4a
DH
476 if (cmd == RXRPC_CMD_ACCEPT) {
477 if (rx->sk.sk_state != RXRPC_SERVER_LISTENING)
478 return -EINVAL;
479 call = rxrpc_accept_call(rx, user_call_ID, NULL);
480 if (IS_ERR(call))
481 return PTR_ERR(call);
fff72429 482 rxrpc_put_call(call, rxrpc_call_put);
df423a4a
DH
483 return 0;
484 }
0b58b8a1 485
df423a4a
DH
486 call = rxrpc_find_call_by_user_ID(rx, user_call_ID);
487 if (!call) {
488 if (cmd != RXRPC_CMD_SEND_DATA)
489 return -EBADSLT;
490 call = rxrpc_new_client_call_for_sendmsg(rx, msg, user_call_ID,
491 exclusive);
492 if (IS_ERR(call))
493 return PTR_ERR(call);
494 }
0b58b8a1 495
df423a4a
DH
496 _debug("CALL %d USR %lx ST %d on CONN %p",
497 call->debug_id, call->user_call_ID, call->state, call->conn);
0b58b8a1 498
df423a4a
DH
499 if (call->state >= RXRPC_CALL_COMPLETE) {
500 /* it's too late for this call */
501 ret = -ESHUTDOWN;
502 } else if (cmd == RXRPC_CMD_SEND_ABORT) {
df423a4a 503 ret = 0;
248f219c
DH
504 if (rxrpc_abort_call("CMD", call, 0, abort_code, ECONNABORTED))
505 ret = rxrpc_send_call_packet(call,
506 RXRPC_PACKET_TYPE_ABORT);
df423a4a
DH
507 } else if (cmd != RXRPC_CMD_SEND_DATA) {
508 ret = -EINVAL;
509 } else if (rxrpc_is_client_call(call) &&
510 call->state != RXRPC_CALL_CLIENT_SEND_REQUEST) {
511 /* request phase complete for this client call */
512 ret = -EPROTO;
513 } else if (rxrpc_is_service_call(call) &&
514 call->state != RXRPC_CALL_SERVER_ACK_REQUEST &&
515 call->state != RXRPC_CALL_SERVER_SEND_REPLY) {
516 /* Reply phase not begun or not complete for service call. */
517 ret = -EPROTO;
518 } else {
519 ret = rxrpc_send_data(rx, call, msg, len);
520 }
0b58b8a1 521
fff72429 522 rxrpc_put_call(call, rxrpc_call_put);
df423a4a
DH
523 _leave(" = %d", ret);
524 return ret;
525}
0b58b8a1 526
df423a4a
DH
527/**
528 * rxrpc_kernel_send_data - Allow a kernel service to send data on a call
529 * @sock: The socket the call is on
530 * @call: The call to send data through
531 * @msg: The data to send
532 * @len: The amount of data to send
533 *
534 * Allow a kernel service to send data on a call. The call must be in an state
535 * appropriate to sending data. No control data should be supplied in @msg,
536 * nor should an address be supplied. MSG_MORE should be flagged if there's
537 * more data to come, otherwise this data will end the transmission phase.
538 */
539int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
540 struct msghdr *msg, size_t len)
541{
542 int ret;
0b58b8a1 543
df423a4a 544 _enter("{%d,%s},", call->debug_id, rxrpc_call_states[call->state]);
0b58b8a1 545
df423a4a
DH
546 ASSERTCMP(msg->msg_name, ==, NULL);
547 ASSERTCMP(msg->msg_control, ==, NULL);
0b58b8a1 548
df423a4a 549 lock_sock(sock->sk);
0b58b8a1 550
df423a4a
DH
551 _debug("CALL %d USR %lx ST %d on CONN %p",
552 call->debug_id, call->user_call_ID, call->state, call->conn);
0b58b8a1 553
df423a4a
DH
554 if (call->state >= RXRPC_CALL_COMPLETE) {
555 ret = -ESHUTDOWN; /* it's too late for this call */
556 } else if (call->state != RXRPC_CALL_CLIENT_SEND_REQUEST &&
557 call->state != RXRPC_CALL_SERVER_ACK_REQUEST &&
558 call->state != RXRPC_CALL_SERVER_SEND_REPLY) {
559 ret = -EPROTO; /* request phase complete for this client call */
560 } else {
561 ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len);
562 }
563
564 release_sock(sock->sk);
0b58b8a1
DH
565 _leave(" = %d", ret);
566 return ret;
df423a4a
DH
567}
568EXPORT_SYMBOL(rxrpc_kernel_send_data);
0b58b8a1 569
df423a4a
DH
570/**
571 * rxrpc_kernel_abort_call - Allow a kernel service to abort a call
572 * @sock: The socket the call is on
573 * @call: The call to be aborted
574 * @abort_code: The abort code to stick into the ABORT packet
5a42976d
DH
575 * @error: Local error value
576 * @why: 3-char string indicating why.
df423a4a
DH
577 *
578 * Allow a kernel service to abort a call, if it's still in an abortable state.
579 */
580void rxrpc_kernel_abort_call(struct socket *sock, struct rxrpc_call *call,
5a42976d 581 u32 abort_code, int error, const char *why)
df423a4a 582{
5a42976d 583 _enter("{%d},%d,%d,%s", call->debug_id, abort_code, error, why);
0b58b8a1 584
df423a4a 585 lock_sock(sock->sk);
0b58b8a1 586
248f219c
DH
587 if (rxrpc_abort_call(why, call, 0, abort_code, error))
588 rxrpc_send_call_packet(call, RXRPC_PACKET_TYPE_ABORT);
df423a4a
DH
589
590 release_sock(sock->sk);
591 _leave("");
0b58b8a1 592}
df423a4a
DH
593
594EXPORT_SYMBOL(rxrpc_kernel_abort_call);