| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* RxRPC recvmsg() implementation |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
|---|
| 4 | 5 | * 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 License |
|---|
| 8 | | - * as published by the Free Software Foundation; either version |
|---|
| 9 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 63 | 59 | } |
|---|
| 64 | 60 | |
|---|
| 65 | 61 | /* |
|---|
| 62 | + * Transition a call to the complete state. |
|---|
| 63 | + */ |
|---|
| 64 | +bool __rxrpc_set_call_completion(struct rxrpc_call *call, |
|---|
| 65 | + enum rxrpc_call_completion compl, |
|---|
| 66 | + u32 abort_code, |
|---|
| 67 | + int error) |
|---|
| 68 | +{ |
|---|
| 69 | + if (call->state < RXRPC_CALL_COMPLETE) { |
|---|
| 70 | + call->abort_code = abort_code; |
|---|
| 71 | + call->error = error; |
|---|
| 72 | + call->completion = compl, |
|---|
| 73 | + call->state = RXRPC_CALL_COMPLETE; |
|---|
| 74 | + trace_rxrpc_call_complete(call); |
|---|
| 75 | + wake_up(&call->waitq); |
|---|
| 76 | + rxrpc_notify_socket(call); |
|---|
| 77 | + return true; |
|---|
| 78 | + } |
|---|
| 79 | + return false; |
|---|
| 80 | +} |
|---|
| 81 | + |
|---|
| 82 | +bool rxrpc_set_call_completion(struct rxrpc_call *call, |
|---|
| 83 | + enum rxrpc_call_completion compl, |
|---|
| 84 | + u32 abort_code, |
|---|
| 85 | + int error) |
|---|
| 86 | +{ |
|---|
| 87 | + bool ret = false; |
|---|
| 88 | + |
|---|
| 89 | + if (call->state < RXRPC_CALL_COMPLETE) { |
|---|
| 90 | + write_lock_bh(&call->state_lock); |
|---|
| 91 | + ret = __rxrpc_set_call_completion(call, compl, abort_code, error); |
|---|
| 92 | + write_unlock_bh(&call->state_lock); |
|---|
| 93 | + } |
|---|
| 94 | + return ret; |
|---|
| 95 | +} |
|---|
| 96 | + |
|---|
| 97 | +/* |
|---|
| 98 | + * Record that a call successfully completed. |
|---|
| 99 | + */ |
|---|
| 100 | +bool __rxrpc_call_completed(struct rxrpc_call *call) |
|---|
| 101 | +{ |
|---|
| 102 | + return __rxrpc_set_call_completion(call, RXRPC_CALL_SUCCEEDED, 0, 0); |
|---|
| 103 | +} |
|---|
| 104 | + |
|---|
| 105 | +bool rxrpc_call_completed(struct rxrpc_call *call) |
|---|
| 106 | +{ |
|---|
| 107 | + bool ret = false; |
|---|
| 108 | + |
|---|
| 109 | + if (call->state < RXRPC_CALL_COMPLETE) { |
|---|
| 110 | + write_lock_bh(&call->state_lock); |
|---|
| 111 | + ret = __rxrpc_call_completed(call); |
|---|
| 112 | + write_unlock_bh(&call->state_lock); |
|---|
| 113 | + } |
|---|
| 114 | + return ret; |
|---|
| 115 | +} |
|---|
| 116 | + |
|---|
| 117 | +/* |
|---|
| 118 | + * Record that a call is locally aborted. |
|---|
| 119 | + */ |
|---|
| 120 | +bool __rxrpc_abort_call(const char *why, struct rxrpc_call *call, |
|---|
| 121 | + rxrpc_seq_t seq, u32 abort_code, int error) |
|---|
| 122 | +{ |
|---|
| 123 | + trace_rxrpc_abort(call->debug_id, why, call->cid, call->call_id, seq, |
|---|
| 124 | + abort_code, error); |
|---|
| 125 | + return __rxrpc_set_call_completion(call, RXRPC_CALL_LOCALLY_ABORTED, |
|---|
| 126 | + abort_code, error); |
|---|
| 127 | +} |
|---|
| 128 | + |
|---|
| 129 | +bool rxrpc_abort_call(const char *why, struct rxrpc_call *call, |
|---|
| 130 | + rxrpc_seq_t seq, u32 abort_code, int error) |
|---|
| 131 | +{ |
|---|
| 132 | + bool ret; |
|---|
| 133 | + |
|---|
| 134 | + write_lock_bh(&call->state_lock); |
|---|
| 135 | + ret = __rxrpc_abort_call(why, call, seq, abort_code, error); |
|---|
| 136 | + write_unlock_bh(&call->state_lock); |
|---|
| 137 | + return ret; |
|---|
| 138 | +} |
|---|
| 139 | + |
|---|
| 140 | +/* |
|---|
| 66 | 141 | * Pass a call terminating message to userspace. |
|---|
| 67 | 142 | */ |
|---|
| 68 | 143 | static int rxrpc_recvmsg_term(struct rxrpc_call *call, struct msghdr *msg) |
|---|
| .. | .. |
|---|
| 104 | 179 | } |
|---|
| 105 | 180 | |
|---|
| 106 | 181 | /* |
|---|
| 107 | | - * Pass back notification of a new call. The call is added to the |
|---|
| 108 | | - * to-be-accepted list. This means that the next call to be accepted might not |
|---|
| 109 | | - * be the last call seen awaiting acceptance, but unless we leave this on the |
|---|
| 110 | | - * front of the queue and block all other messages until someone gives us a |
|---|
| 111 | | - * user_ID for it, there's not a lot we can do. |
|---|
| 112 | | - */ |
|---|
| 113 | | -static int rxrpc_recvmsg_new_call(struct rxrpc_sock *rx, |
|---|
| 114 | | - struct rxrpc_call *call, |
|---|
| 115 | | - struct msghdr *msg, int flags) |
|---|
| 116 | | -{ |
|---|
| 117 | | - int tmp = 0, ret; |
|---|
| 118 | | - |
|---|
| 119 | | - ret = put_cmsg(msg, SOL_RXRPC, RXRPC_NEW_CALL, 0, &tmp); |
|---|
| 120 | | - |
|---|
| 121 | | - if (ret == 0 && !(flags & MSG_PEEK)) { |
|---|
| 122 | | - _debug("to be accepted"); |
|---|
| 123 | | - write_lock_bh(&rx->recvmsg_lock); |
|---|
| 124 | | - list_del_init(&call->recvmsg_link); |
|---|
| 125 | | - write_unlock_bh(&rx->recvmsg_lock); |
|---|
| 126 | | - |
|---|
| 127 | | - rxrpc_get_call(call, rxrpc_call_got); |
|---|
| 128 | | - write_lock(&rx->call_lock); |
|---|
| 129 | | - list_add_tail(&call->accept_link, &rx->to_be_accepted); |
|---|
| 130 | | - write_unlock(&rx->call_lock); |
|---|
| 131 | | - } |
|---|
| 132 | | - |
|---|
| 133 | | - trace_rxrpc_recvmsg(call, rxrpc_recvmsg_to_be_accepted, 1, 0, 0, ret); |
|---|
| 134 | | - return ret; |
|---|
| 135 | | -} |
|---|
| 136 | | - |
|---|
| 137 | | -/* |
|---|
| 138 | 182 | * End the packet reception phase. |
|---|
| 139 | 183 | */ |
|---|
| 140 | 184 | static void rxrpc_end_rx_phase(struct rxrpc_call *call, rxrpc_serial_t serial) |
|---|
| .. | .. |
|---|
| 145 | 189 | ASSERTCMP(call->rx_hard_ack, ==, call->rx_top); |
|---|
| 146 | 190 | |
|---|
| 147 | 191 | if (call->state == RXRPC_CALL_CLIENT_RECV_REPLY) { |
|---|
| 148 | | - rxrpc_propose_ACK(call, RXRPC_ACK_IDLE, 0, serial, false, true, |
|---|
| 192 | + rxrpc_propose_ACK(call, RXRPC_ACK_IDLE, serial, false, true, |
|---|
| 149 | 193 | rxrpc_propose_ack_terminal_ack); |
|---|
| 150 | 194 | //rxrpc_send_ack_packet(call, false, NULL); |
|---|
| 151 | 195 | } |
|---|
| .. | .. |
|---|
| 163 | 207 | call->state = RXRPC_CALL_SERVER_ACK_REQUEST; |
|---|
| 164 | 208 | call->expect_req_by = jiffies + MAX_JIFFY_OFFSET; |
|---|
| 165 | 209 | write_unlock_bh(&call->state_lock); |
|---|
| 166 | | - rxrpc_propose_ACK(call, RXRPC_ACK_DELAY, 0, serial, false, true, |
|---|
| 210 | + rxrpc_propose_ACK(call, RXRPC_ACK_DELAY, serial, false, true, |
|---|
| 167 | 211 | rxrpc_propose_ack_processing_op); |
|---|
| 168 | 212 | break; |
|---|
| 169 | 213 | default: |
|---|
| .. | .. |
|---|
| 181 | 225 | struct sk_buff *skb; |
|---|
| 182 | 226 | rxrpc_serial_t serial; |
|---|
| 183 | 227 | rxrpc_seq_t hard_ack, top; |
|---|
| 184 | | - u8 flags; |
|---|
| 228 | + bool last = false; |
|---|
| 229 | + u8 subpacket; |
|---|
| 185 | 230 | int ix; |
|---|
| 186 | 231 | |
|---|
| 187 | 232 | _enter("%d", call->debug_id); |
|---|
| .. | .. |
|---|
| 193 | 238 | hard_ack++; |
|---|
| 194 | 239 | ix = hard_ack & RXRPC_RXTX_BUFF_MASK; |
|---|
| 195 | 240 | skb = call->rxtx_buffer[ix]; |
|---|
| 196 | | - rxrpc_see_skb(skb, rxrpc_skb_rx_rotated); |
|---|
| 241 | + rxrpc_see_skb(skb, rxrpc_skb_rotated); |
|---|
| 197 | 242 | sp = rxrpc_skb(skb); |
|---|
| 198 | | - flags = sp->hdr.flags; |
|---|
| 199 | | - serial = sp->hdr.serial; |
|---|
| 200 | | - if (call->rxtx_annotations[ix] & RXRPC_RX_ANNO_JUMBO) |
|---|
| 201 | | - serial += (call->rxtx_annotations[ix] & RXRPC_RX_ANNO_JUMBO) - 1; |
|---|
| 243 | + |
|---|
| 244 | + subpacket = call->rxtx_annotations[ix] & RXRPC_RX_ANNO_SUBPACKET; |
|---|
| 245 | + serial = sp->hdr.serial + subpacket; |
|---|
| 246 | + |
|---|
| 247 | + if (subpacket == sp->nr_subpackets - 1 && |
|---|
| 248 | + sp->rx_flags & RXRPC_SKB_INCL_LAST) |
|---|
| 249 | + last = true; |
|---|
| 202 | 250 | |
|---|
| 203 | 251 | call->rxtx_buffer[ix] = NULL; |
|---|
| 204 | 252 | call->rxtx_annotations[ix] = 0; |
|---|
| 205 | 253 | /* Barrier against rxrpc_input_data(). */ |
|---|
| 206 | 254 | smp_store_release(&call->rx_hard_ack, hard_ack); |
|---|
| 207 | 255 | |
|---|
| 208 | | - rxrpc_free_skb(skb, rxrpc_skb_rx_freed); |
|---|
| 256 | + rxrpc_free_skb(skb, rxrpc_skb_freed); |
|---|
| 209 | 257 | |
|---|
| 210 | | - _debug("%u,%u,%02x", hard_ack, top, flags); |
|---|
| 211 | 258 | trace_rxrpc_receive(call, rxrpc_receive_rotate, serial, hard_ack); |
|---|
| 212 | | - if (flags & RXRPC_LAST_PACKET) { |
|---|
| 259 | + if (last) { |
|---|
| 213 | 260 | rxrpc_end_rx_phase(call, serial); |
|---|
| 214 | 261 | } else { |
|---|
| 215 | 262 | /* Check to see if there's an ACK that needs sending. */ |
|---|
| 216 | | - if (after_eq(hard_ack, call->ackr_consumed + 2) || |
|---|
| 217 | | - after_eq(top, call->ackr_seen + 2) || |
|---|
| 218 | | - (hard_ack == top && after(hard_ack, call->ackr_consumed))) |
|---|
| 219 | | - rxrpc_propose_ACK(call, RXRPC_ACK_DELAY, 0, serial, |
|---|
| 220 | | - true, true, |
|---|
| 263 | + if (atomic_inc_return(&call->ackr_nr_consumed) > 2) |
|---|
| 264 | + rxrpc_propose_ACK(call, RXRPC_ACK_IDLE, serial, |
|---|
| 265 | + true, false, |
|---|
| 221 | 266 | rxrpc_propose_ack_rotate_rx); |
|---|
| 222 | 267 | if (call->ackr_reason && call->ackr_reason != RXRPC_ACK_DELAY) |
|---|
| 223 | 268 | rxrpc_send_ack_packet(call, false, NULL); |
|---|
| .. | .. |
|---|
| 237 | 282 | struct rxrpc_skb_priv *sp = rxrpc_skb(skb); |
|---|
| 238 | 283 | rxrpc_seq_t seq = sp->hdr.seq; |
|---|
| 239 | 284 | u16 cksum = sp->hdr.cksum; |
|---|
| 285 | + u8 subpacket = annotation & RXRPC_RX_ANNO_SUBPACKET; |
|---|
| 240 | 286 | |
|---|
| 241 | 287 | _enter(""); |
|---|
| 242 | 288 | |
|---|
| 243 | 289 | /* For all but the head jumbo subpacket, the security checksum is in a |
|---|
| 244 | 290 | * jumbo header immediately prior to the data. |
|---|
| 245 | 291 | */ |
|---|
| 246 | | - if ((annotation & RXRPC_RX_ANNO_JUMBO) > 1) { |
|---|
| 292 | + if (subpacket > 0) { |
|---|
| 247 | 293 | __be16 tmp; |
|---|
| 248 | 294 | if (skb_copy_bits(skb, offset - 2, &tmp, 2) < 0) |
|---|
| 249 | 295 | BUG(); |
|---|
| 250 | 296 | cksum = ntohs(tmp); |
|---|
| 251 | | - seq += (annotation & RXRPC_RX_ANNO_JUMBO) - 1; |
|---|
| 297 | + seq += subpacket; |
|---|
| 252 | 298 | } |
|---|
| 253 | 299 | |
|---|
| 254 | | - return call->conn->security->verify_packet(call, skb, offset, len, |
|---|
| 255 | | - seq, cksum); |
|---|
| 300 | + return call->security->verify_packet(call, skb, offset, len, |
|---|
| 301 | + seq, cksum); |
|---|
| 256 | 302 | } |
|---|
| 257 | 303 | |
|---|
| 258 | 304 | /* |
|---|
| .. | .. |
|---|
| 267 | 313 | */ |
|---|
| 268 | 314 | static int rxrpc_locate_data(struct rxrpc_call *call, struct sk_buff *skb, |
|---|
| 269 | 315 | u8 *_annotation, |
|---|
| 270 | | - unsigned int *_offset, unsigned int *_len) |
|---|
| 316 | + unsigned int *_offset, unsigned int *_len, |
|---|
| 317 | + bool *_last) |
|---|
| 271 | 318 | { |
|---|
| 319 | + struct rxrpc_skb_priv *sp = rxrpc_skb(skb); |
|---|
| 272 | 320 | unsigned int offset = sizeof(struct rxrpc_wire_header); |
|---|
| 273 | 321 | unsigned int len; |
|---|
| 322 | + bool last = false; |
|---|
| 274 | 323 | int ret; |
|---|
| 275 | 324 | u8 annotation = *_annotation; |
|---|
| 325 | + u8 subpacket = annotation & RXRPC_RX_ANNO_SUBPACKET; |
|---|
| 276 | 326 | |
|---|
| 277 | 327 | /* Locate the subpacket */ |
|---|
| 328 | + offset += subpacket * RXRPC_JUMBO_SUBPKTLEN; |
|---|
| 278 | 329 | len = skb->len - offset; |
|---|
| 279 | | - if ((annotation & RXRPC_RX_ANNO_JUMBO) > 0) { |
|---|
| 280 | | - offset += (((annotation & RXRPC_RX_ANNO_JUMBO) - 1) * |
|---|
| 281 | | - RXRPC_JUMBO_SUBPKTLEN); |
|---|
| 282 | | - len = (annotation & RXRPC_RX_ANNO_JLAST) ? |
|---|
| 283 | | - skb->len - offset : RXRPC_JUMBO_SUBPKTLEN; |
|---|
| 284 | | - } |
|---|
| 330 | + if (subpacket < sp->nr_subpackets - 1) |
|---|
| 331 | + len = RXRPC_JUMBO_DATALEN; |
|---|
| 332 | + else if (sp->rx_flags & RXRPC_SKB_INCL_LAST) |
|---|
| 333 | + last = true; |
|---|
| 285 | 334 | |
|---|
| 286 | 335 | if (!(annotation & RXRPC_RX_ANNO_VERIFIED)) { |
|---|
| 287 | 336 | ret = rxrpc_verify_packet(call, skb, annotation, offset, len); |
|---|
| .. | .. |
|---|
| 292 | 341 | |
|---|
| 293 | 342 | *_offset = offset; |
|---|
| 294 | 343 | *_len = len; |
|---|
| 295 | | - call->conn->security->locate_data(call, skb, _offset, _len); |
|---|
| 344 | + *_last = last; |
|---|
| 345 | + call->security->locate_data(call, skb, _offset, _len); |
|---|
| 296 | 346 | return 0; |
|---|
| 297 | 347 | } |
|---|
| 298 | 348 | |
|---|
| .. | .. |
|---|
| 307 | 357 | { |
|---|
| 308 | 358 | struct rxrpc_skb_priv *sp; |
|---|
| 309 | 359 | struct sk_buff *skb; |
|---|
| 360 | + rxrpc_serial_t serial; |
|---|
| 310 | 361 | rxrpc_seq_t hard_ack, top, seq; |
|---|
| 311 | 362 | size_t remain; |
|---|
| 312 | | - bool last; |
|---|
| 363 | + bool rx_pkt_last; |
|---|
| 313 | 364 | unsigned int rx_pkt_offset, rx_pkt_len; |
|---|
| 314 | 365 | int ix, copy, ret = -EAGAIN, ret2; |
|---|
| 315 | 366 | |
|---|
| .. | .. |
|---|
| 319 | 370 | |
|---|
| 320 | 371 | rx_pkt_offset = call->rx_pkt_offset; |
|---|
| 321 | 372 | rx_pkt_len = call->rx_pkt_len; |
|---|
| 373 | + rx_pkt_last = call->rx_pkt_last; |
|---|
| 322 | 374 | |
|---|
| 323 | 375 | if (call->state >= RXRPC_CALL_SERVER_ACK_REQUEST) { |
|---|
| 324 | 376 | seq = call->rx_hard_ack; |
|---|
| .. | .. |
|---|
| 329 | 381 | /* Barriers against rxrpc_input_data(). */ |
|---|
| 330 | 382 | hard_ack = call->rx_hard_ack; |
|---|
| 331 | 383 | seq = hard_ack + 1; |
|---|
| 384 | + |
|---|
| 332 | 385 | while (top = smp_load_acquire(&call->rx_top), |
|---|
| 333 | 386 | before_eq(seq, top) |
|---|
| 334 | 387 | ) { |
|---|
| .. | .. |
|---|
| 340 | 393 | break; |
|---|
| 341 | 394 | } |
|---|
| 342 | 395 | smp_rmb(); |
|---|
| 343 | | - rxrpc_see_skb(skb, rxrpc_skb_rx_seen); |
|---|
| 396 | + rxrpc_see_skb(skb, rxrpc_skb_seen); |
|---|
| 344 | 397 | sp = rxrpc_skb(skb); |
|---|
| 345 | 398 | |
|---|
| 346 | | - if (!(flags & MSG_PEEK)) |
|---|
| 399 | + if (!(flags & MSG_PEEK)) { |
|---|
| 400 | + serial = sp->hdr.serial; |
|---|
| 401 | + serial += call->rxtx_annotations[ix] & RXRPC_RX_ANNO_SUBPACKET; |
|---|
| 347 | 402 | trace_rxrpc_receive(call, rxrpc_receive_front, |
|---|
| 348 | | - sp->hdr.serial, seq); |
|---|
| 403 | + serial, seq); |
|---|
| 404 | + } |
|---|
| 349 | 405 | |
|---|
| 350 | 406 | if (msg) |
|---|
| 351 | 407 | sock_recv_timestamp(msg, sock->sk, skb); |
|---|
| .. | .. |
|---|
| 353 | 409 | if (rx_pkt_offset == 0) { |
|---|
| 354 | 410 | ret2 = rxrpc_locate_data(call, skb, |
|---|
| 355 | 411 | &call->rxtx_annotations[ix], |
|---|
| 356 | | - &rx_pkt_offset, &rx_pkt_len); |
|---|
| 412 | + &rx_pkt_offset, &rx_pkt_len, |
|---|
| 413 | + &rx_pkt_last); |
|---|
| 357 | 414 | trace_rxrpc_recvmsg(call, rxrpc_recvmsg_next, seq, |
|---|
| 358 | 415 | rx_pkt_offset, rx_pkt_len, ret2); |
|---|
| 359 | 416 | if (ret2 < 0) { |
|---|
| .. | .. |
|---|
| 393 | 450 | } |
|---|
| 394 | 451 | |
|---|
| 395 | 452 | /* The whole packet has been transferred. */ |
|---|
| 396 | | - last = sp->hdr.flags & RXRPC_LAST_PACKET; |
|---|
| 397 | 453 | if (!(flags & MSG_PEEK)) |
|---|
| 398 | 454 | rxrpc_rotate_rx_window(call); |
|---|
| 399 | 455 | rx_pkt_offset = 0; |
|---|
| 400 | 456 | rx_pkt_len = 0; |
|---|
| 401 | 457 | |
|---|
| 402 | | - if (last) { |
|---|
| 458 | + if (rx_pkt_last) { |
|---|
| 403 | 459 | ASSERTCMP(seq, ==, READ_ONCE(call->rx_top)); |
|---|
| 404 | 460 | ret = 1; |
|---|
| 405 | 461 | goto out; |
|---|
| .. | .. |
|---|
| 412 | 468 | if (!(flags & MSG_PEEK)) { |
|---|
| 413 | 469 | call->rx_pkt_offset = rx_pkt_offset; |
|---|
| 414 | 470 | call->rx_pkt_len = rx_pkt_len; |
|---|
| 471 | + call->rx_pkt_last = rx_pkt_last; |
|---|
| 415 | 472 | } |
|---|
| 416 | 473 | done: |
|---|
| 417 | 474 | trace_rxrpc_recvmsg(call, rxrpc_recvmsg_data_return, seq, |
|---|
| .. | .. |
|---|
| 540 | 597 | } |
|---|
| 541 | 598 | |
|---|
| 542 | 599 | switch (READ_ONCE(call->state)) { |
|---|
| 543 | | - case RXRPC_CALL_SERVER_ACCEPTING: |
|---|
| 544 | | - ret = rxrpc_recvmsg_new_call(rx, call, msg, flags); |
|---|
| 545 | | - break; |
|---|
| 546 | 600 | case RXRPC_CALL_CLIENT_RECV_REPLY: |
|---|
| 547 | 601 | case RXRPC_CALL_SERVER_RECV_REQUEST: |
|---|
| 548 | 602 | case RXRPC_CALL_SERVER_ACK_REQUEST: |
|---|
| .. | .. |
|---|
| 638 | 692 | call->debug_id, rxrpc_call_states[call->state], |
|---|
| 639 | 693 | iov_iter_count(iter), want_more); |
|---|
| 640 | 694 | |
|---|
| 641 | | - ASSERTCMP(call->state, !=, RXRPC_CALL_SERVER_ACCEPTING); |
|---|
| 695 | + ASSERTCMP(call->state, !=, RXRPC_CALL_SERVER_SECURING); |
|---|
| 642 | 696 | |
|---|
| 643 | 697 | mutex_lock(&call->user_mutex); |
|---|
| 644 | 698 | |
|---|
| .. | .. |
|---|
| 686 | 740 | case RXRPC_ACK_DELAY: |
|---|
| 687 | 741 | if (ret != -EAGAIN) |
|---|
| 688 | 742 | break; |
|---|
| 689 | | - /* Fall through */ |
|---|
| 743 | + fallthrough; |
|---|
| 690 | 744 | default: |
|---|
| 691 | 745 | rxrpc_send_ack_packet(call, false, NULL); |
|---|
| 692 | 746 | } |
|---|
| .. | .. |
|---|
| 716 | 770 | goto out; |
|---|
| 717 | 771 | } |
|---|
| 718 | 772 | EXPORT_SYMBOL(rxrpc_kernel_recv_data); |
|---|
| 773 | + |
|---|
| 774 | +/** |
|---|
| 775 | + * rxrpc_kernel_get_reply_time - Get timestamp on first reply packet |
|---|
| 776 | + * @sock: The socket that the call exists on |
|---|
| 777 | + * @call: The call to query |
|---|
| 778 | + * @_ts: Where to put the timestamp |
|---|
| 779 | + * |
|---|
| 780 | + * Retrieve the timestamp from the first DATA packet of the reply if it is |
|---|
| 781 | + * in the ring. Returns true if successful, false if not. |
|---|
| 782 | + */ |
|---|
| 783 | +bool rxrpc_kernel_get_reply_time(struct socket *sock, struct rxrpc_call *call, |
|---|
| 784 | + ktime_t *_ts) |
|---|
| 785 | +{ |
|---|
| 786 | + struct sk_buff *skb; |
|---|
| 787 | + rxrpc_seq_t hard_ack, top, seq; |
|---|
| 788 | + bool success = false; |
|---|
| 789 | + |
|---|
| 790 | + mutex_lock(&call->user_mutex); |
|---|
| 791 | + |
|---|
| 792 | + if (READ_ONCE(call->state) != RXRPC_CALL_CLIENT_RECV_REPLY) |
|---|
| 793 | + goto out; |
|---|
| 794 | + |
|---|
| 795 | + hard_ack = call->rx_hard_ack; |
|---|
| 796 | + if (hard_ack != 0) |
|---|
| 797 | + goto out; |
|---|
| 798 | + |
|---|
| 799 | + seq = hard_ack + 1; |
|---|
| 800 | + top = smp_load_acquire(&call->rx_top); |
|---|
| 801 | + if (after(seq, top)) |
|---|
| 802 | + goto out; |
|---|
| 803 | + |
|---|
| 804 | + skb = call->rxtx_buffer[seq & RXRPC_RXTX_BUFF_MASK]; |
|---|
| 805 | + if (!skb) |
|---|
| 806 | + goto out; |
|---|
| 807 | + |
|---|
| 808 | + *_ts = skb_get_ktime(skb); |
|---|
| 809 | + success = true; |
|---|
| 810 | + |
|---|
| 811 | +out: |
|---|
| 812 | + mutex_unlock(&call->user_mutex); |
|---|
| 813 | + return success; |
|---|
| 814 | +} |
|---|
| 815 | +EXPORT_SYMBOL(rxrpc_kernel_get_reply_time); |
|---|