.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* AF_RXRPC internal definitions |
---|
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 | #include <linux/atomic.h> |
---|
13 | 9 | #include <linux/seqlock.h> |
---|
| 10 | +#include <linux/win_minmax.h> |
---|
14 | 11 | #include <net/net_namespace.h> |
---|
15 | 12 | #include <net/netns/generic.h> |
---|
16 | 13 | #include <net/sock.h> |
---|
17 | 14 | #include <net/af_rxrpc.h> |
---|
18 | 15 | #include "protocol.h" |
---|
19 | | - |
---|
20 | | -#if 0 |
---|
21 | | -#define CHECK_SLAB_OKAY(X) \ |
---|
22 | | - BUG_ON(atomic_read((X)) >> (sizeof(atomic_t) - 2) == \ |
---|
23 | | - (POISON_FREE << 8 | POISON_FREE)) |
---|
24 | | -#else |
---|
25 | | -#define CHECK_SLAB_OKAY(X) do {} while (0) |
---|
26 | | -#endif |
---|
27 | 16 | |
---|
28 | 17 | #define FCRYPT_BSIZE 8 |
---|
29 | 18 | struct rxrpc_crypt { |
---|
.. | .. |
---|
79 | 68 | struct work_struct service_conn_reaper; |
---|
80 | 69 | struct timer_list service_conn_reap_timer; |
---|
81 | 70 | |
---|
82 | | - unsigned int nr_client_conns; |
---|
83 | | - unsigned int nr_active_client_conns; |
---|
84 | | - bool kill_all_client_conns; |
---|
85 | 71 | bool live; |
---|
| 72 | + |
---|
| 73 | + bool kill_all_client_conns; |
---|
| 74 | + atomic_t nr_client_conns; |
---|
86 | 75 | spinlock_t client_conn_cache_lock; /* Lock for ->*_client_conns */ |
---|
87 | 76 | spinlock_t client_conn_discard_lock; /* Prevent multiple discarders */ |
---|
88 | | - struct list_head waiting_client_conns; |
---|
89 | | - struct list_head active_client_conns; |
---|
90 | 77 | struct list_head idle_client_conns; |
---|
91 | 78 | struct work_struct client_conn_reaper; |
---|
92 | 79 | struct timer_list client_conn_reap_timer; |
---|
93 | 80 | |
---|
94 | | - struct list_head local_endpoints; |
---|
| 81 | + struct hlist_head local_endpoints; |
---|
95 | 82 | struct mutex local_mutex; /* Lock for ->local_endpoints */ |
---|
96 | 83 | |
---|
97 | 84 | DECLARE_HASHTABLE (peer_hash, 10); |
---|
.. | .. |
---|
189 | 176 | * - max 48 bytes (struct sk_buff::cb) |
---|
190 | 177 | */ |
---|
191 | 178 | struct rxrpc_skb_priv { |
---|
192 | | - union { |
---|
193 | | - u8 nr_jumbo; /* Number of jumbo subpackets */ |
---|
194 | | - }; |
---|
| 179 | + atomic_t nr_ring_pins; /* Number of rxtx ring pins */ |
---|
| 180 | + u8 nr_subpackets; /* Number of subpackets */ |
---|
| 181 | + u8 rx_flags; /* Received packet flags */ |
---|
| 182 | +#define RXRPC_SKB_INCL_LAST 0x01 /* - Includes last packet */ |
---|
| 183 | +#define RXRPC_SKB_TX_BUFFER 0x02 /* - Is transmit buffer */ |
---|
195 | 184 | union { |
---|
196 | 185 | int remain; /* amount of space remaining for next write */ |
---|
| 186 | + |
---|
| 187 | + /* List of requested ACKs on subpackets */ |
---|
| 188 | + unsigned long rx_req_ack[(RXRPC_MAX_NR_JUMBO + BITS_PER_LONG - 1) / |
---|
| 189 | + BITS_PER_LONG]; |
---|
197 | 190 | }; |
---|
198 | 191 | |
---|
199 | 192 | struct rxrpc_host_header hdr; /* RxRPC packet header from this packet */ |
---|
.. | .. |
---|
207 | 200 | struct rxrpc_security { |
---|
208 | 201 | const char *name; /* name of this service */ |
---|
209 | 202 | u8 security_index; /* security type provided */ |
---|
| 203 | + u32 no_key_abort; /* Abort code indicating no key */ |
---|
210 | 204 | |
---|
211 | 205 | /* Initialise a security service */ |
---|
212 | 206 | int (*init)(void); |
---|
.. | .. |
---|
229 | 223 | /* verify the security on a received packet */ |
---|
230 | 224 | int (*verify_packet)(struct rxrpc_call *, struct sk_buff *, |
---|
231 | 225 | unsigned int, unsigned int, rxrpc_seq_t, u16); |
---|
| 226 | + |
---|
| 227 | + /* Free crypto request on a call */ |
---|
| 228 | + void (*free_call_crypto)(struct rxrpc_call *); |
---|
232 | 229 | |
---|
233 | 230 | /* Locate the data in a received packet that has been verified. */ |
---|
234 | 231 | void (*locate_data)(struct rxrpc_call *, struct sk_buff *, |
---|
.. | .. |
---|
259 | 256 | struct rxrpc_local { |
---|
260 | 257 | struct rcu_head rcu; |
---|
261 | 258 | atomic_t active_users; /* Number of users of the local endpoint */ |
---|
262 | | - atomic_t usage; /* Number of references to the structure */ |
---|
| 259 | + refcount_t ref; /* Number of references to the structure */ |
---|
263 | 260 | struct rxrpc_net *rxnet; /* The network ns in which this resides */ |
---|
264 | | - struct list_head link; |
---|
| 261 | + struct hlist_node link; |
---|
265 | 262 | struct socket *socket; /* my UDP socket */ |
---|
266 | 263 | struct work_struct processor; |
---|
267 | 264 | struct rxrpc_sock __rcu *service; /* Service(s) listening on this endpoint */ |
---|
268 | 265 | struct rw_semaphore defrag_sem; /* control re-enablement of IP DF bit */ |
---|
269 | 266 | struct sk_buff_head reject_queue; /* packets awaiting rejection */ |
---|
270 | 267 | struct sk_buff_head event_queue; /* endpoint event packets awaiting processing */ |
---|
271 | | - struct rb_root client_conns; /* Client connections by socket params */ |
---|
272 | | - spinlock_t client_conns_lock; /* Lock for client_conns */ |
---|
| 268 | + struct rb_root client_bundles; /* Client connection bundles by socket params */ |
---|
| 269 | + spinlock_t client_bundles_lock; /* Lock for client_bundles */ |
---|
273 | 270 | spinlock_t lock; /* access lock */ |
---|
274 | 271 | rwlock_t services_lock; /* lock for services list */ |
---|
275 | 272 | int debug_id; /* debug ID for printks */ |
---|
.. | .. |
---|
284 | 281 | */ |
---|
285 | 282 | struct rxrpc_peer { |
---|
286 | 283 | struct rcu_head rcu; /* This must be first */ |
---|
287 | | - atomic_t usage; |
---|
| 284 | + refcount_t ref; |
---|
288 | 285 | unsigned long hash_key; |
---|
289 | 286 | struct hlist_node hash_link; |
---|
290 | 287 | struct rxrpc_local *local; |
---|
.. | .. |
---|
305 | 302 | #define RXRPC_RTT_CACHE_SIZE 32 |
---|
306 | 303 | spinlock_t rtt_input_lock; /* RTT lock for input routine */ |
---|
307 | 304 | ktime_t rtt_last_req; /* Time of last RTT request */ |
---|
308 | | - u64 rtt; /* Current RTT estimate (in nS) */ |
---|
309 | | - u64 rtt_sum; /* Sum of cache contents */ |
---|
310 | | - u64 rtt_cache[RXRPC_RTT_CACHE_SIZE]; /* Determined RTT cache */ |
---|
311 | | - u8 rtt_cursor; /* next entry at which to insert */ |
---|
312 | | - u8 rtt_usage; /* amount of cache actually used */ |
---|
| 305 | + unsigned int rtt_count; /* Number of samples we've got */ |
---|
| 306 | + |
---|
| 307 | + u32 srtt_us; /* smoothed round trip time << 3 in usecs */ |
---|
| 308 | + u32 mdev_us; /* medium deviation */ |
---|
| 309 | + u32 mdev_max_us; /* maximal mdev for the last rtt period */ |
---|
| 310 | + u32 rttvar_us; /* smoothed mdev_max */ |
---|
| 311 | + u32 rto_j; /* Retransmission timeout in jiffies */ |
---|
| 312 | + u8 backoff; /* Backoff timeout */ |
---|
313 | 313 | |
---|
314 | 314 | u8 cong_cwnd; /* Congestion window size */ |
---|
315 | 315 | }; |
---|
.. | .. |
---|
343 | 343 | enum rxrpc_conn_flag { |
---|
344 | 344 | RXRPC_CONN_HAS_IDR, /* Has a client conn ID assigned */ |
---|
345 | 345 | RXRPC_CONN_IN_SERVICE_CONNS, /* Conn is in peer->service_conns */ |
---|
346 | | - RXRPC_CONN_IN_CLIENT_CONNS, /* Conn is in local->client_conns */ |
---|
347 | | - RXRPC_CONN_EXPOSED, /* Conn has extra ref for exposure */ |
---|
348 | 346 | RXRPC_CONN_DONT_REUSE, /* Don't reuse this connection */ |
---|
349 | | - RXRPC_CONN_COUNTED, /* Counted by rxrpc_nr_client_conns */ |
---|
350 | 347 | RXRPC_CONN_PROBING_FOR_UPGRADE, /* Probing for service upgrade */ |
---|
351 | 348 | RXRPC_CONN_FINAL_ACK_0, /* Need final ACK for channel 0 */ |
---|
352 | 349 | RXRPC_CONN_FINAL_ACK_1, /* Need final ACK for channel 1 */ |
---|
.. | .. |
---|
367 | 364 | }; |
---|
368 | 365 | |
---|
369 | 366 | /* |
---|
370 | | - * The connection cache state. |
---|
371 | | - */ |
---|
372 | | -enum rxrpc_conn_cache_state { |
---|
373 | | - RXRPC_CONN_CLIENT_INACTIVE, /* Conn is not yet listed */ |
---|
374 | | - RXRPC_CONN_CLIENT_WAITING, /* Conn is on wait list, waiting for capacity */ |
---|
375 | | - RXRPC_CONN_CLIENT_ACTIVE, /* Conn is on active list, doing calls */ |
---|
376 | | - RXRPC_CONN_CLIENT_UPGRADE, /* Conn is on active list, probing for upgrade */ |
---|
377 | | - RXRPC_CONN_CLIENT_CULLED, /* Conn is culled and delisted, doing calls */ |
---|
378 | | - RXRPC_CONN_CLIENT_IDLE, /* Conn is on idle list, doing mostly nothing */ |
---|
379 | | - RXRPC_CONN__NR_CACHE_STATES |
---|
380 | | -}; |
---|
381 | | - |
---|
382 | | -/* |
---|
383 | 367 | * The connection protocol state. |
---|
384 | 368 | */ |
---|
385 | 369 | enum rxrpc_conn_proto_state { |
---|
.. | .. |
---|
395 | 379 | }; |
---|
396 | 380 | |
---|
397 | 381 | /* |
---|
| 382 | + * RxRPC client connection bundle. |
---|
| 383 | + */ |
---|
| 384 | +struct rxrpc_bundle { |
---|
| 385 | + struct rxrpc_conn_parameters params; |
---|
| 386 | + refcount_t ref; |
---|
| 387 | + atomic_t active; /* Number of active users */ |
---|
| 388 | + unsigned int debug_id; |
---|
| 389 | + bool try_upgrade; /* True if the bundle is attempting upgrade */ |
---|
| 390 | + bool alloc_conn; /* True if someone's getting a conn */ |
---|
| 391 | + short alloc_error; /* Error from last conn allocation */ |
---|
| 392 | + spinlock_t channel_lock; |
---|
| 393 | + struct rb_node local_node; /* Node in local->client_conns */ |
---|
| 394 | + struct list_head waiting_calls; /* Calls waiting for channels */ |
---|
| 395 | + unsigned long avail_chans; /* Mask of available channels */ |
---|
| 396 | + struct rxrpc_connection *conns[4]; /* The connections in the bundle (max 4) */ |
---|
| 397 | +}; |
---|
| 398 | + |
---|
| 399 | +/* |
---|
398 | 400 | * RxRPC connection definition |
---|
399 | 401 | * - matched by { local, peer, epoch, conn_id, direction } |
---|
400 | 402 | * - each connection can only handle four simultaneous calls |
---|
.. | .. |
---|
403 | 405 | struct rxrpc_conn_proto proto; |
---|
404 | 406 | struct rxrpc_conn_parameters params; |
---|
405 | 407 | |
---|
406 | | - atomic_t usage; |
---|
| 408 | + refcount_t ref; |
---|
407 | 409 | struct rcu_head rcu; |
---|
408 | 410 | struct list_head cache_link; |
---|
409 | 411 | |
---|
410 | | - spinlock_t channel_lock; |
---|
411 | | - unsigned char active_chans; /* Mask of active channels */ |
---|
412 | | -#define RXRPC_ACTIVE_CHANS_MASK ((1 << RXRPC_MAXCALLS) - 1) |
---|
413 | | - struct list_head waiting_calls; /* Calls waiting for channels */ |
---|
| 412 | + unsigned char act_chans; /* Mask of active channels */ |
---|
414 | 413 | struct rxrpc_channel { |
---|
415 | 414 | unsigned long final_ack_at; /* Time at which to issue final ACK */ |
---|
416 | 415 | struct rxrpc_call __rcu *call; /* Active call */ |
---|
.. | .. |
---|
427 | 426 | |
---|
428 | 427 | struct timer_list timer; /* Conn event timer */ |
---|
429 | 428 | struct work_struct processor; /* connection event processor */ |
---|
430 | | - union { |
---|
431 | | - struct rb_node client_node; /* Node in local->client_conns */ |
---|
432 | | - struct rb_node service_node; /* Node in peer->service_conns */ |
---|
433 | | - }; |
---|
| 429 | + struct rxrpc_bundle *bundle; /* Client connection bundle */ |
---|
| 430 | + struct rb_node service_node; /* Node in peer->service_conns */ |
---|
434 | 431 | struct list_head proc_link; /* link in procfs list */ |
---|
435 | 432 | struct list_head link; /* link in master connection list */ |
---|
436 | 433 | struct sk_buff_head rx_queue; /* received conn-level packets */ |
---|
437 | 434 | const struct rxrpc_security *security; /* applied security module */ |
---|
438 | 435 | struct key *server_key; /* security for this service */ |
---|
439 | | - struct crypto_skcipher *cipher; /* encryption handle */ |
---|
| 436 | + struct crypto_sync_skcipher *cipher; /* encryption handle */ |
---|
440 | 437 | struct rxrpc_crypt csum_iv; /* packet checksum base */ |
---|
441 | 438 | unsigned long flags; |
---|
442 | 439 | unsigned long events; |
---|
443 | 440 | unsigned long idle_timestamp; /* Time at which last became idle */ |
---|
444 | 441 | spinlock_t state_lock; /* state-change lock */ |
---|
445 | | - enum rxrpc_conn_cache_state cache_state; |
---|
446 | 442 | enum rxrpc_conn_proto_state state; /* current state of connection */ |
---|
447 | 443 | u32 abort_code; /* Abort code of connection abort */ |
---|
448 | 444 | int debug_id; /* debug ID for printks */ |
---|
.. | .. |
---|
454 | 450 | u8 security_size; /* security header size */ |
---|
455 | 451 | u8 security_ix; /* security type */ |
---|
456 | 452 | u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */ |
---|
| 453 | + u8 bundle_shift; /* Index into bundle->avail_chans */ |
---|
457 | 454 | short error; /* Local error code */ |
---|
458 | 455 | }; |
---|
459 | 456 | |
---|
.. | .. |
---|
477 | 474 | RXRPC_CALL_EXPOSED, /* The call was exposed to the world */ |
---|
478 | 475 | RXRPC_CALL_RX_LAST, /* Received the last packet (at rxtx_top) */ |
---|
479 | 476 | RXRPC_CALL_TX_LAST, /* Last packet in Tx buffer (at rxtx_top) */ |
---|
480 | | - RXRPC_CALL_TX_LASTQ, /* Last packet has been queued */ |
---|
481 | 477 | RXRPC_CALL_SEND_PING, /* A ping will need to be sent */ |
---|
482 | | - RXRPC_CALL_PINGING, /* Ping in process */ |
---|
483 | 478 | RXRPC_CALL_RETRANS_TIMEOUT, /* Retransmission due to timeout occurred */ |
---|
484 | 479 | RXRPC_CALL_BEGAN_RX_TIMER, /* We began the expect_rx_by timer */ |
---|
485 | 480 | RXRPC_CALL_RX_HEARD, /* The peer responded at least once to this call */ |
---|
486 | 481 | RXRPC_CALL_RX_UNDERRUN, /* Got data underrun */ |
---|
487 | 482 | RXRPC_CALL_DISCONNECTED, /* The call has been disconnected */ |
---|
| 483 | + RXRPC_CALL_KERNEL, /* The call was made by the kernel */ |
---|
| 484 | + RXRPC_CALL_UPGRADE, /* Service upgrade was requested for the call */ |
---|
488 | 485 | }; |
---|
489 | 486 | |
---|
490 | 487 | /* |
---|
.. | .. |
---|
510 | 507 | RXRPC_CALL_CLIENT_RECV_REPLY, /* - client receiving reply phase */ |
---|
511 | 508 | RXRPC_CALL_SERVER_PREALLOC, /* - service preallocation */ |
---|
512 | 509 | RXRPC_CALL_SERVER_SECURING, /* - server securing request connection */ |
---|
513 | | - RXRPC_CALL_SERVER_ACCEPTING, /* - server accepting request */ |
---|
514 | 510 | RXRPC_CALL_SERVER_RECV_REQUEST, /* - server receiving request */ |
---|
515 | 511 | RXRPC_CALL_SERVER_ACK_REQUEST, /* - server pending ACK of request */ |
---|
516 | 512 | RXRPC_CALL_SERVER_SEND_REPLY, /* - server sending reply */ |
---|
517 | 513 | RXRPC_CALL_SERVER_AWAIT_ACK, /* - server awaiting final ACK */ |
---|
518 | 514 | RXRPC_CALL_COMPLETE, /* - call complete */ |
---|
519 | 515 | NR__RXRPC_CALL_STATES |
---|
| 516 | +}; |
---|
| 517 | + |
---|
| 518 | +/* |
---|
| 519 | + * Call completion condition (state == RXRPC_CALL_COMPLETE). |
---|
| 520 | + */ |
---|
| 521 | +enum rxrpc_call_completion { |
---|
| 522 | + RXRPC_CALL_SUCCEEDED, /* - Normal termination */ |
---|
| 523 | + RXRPC_CALL_REMOTELY_ABORTED, /* - call aborted by peer */ |
---|
| 524 | + RXRPC_CALL_LOCALLY_ABORTED, /* - call aborted locally on error or close */ |
---|
| 525 | + RXRPC_CALL_LOCAL_ERROR, /* - call failed due to local error */ |
---|
| 526 | + RXRPC_CALL_NETWORK_ERROR, /* - call terminated by network error */ |
---|
| 527 | + NR__RXRPC_CALL_COMPLETIONS |
---|
520 | 528 | }; |
---|
521 | 529 | |
---|
522 | 530 | /* |
---|
.. | .. |
---|
540 | 548 | struct rxrpc_peer *peer; /* Peer record for remote address */ |
---|
541 | 549 | struct rxrpc_sock __rcu *socket; /* socket responsible */ |
---|
542 | 550 | struct rxrpc_net *rxnet; /* Network namespace to which call belongs */ |
---|
| 551 | + const struct rxrpc_security *security; /* applied security module */ |
---|
543 | 552 | struct mutex user_mutex; /* User access mutex */ |
---|
544 | 553 | unsigned long ack_at; /* When deferred ACK needs to happen */ |
---|
545 | 554 | unsigned long ack_lost_at; /* When ACK is figured as lost */ |
---|
.. | .. |
---|
551 | 560 | unsigned long expect_term_by; /* When we expect call termination by */ |
---|
552 | 561 | u32 next_rx_timo; /* Timeout for next Rx packet (jif) */ |
---|
553 | 562 | u32 next_req_timo; /* Timeout for next Rx request packet (jif) */ |
---|
| 563 | + struct skcipher_request *cipher_req; /* Packet cipher request buffer */ |
---|
554 | 564 | struct timer_list timer; /* Combined event timer */ |
---|
555 | 565 | struct work_struct processor; /* Event processor */ |
---|
556 | 566 | rxrpc_notify_rx_t notify_rx; /* kernel service Rx notification function */ |
---|
557 | 567 | struct list_head link; /* link in master call list */ |
---|
558 | | - struct list_head chan_wait_link; /* Link in conn->waiting_calls */ |
---|
| 568 | + struct list_head chan_wait_link; /* Link in conn->bundle->waiting_calls */ |
---|
559 | 569 | struct hlist_node error_link; /* link in error distribution list */ |
---|
560 | 570 | struct list_head accept_link; /* Link in rx->acceptq */ |
---|
561 | 571 | struct list_head recvmsg_link; /* Link in rx->recvmsg_q */ |
---|
.. | .. |
---|
575 | 585 | int error; /* Local error incurred */ |
---|
576 | 586 | enum rxrpc_call_state state; /* current state of call */ |
---|
577 | 587 | enum rxrpc_call_completion completion; /* Call completion condition */ |
---|
578 | | - atomic_t usage; |
---|
| 588 | + refcount_t ref; |
---|
579 | 589 | u16 service_id; /* service ID */ |
---|
580 | 590 | u8 security_ix; /* Security type */ |
---|
| 591 | + enum rxrpc_interruptibility interruptibility; /* At what point call may be interrupted */ |
---|
581 | 592 | u32 call_id; /* call ID on connection */ |
---|
582 | 593 | u32 cid; /* connection ID plus channel index */ |
---|
583 | 594 | int debug_id; /* debug ID for printks */ |
---|
584 | 595 | unsigned short rx_pkt_offset; /* Current recvmsg packet offset */ |
---|
585 | 596 | unsigned short rx_pkt_len; /* Current recvmsg packet len */ |
---|
| 597 | + bool rx_pkt_last; /* Current recvmsg packet is last */ |
---|
586 | 598 | |
---|
587 | 599 | /* Rx/Tx circular buffer, depending on phase. |
---|
588 | 600 | * |
---|
.. | .. |
---|
606 | 618 | #define RXRPC_TX_ANNO_LAST 0x04 |
---|
607 | 619 | #define RXRPC_TX_ANNO_RESENT 0x08 |
---|
608 | 620 | |
---|
609 | | -#define RXRPC_RX_ANNO_JUMBO 0x3f /* Jumbo subpacket number + 1 if not zero */ |
---|
610 | | -#define RXRPC_RX_ANNO_JLAST 0x40 /* Set if last element of a jumbo packet */ |
---|
| 621 | +#define RXRPC_RX_ANNO_SUBPACKET 0x3f /* Subpacket number in jumbogram */ |
---|
611 | 622 | #define RXRPC_RX_ANNO_VERIFIED 0x80 /* Set if verified and decrypted */ |
---|
612 | 623 | rxrpc_seq_t tx_hard_ack; /* Dead slot in buffer; the first transmitted but |
---|
613 | 624 | * not hard-ACK'd packet follows this. |
---|
.. | .. |
---|
641 | 652 | |
---|
642 | 653 | spinlock_t input_lock; /* Lock for packet input to this call */ |
---|
643 | 654 | |
---|
644 | | - /* receive-phase ACK management */ |
---|
| 655 | + /* Receive-phase ACK management (ACKs we send). */ |
---|
645 | 656 | u8 ackr_reason; /* reason to ACK */ |
---|
646 | | - u16 ackr_skew; /* skew on packet being ACK'd */ |
---|
647 | 657 | rxrpc_serial_t ackr_serial; /* serial of packet being ACK'd */ |
---|
648 | | - rxrpc_serial_t ackr_first_seq; /* first sequence number received */ |
---|
649 | | - rxrpc_seq_t ackr_prev_seq; /* previous sequence number received */ |
---|
650 | | - rxrpc_seq_t ackr_consumed; /* Highest packet shown consumed */ |
---|
651 | | - rxrpc_seq_t ackr_seen; /* Highest packet shown seen */ |
---|
| 658 | + rxrpc_seq_t ackr_highest_seq; /* Higest sequence number received */ |
---|
| 659 | + atomic_t ackr_nr_unacked; /* Number of unacked packets */ |
---|
| 660 | + atomic_t ackr_nr_consumed; /* Number of packets needing hard ACK */ |
---|
652 | 661 | |
---|
653 | | - /* ping management */ |
---|
654 | | - rxrpc_serial_t ping_serial; /* Last ping sent */ |
---|
655 | | - ktime_t ping_time; /* Time last ping sent */ |
---|
| 662 | + /* RTT management */ |
---|
| 663 | + rxrpc_serial_t rtt_serial[4]; /* Serial number of DATA or PING sent */ |
---|
| 664 | + ktime_t rtt_sent_at[4]; /* Time packet sent */ |
---|
| 665 | + unsigned long rtt_avail; /* Mask of available slots in bits 0-3, |
---|
| 666 | + * Mask of pending samples in 8-11 */ |
---|
| 667 | +#define RXRPC_CALL_RTT_AVAIL_MASK 0xf |
---|
| 668 | +#define RXRPC_CALL_RTT_PEND_SHIFT 8 |
---|
656 | 669 | |
---|
657 | | - /* transmission-phase ACK management */ |
---|
| 670 | + /* Transmission-phase ACK management (ACKs we've received). */ |
---|
658 | 671 | ktime_t acks_latest_ts; /* Timestamp of latest ACK received */ |
---|
659 | | - rxrpc_serial_t acks_latest; /* serial number of latest ACK received */ |
---|
| 672 | + rxrpc_seq_t acks_first_seq; /* first sequence number received */ |
---|
| 673 | + rxrpc_seq_t acks_prev_seq; /* Highest previousPacket received */ |
---|
660 | 674 | rxrpc_seq_t acks_lowest_nak; /* Lowest NACK in the buffer (or ==tx_hard_ack) */ |
---|
661 | 675 | rxrpc_seq_t acks_lost_top; /* tx_top at the time lost-ack ping sent */ |
---|
662 | 676 | rxrpc_serial_t acks_lost_ping; /* Serial number of probe ACK */ |
---|
.. | .. |
---|
689 | 703 | enum rxrpc_command { |
---|
690 | 704 | RXRPC_CMD_SEND_DATA, /* send data message */ |
---|
691 | 705 | RXRPC_CMD_SEND_ABORT, /* request abort generation */ |
---|
692 | | - RXRPC_CMD_ACCEPT, /* [server] accept incoming call */ |
---|
693 | 706 | RXRPC_CMD_REJECT_BUSY, /* [server] reject a call as busy */ |
---|
| 707 | + RXRPC_CMD_CHARGE_ACCEPT, /* [server] charge accept preallocation */ |
---|
694 | 708 | }; |
---|
695 | 709 | |
---|
696 | 710 | struct rxrpc_call_params { |
---|
.. | .. |
---|
702 | 716 | u32 normal; /* Max time since last call packet (msec) */ |
---|
703 | 717 | } timeouts; |
---|
704 | 718 | u8 nr_timeouts; /* Number of timeouts specified */ |
---|
| 719 | + bool kernel; /* T if kernel is making the call */ |
---|
| 720 | + enum rxrpc_interruptibility interruptibility; /* How is interruptible is the call? */ |
---|
705 | 721 | }; |
---|
706 | 722 | |
---|
707 | 723 | struct rxrpc_send_params { |
---|
.. | .. |
---|
729 | 745 | struct rxrpc_sock *, |
---|
730 | 746 | struct sk_buff *); |
---|
731 | 747 | void rxrpc_accept_incoming_calls(struct rxrpc_local *); |
---|
732 | | -struct rxrpc_call *rxrpc_accept_call(struct rxrpc_sock *, unsigned long, |
---|
733 | | - rxrpc_notify_rx_t); |
---|
734 | | -int rxrpc_reject_call(struct rxrpc_sock *); |
---|
| 748 | +int rxrpc_user_charge_accept(struct rxrpc_sock *, unsigned long); |
---|
735 | 749 | |
---|
736 | 750 | /* |
---|
737 | 751 | * call_event.c |
---|
738 | 752 | */ |
---|
739 | | -void rxrpc_propose_ACK(struct rxrpc_call *, u8, u16, u32, bool, bool, |
---|
| 753 | +void rxrpc_propose_ACK(struct rxrpc_call *, u8, u32, bool, bool, |
---|
740 | 754 | enum rxrpc_propose_ack_trace); |
---|
741 | 755 | void rxrpc_process_call(struct work_struct *); |
---|
742 | 756 | |
---|
743 | | -static inline void rxrpc_reduce_call_timer(struct rxrpc_call *call, |
---|
744 | | - unsigned long expire_at, |
---|
745 | | - unsigned long now, |
---|
746 | | - enum rxrpc_timer_trace why) |
---|
747 | | -{ |
---|
748 | | - trace_rxrpc_timer(call, why, now); |
---|
749 | | - timer_reduce(&call->timer, expire_at); |
---|
750 | | -} |
---|
| 757 | +void rxrpc_reduce_call_timer(struct rxrpc_call *call, |
---|
| 758 | + unsigned long expire_at, |
---|
| 759 | + unsigned long now, |
---|
| 760 | + enum rxrpc_timer_trace why); |
---|
| 761 | + |
---|
| 762 | +void rxrpc_delete_call_timer(struct rxrpc_call *call); |
---|
751 | 763 | |
---|
752 | 764 | /* |
---|
753 | 765 | * call_object.c |
---|
.. | .. |
---|
764 | 776 | struct sockaddr_rxrpc *, |
---|
765 | 777 | struct rxrpc_call_params *, gfp_t, |
---|
766 | 778 | unsigned int); |
---|
767 | | -int rxrpc_retry_client_call(struct rxrpc_sock *, |
---|
768 | | - struct rxrpc_call *, |
---|
769 | | - struct rxrpc_conn_parameters *, |
---|
770 | | - struct sockaddr_rxrpc *, |
---|
771 | | - gfp_t); |
---|
772 | 779 | void rxrpc_incoming_call(struct rxrpc_sock *, struct rxrpc_call *, |
---|
773 | 780 | struct sk_buff *); |
---|
774 | 781 | void rxrpc_release_call(struct rxrpc_sock *, struct rxrpc_call *); |
---|
775 | | -int rxrpc_prepare_call_for_retry(struct rxrpc_sock *, struct rxrpc_call *); |
---|
776 | 782 | void rxrpc_release_calls_on_socket(struct rxrpc_sock *); |
---|
777 | 783 | bool __rxrpc_queue_call(struct rxrpc_call *); |
---|
778 | 784 | bool rxrpc_queue_call(struct rxrpc_call *); |
---|
779 | 785 | void rxrpc_see_call(struct rxrpc_call *); |
---|
| 786 | +bool rxrpc_try_get_call(struct rxrpc_call *call, enum rxrpc_call_trace op); |
---|
780 | 787 | void rxrpc_get_call(struct rxrpc_call *, enum rxrpc_call_trace); |
---|
781 | 788 | void rxrpc_put_call(struct rxrpc_call *, enum rxrpc_call_trace); |
---|
782 | 789 | void rxrpc_cleanup_call(struct rxrpc_call *); |
---|
.. | .. |
---|
793 | 800 | } |
---|
794 | 801 | |
---|
795 | 802 | /* |
---|
796 | | - * Transition a call to the complete state. |
---|
797 | | - */ |
---|
798 | | -static inline bool __rxrpc_set_call_completion(struct rxrpc_call *call, |
---|
799 | | - enum rxrpc_call_completion compl, |
---|
800 | | - u32 abort_code, |
---|
801 | | - int error) |
---|
802 | | -{ |
---|
803 | | - if (call->state < RXRPC_CALL_COMPLETE) { |
---|
804 | | - call->abort_code = abort_code; |
---|
805 | | - call->error = error; |
---|
806 | | - call->completion = compl, |
---|
807 | | - call->state = RXRPC_CALL_COMPLETE; |
---|
808 | | - trace_rxrpc_call_complete(call); |
---|
809 | | - wake_up(&call->waitq); |
---|
810 | | - return true; |
---|
811 | | - } |
---|
812 | | - return false; |
---|
813 | | -} |
---|
814 | | - |
---|
815 | | -static inline bool rxrpc_set_call_completion(struct rxrpc_call *call, |
---|
816 | | - enum rxrpc_call_completion compl, |
---|
817 | | - u32 abort_code, |
---|
818 | | - int error) |
---|
819 | | -{ |
---|
820 | | - bool ret; |
---|
821 | | - |
---|
822 | | - write_lock_bh(&call->state_lock); |
---|
823 | | - ret = __rxrpc_set_call_completion(call, compl, abort_code, error); |
---|
824 | | - write_unlock_bh(&call->state_lock); |
---|
825 | | - return ret; |
---|
826 | | -} |
---|
827 | | - |
---|
828 | | -/* |
---|
829 | | - * Record that a call successfully completed. |
---|
830 | | - */ |
---|
831 | | -static inline bool __rxrpc_call_completed(struct rxrpc_call *call) |
---|
832 | | -{ |
---|
833 | | - return __rxrpc_set_call_completion(call, RXRPC_CALL_SUCCEEDED, 0, 0); |
---|
834 | | -} |
---|
835 | | - |
---|
836 | | -static inline bool rxrpc_call_completed(struct rxrpc_call *call) |
---|
837 | | -{ |
---|
838 | | - bool ret; |
---|
839 | | - |
---|
840 | | - write_lock_bh(&call->state_lock); |
---|
841 | | - ret = __rxrpc_call_completed(call); |
---|
842 | | - write_unlock_bh(&call->state_lock); |
---|
843 | | - return ret; |
---|
844 | | -} |
---|
845 | | - |
---|
846 | | -/* |
---|
847 | | - * Record that a call is locally aborted. |
---|
848 | | - */ |
---|
849 | | -static inline bool __rxrpc_abort_call(const char *why, struct rxrpc_call *call, |
---|
850 | | - rxrpc_seq_t seq, |
---|
851 | | - u32 abort_code, int error) |
---|
852 | | -{ |
---|
853 | | - trace_rxrpc_abort(call->debug_id, why, call->cid, call->call_id, seq, |
---|
854 | | - abort_code, error); |
---|
855 | | - return __rxrpc_set_call_completion(call, RXRPC_CALL_LOCALLY_ABORTED, |
---|
856 | | - abort_code, error); |
---|
857 | | -} |
---|
858 | | - |
---|
859 | | -static inline bool rxrpc_abort_call(const char *why, struct rxrpc_call *call, |
---|
860 | | - rxrpc_seq_t seq, u32 abort_code, int error) |
---|
861 | | -{ |
---|
862 | | - bool ret; |
---|
863 | | - |
---|
864 | | - write_lock_bh(&call->state_lock); |
---|
865 | | - ret = __rxrpc_abort_call(why, call, seq, abort_code, error); |
---|
866 | | - write_unlock_bh(&call->state_lock); |
---|
867 | | - return ret; |
---|
868 | | -} |
---|
869 | | - |
---|
870 | | -/* |
---|
871 | | - * Abort a call due to a protocol error. |
---|
872 | | - */ |
---|
873 | | -static inline bool __rxrpc_abort_eproto(struct rxrpc_call *call, |
---|
874 | | - struct sk_buff *skb, |
---|
875 | | - const char *eproto_why, |
---|
876 | | - const char *why, |
---|
877 | | - u32 abort_code) |
---|
878 | | -{ |
---|
879 | | - struct rxrpc_skb_priv *sp = rxrpc_skb(skb); |
---|
880 | | - |
---|
881 | | - trace_rxrpc_rx_eproto(call, sp->hdr.serial, eproto_why); |
---|
882 | | - return rxrpc_abort_call(why, call, sp->hdr.seq, abort_code, -EPROTO); |
---|
883 | | -} |
---|
884 | | - |
---|
885 | | -#define rxrpc_abort_eproto(call, skb, eproto_why, abort_why, abort_code) \ |
---|
886 | | - __rxrpc_abort_eproto((call), (skb), tracepoint_string(eproto_why), \ |
---|
887 | | - (abort_why), (abort_code)) |
---|
888 | | - |
---|
889 | | -/* |
---|
890 | 803 | * conn_client.c |
---|
891 | 804 | */ |
---|
892 | | -extern unsigned int rxrpc_max_client_connections; |
---|
893 | 805 | extern unsigned int rxrpc_reap_client_connections; |
---|
894 | 806 | extern unsigned long rxrpc_conn_idle_client_expiry; |
---|
895 | 807 | extern unsigned long rxrpc_conn_idle_client_fast_expiry; |
---|
896 | 808 | extern struct idr rxrpc_client_conn_ids; |
---|
897 | 809 | |
---|
898 | 810 | void rxrpc_destroy_client_conn_ids(void); |
---|
| 811 | +struct rxrpc_bundle *rxrpc_get_bundle(struct rxrpc_bundle *); |
---|
| 812 | +void rxrpc_put_bundle(struct rxrpc_bundle *); |
---|
899 | 813 | int rxrpc_connect_call(struct rxrpc_sock *, struct rxrpc_call *, |
---|
900 | 814 | struct rxrpc_conn_parameters *, struct sockaddr_rxrpc *, |
---|
901 | 815 | gfp_t); |
---|
902 | 816 | void rxrpc_expose_client_call(struct rxrpc_call *); |
---|
903 | | -void rxrpc_disconnect_client_call(struct rxrpc_call *); |
---|
| 817 | +void rxrpc_disconnect_client_call(struct rxrpc_bundle *, struct rxrpc_call *); |
---|
904 | 818 | void rxrpc_put_client_conn(struct rxrpc_connection *); |
---|
905 | 819 | void rxrpc_discard_expired_client_conns(struct work_struct *); |
---|
906 | 820 | void rxrpc_destroy_all_client_connections(struct rxrpc_net *); |
---|
.. | .. |
---|
910 | 824 | * conn_event.c |
---|
911 | 825 | */ |
---|
912 | 826 | void rxrpc_process_connection(struct work_struct *); |
---|
| 827 | +void rxrpc_process_delayed_final_acks(struct rxrpc_connection *, bool); |
---|
913 | 828 | |
---|
914 | 829 | /* |
---|
915 | 830 | * conn_object.c |
---|
.. | .. |
---|
926 | 841 | void rxrpc_kill_connection(struct rxrpc_connection *); |
---|
927 | 842 | bool rxrpc_queue_conn(struct rxrpc_connection *); |
---|
928 | 843 | void rxrpc_see_connection(struct rxrpc_connection *); |
---|
929 | | -void rxrpc_get_connection(struct rxrpc_connection *); |
---|
| 844 | +struct rxrpc_connection *rxrpc_get_connection(struct rxrpc_connection *); |
---|
930 | 845 | struct rxrpc_connection *rxrpc_get_connection_maybe(struct rxrpc_connection *); |
---|
931 | 846 | void rxrpc_put_service_conn(struct rxrpc_connection *); |
---|
932 | 847 | void rxrpc_service_connection_reaper(struct work_struct *); |
---|
.. | .. |
---|
965 | 880 | struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *, |
---|
966 | 881 | struct sk_buff *); |
---|
967 | 882 | struct rxrpc_connection *rxrpc_prealloc_service_connection(struct rxrpc_net *, gfp_t); |
---|
968 | | -void rxrpc_new_incoming_connection(struct rxrpc_sock *, |
---|
969 | | - struct rxrpc_connection *, struct sk_buff *); |
---|
| 883 | +void rxrpc_new_incoming_connection(struct rxrpc_sock *, struct rxrpc_connection *, |
---|
| 884 | + const struct rxrpc_security *, struct key *, |
---|
| 885 | + struct sk_buff *); |
---|
970 | 886 | void rxrpc_unpublish_service_conn(struct rxrpc_connection *); |
---|
971 | 887 | |
---|
972 | 888 | /* |
---|
.. | .. |
---|
985 | 901 | extern struct key_type key_type_rxrpc; |
---|
986 | 902 | extern struct key_type key_type_rxrpc_s; |
---|
987 | 903 | |
---|
988 | | -int rxrpc_request_key(struct rxrpc_sock *, char __user *, int); |
---|
989 | | -int rxrpc_server_keyring(struct rxrpc_sock *, char __user *, int); |
---|
| 904 | +int rxrpc_request_key(struct rxrpc_sock *, sockptr_t , int); |
---|
| 905 | +int rxrpc_server_keyring(struct rxrpc_sock *, sockptr_t, int); |
---|
990 | 906 | int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time64_t, |
---|
991 | 907 | u32); |
---|
992 | 908 | |
---|
.. | .. |
---|
1027 | 943 | extern unsigned int rxrpc_rx_window_size; |
---|
1028 | 944 | extern unsigned int rxrpc_rx_mtu; |
---|
1029 | 945 | extern unsigned int rxrpc_rx_jumbo_max; |
---|
1030 | | -extern unsigned long rxrpc_resend_timeout; |
---|
1031 | 946 | |
---|
1032 | 947 | extern const s8 rxrpc_ack_priority[]; |
---|
1033 | 948 | |
---|
.. | .. |
---|
1055 | 970 | * peer_event.c |
---|
1056 | 971 | */ |
---|
1057 | 972 | void rxrpc_error_report(struct sock *); |
---|
1058 | | -void rxrpc_peer_add_rtt(struct rxrpc_call *, enum rxrpc_rtt_rx_trace, |
---|
1059 | | - rxrpc_serial_t, rxrpc_serial_t, ktime_t, ktime_t); |
---|
1060 | 973 | void rxrpc_peer_keepalive_worker(struct work_struct *); |
---|
1061 | 974 | |
---|
1062 | 975 | /* |
---|
.. | .. |
---|
1080 | 993 | */ |
---|
1081 | 994 | extern const struct seq_operations rxrpc_call_seq_ops; |
---|
1082 | 995 | extern const struct seq_operations rxrpc_connection_seq_ops; |
---|
| 996 | +extern const struct seq_operations rxrpc_peer_seq_ops; |
---|
| 997 | +extern const struct seq_operations rxrpc_local_seq_ops; |
---|
1083 | 998 | |
---|
1084 | 999 | /* |
---|
1085 | 1000 | * recvmsg.c |
---|
1086 | 1001 | */ |
---|
1087 | 1002 | void rxrpc_notify_socket(struct rxrpc_call *); |
---|
| 1003 | +bool __rxrpc_set_call_completion(struct rxrpc_call *, enum rxrpc_call_completion, u32, int); |
---|
| 1004 | +bool rxrpc_set_call_completion(struct rxrpc_call *, enum rxrpc_call_completion, u32, int); |
---|
| 1005 | +bool __rxrpc_call_completed(struct rxrpc_call *); |
---|
| 1006 | +bool rxrpc_call_completed(struct rxrpc_call *); |
---|
| 1007 | +bool __rxrpc_abort_call(const char *, struct rxrpc_call *, rxrpc_seq_t, u32, int); |
---|
| 1008 | +bool rxrpc_abort_call(const char *, struct rxrpc_call *, rxrpc_seq_t, u32, int); |
---|
1088 | 1009 | int rxrpc_recvmsg(struct socket *, struct msghdr *, size_t, int); |
---|
| 1010 | + |
---|
| 1011 | +/* |
---|
| 1012 | + * Abort a call due to a protocol error. |
---|
| 1013 | + */ |
---|
| 1014 | +static inline bool __rxrpc_abort_eproto(struct rxrpc_call *call, |
---|
| 1015 | + struct sk_buff *skb, |
---|
| 1016 | + const char *eproto_why, |
---|
| 1017 | + const char *why, |
---|
| 1018 | + u32 abort_code) |
---|
| 1019 | +{ |
---|
| 1020 | + struct rxrpc_skb_priv *sp = rxrpc_skb(skb); |
---|
| 1021 | + |
---|
| 1022 | + trace_rxrpc_rx_eproto(call, sp->hdr.serial, eproto_why); |
---|
| 1023 | + return rxrpc_abort_call(why, call, sp->hdr.seq, abort_code, -EPROTO); |
---|
| 1024 | +} |
---|
| 1025 | + |
---|
| 1026 | +#define rxrpc_abort_eproto(call, skb, eproto_why, abort_why, abort_code) \ |
---|
| 1027 | + __rxrpc_abort_eproto((call), (skb), tracepoint_string(eproto_why), \ |
---|
| 1028 | + (abort_why), (abort_code)) |
---|
| 1029 | + |
---|
| 1030 | +/* |
---|
| 1031 | + * rtt.c |
---|
| 1032 | + */ |
---|
| 1033 | +void rxrpc_peer_add_rtt(struct rxrpc_call *, enum rxrpc_rtt_rx_trace, int, |
---|
| 1034 | + rxrpc_serial_t, rxrpc_serial_t, ktime_t, ktime_t); |
---|
| 1035 | +unsigned long rxrpc_get_rto_backoff(struct rxrpc_peer *, bool); |
---|
| 1036 | +void rxrpc_peer_init_rtt(struct rxrpc_peer *); |
---|
1089 | 1037 | |
---|
1090 | 1038 | /* |
---|
1091 | 1039 | * rxkad.c |
---|
.. | .. |
---|
1100 | 1048 | int __init rxrpc_init_security(void); |
---|
1101 | 1049 | void rxrpc_exit_security(void); |
---|
1102 | 1050 | int rxrpc_init_client_conn_security(struct rxrpc_connection *); |
---|
1103 | | -int rxrpc_init_server_conn_security(struct rxrpc_connection *); |
---|
| 1051 | +bool rxrpc_look_up_server_security(struct rxrpc_local *, struct rxrpc_sock *, |
---|
| 1052 | + const struct rxrpc_security **, struct key **, |
---|
| 1053 | + struct sk_buff *); |
---|
1104 | 1054 | |
---|
1105 | 1055 | /* |
---|
1106 | 1056 | * sendmsg.c |
---|
.. | .. |
---|
1114 | 1064 | void rxrpc_packet_destructor(struct sk_buff *); |
---|
1115 | 1065 | void rxrpc_new_skb(struct sk_buff *, enum rxrpc_skb_trace); |
---|
1116 | 1066 | void rxrpc_see_skb(struct sk_buff *, enum rxrpc_skb_trace); |
---|
| 1067 | +void rxrpc_eaten_skb(struct sk_buff *, enum rxrpc_skb_trace); |
---|
1117 | 1068 | void rxrpc_get_skb(struct sk_buff *, enum rxrpc_skb_trace); |
---|
1118 | 1069 | void rxrpc_free_skb(struct sk_buff *, enum rxrpc_skb_trace); |
---|
1119 | | -void rxrpc_lose_skb(struct sk_buff *, enum rxrpc_skb_trace); |
---|
1120 | 1070 | void rxrpc_purge_queue(struct sk_buff_head *); |
---|
1121 | 1071 | |
---|
1122 | 1072 | /* |
---|
.. | .. |
---|
1133 | 1083 | /* |
---|
1134 | 1084 | * utils.c |
---|
1135 | 1085 | */ |
---|
1136 | | -int rxrpc_extract_addr_from_skb(struct rxrpc_local *, struct sockaddr_rxrpc *, |
---|
1137 | | - struct sk_buff *); |
---|
| 1086 | +int rxrpc_extract_addr_from_skb(struct sockaddr_rxrpc *, struct sk_buff *); |
---|
1138 | 1087 | |
---|
1139 | 1088 | static inline bool before(u32 seq1, u32 seq2) |
---|
1140 | 1089 | { |
---|