hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/rxrpc/ar-internal.h
....@@ -1,29 +1,18 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /* AF_RXRPC internal definitions
23 *
34 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
45 * 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.
106 */
117
128 #include <linux/atomic.h>
139 #include <linux/seqlock.h>
10
+#include <linux/win_minmax.h>
1411 #include <net/net_namespace.h>
1512 #include <net/netns/generic.h>
1613 #include <net/sock.h>
1714 #include <net/af_rxrpc.h>
1815 #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
2716
2817 #define FCRYPT_BSIZE 8
2918 struct rxrpc_crypt {
....@@ -79,19 +68,17 @@
7968 struct work_struct service_conn_reaper;
8069 struct timer_list service_conn_reap_timer;
8170
82
- unsigned int nr_client_conns;
83
- unsigned int nr_active_client_conns;
84
- bool kill_all_client_conns;
8571 bool live;
72
+
73
+ bool kill_all_client_conns;
74
+ atomic_t nr_client_conns;
8675 spinlock_t client_conn_cache_lock; /* Lock for ->*_client_conns */
8776 spinlock_t client_conn_discard_lock; /* Prevent multiple discarders */
88
- struct list_head waiting_client_conns;
89
- struct list_head active_client_conns;
9077 struct list_head idle_client_conns;
9178 struct work_struct client_conn_reaper;
9279 struct timer_list client_conn_reap_timer;
9380
94
- struct list_head local_endpoints;
81
+ struct hlist_head local_endpoints;
9582 struct mutex local_mutex; /* Lock for ->local_endpoints */
9683
9784 DECLARE_HASHTABLE (peer_hash, 10);
....@@ -189,11 +176,17 @@
189176 * - max 48 bytes (struct sk_buff::cb)
190177 */
191178 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 */
195184 union {
196185 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];
197190 };
198191
199192 struct rxrpc_host_header hdr; /* RxRPC packet header from this packet */
....@@ -207,6 +200,7 @@
207200 struct rxrpc_security {
208201 const char *name; /* name of this service */
209202 u8 security_index; /* security type provided */
203
+ u32 no_key_abort; /* Abort code indicating no key */
210204
211205 /* Initialise a security service */
212206 int (*init)(void);
....@@ -229,6 +223,9 @@
229223 /* verify the security on a received packet */
230224 int (*verify_packet)(struct rxrpc_call *, struct sk_buff *,
231225 unsigned int, unsigned int, rxrpc_seq_t, u16);
226
+
227
+ /* Free crypto request on a call */
228
+ void (*free_call_crypto)(struct rxrpc_call *);
232229
233230 /* Locate the data in a received packet that has been verified. */
234231 void (*locate_data)(struct rxrpc_call *, struct sk_buff *,
....@@ -259,17 +256,17 @@
259256 struct rxrpc_local {
260257 struct rcu_head rcu;
261258 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 */
263260 struct rxrpc_net *rxnet; /* The network ns in which this resides */
264
- struct list_head link;
261
+ struct hlist_node link;
265262 struct socket *socket; /* my UDP socket */
266263 struct work_struct processor;
267264 struct rxrpc_sock __rcu *service; /* Service(s) listening on this endpoint */
268265 struct rw_semaphore defrag_sem; /* control re-enablement of IP DF bit */
269266 struct sk_buff_head reject_queue; /* packets awaiting rejection */
270267 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 */
273270 spinlock_t lock; /* access lock */
274271 rwlock_t services_lock; /* lock for services list */
275272 int debug_id; /* debug ID for printks */
....@@ -284,7 +281,7 @@
284281 */
285282 struct rxrpc_peer {
286283 struct rcu_head rcu; /* This must be first */
287
- atomic_t usage;
284
+ refcount_t ref;
288285 unsigned long hash_key;
289286 struct hlist_node hash_link;
290287 struct rxrpc_local *local;
....@@ -305,11 +302,14 @@
305302 #define RXRPC_RTT_CACHE_SIZE 32
306303 spinlock_t rtt_input_lock; /* RTT lock for input routine */
307304 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 */
313313
314314 u8 cong_cwnd; /* Congestion window size */
315315 };
....@@ -343,10 +343,7 @@
343343 enum rxrpc_conn_flag {
344344 RXRPC_CONN_HAS_IDR, /* Has a client conn ID assigned */
345345 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 */
348346 RXRPC_CONN_DONT_REUSE, /* Don't reuse this connection */
349
- RXRPC_CONN_COUNTED, /* Counted by rxrpc_nr_client_conns */
350347 RXRPC_CONN_PROBING_FOR_UPGRADE, /* Probing for service upgrade */
351348 RXRPC_CONN_FINAL_ACK_0, /* Need final ACK for channel 0 */
352349 RXRPC_CONN_FINAL_ACK_1, /* Need final ACK for channel 1 */
....@@ -367,19 +364,6 @@
367364 };
368365
369366 /*
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
-/*
383367 * The connection protocol state.
384368 */
385369 enum rxrpc_conn_proto_state {
....@@ -395,6 +379,24 @@
395379 };
396380
397381 /*
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
+/*
398400 * RxRPC connection definition
399401 * - matched by { local, peer, epoch, conn_id, direction }
400402 * - each connection can only handle four simultaneous calls
....@@ -403,14 +405,11 @@
403405 struct rxrpc_conn_proto proto;
404406 struct rxrpc_conn_parameters params;
405407
406
- atomic_t usage;
408
+ refcount_t ref;
407409 struct rcu_head rcu;
408410 struct list_head cache_link;
409411
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 */
414413 struct rxrpc_channel {
415414 unsigned long final_ack_at; /* Time at which to issue final ACK */
416415 struct rxrpc_call __rcu *call; /* Active call */
....@@ -427,22 +426,19 @@
427426
428427 struct timer_list timer; /* Conn event timer */
429428 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 */
434431 struct list_head proc_link; /* link in procfs list */
435432 struct list_head link; /* link in master connection list */
436433 struct sk_buff_head rx_queue; /* received conn-level packets */
437434 const struct rxrpc_security *security; /* applied security module */
438435 struct key *server_key; /* security for this service */
439
- struct crypto_skcipher *cipher; /* encryption handle */
436
+ struct crypto_sync_skcipher *cipher; /* encryption handle */
440437 struct rxrpc_crypt csum_iv; /* packet checksum base */
441438 unsigned long flags;
442439 unsigned long events;
443440 unsigned long idle_timestamp; /* Time at which last became idle */
444441 spinlock_t state_lock; /* state-change lock */
445
- enum rxrpc_conn_cache_state cache_state;
446442 enum rxrpc_conn_proto_state state; /* current state of connection */
447443 u32 abort_code; /* Abort code of connection abort */
448444 int debug_id; /* debug ID for printks */
....@@ -454,6 +450,7 @@
454450 u8 security_size; /* security header size */
455451 u8 security_ix; /* security type */
456452 u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
453
+ u8 bundle_shift; /* Index into bundle->avail_chans */
457454 short error; /* Local error code */
458455 };
459456
....@@ -477,14 +474,14 @@
477474 RXRPC_CALL_EXPOSED, /* The call was exposed to the world */
478475 RXRPC_CALL_RX_LAST, /* Received the last packet (at rxtx_top) */
479476 RXRPC_CALL_TX_LAST, /* Last packet in Tx buffer (at rxtx_top) */
480
- RXRPC_CALL_TX_LASTQ, /* Last packet has been queued */
481477 RXRPC_CALL_SEND_PING, /* A ping will need to be sent */
482
- RXRPC_CALL_PINGING, /* Ping in process */
483478 RXRPC_CALL_RETRANS_TIMEOUT, /* Retransmission due to timeout occurred */
484479 RXRPC_CALL_BEGAN_RX_TIMER, /* We began the expect_rx_by timer */
485480 RXRPC_CALL_RX_HEARD, /* The peer responded at least once to this call */
486481 RXRPC_CALL_RX_UNDERRUN, /* Got data underrun */
487482 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 */
488485 };
489486
490487 /*
....@@ -510,13 +507,24 @@
510507 RXRPC_CALL_CLIENT_RECV_REPLY, /* - client receiving reply phase */
511508 RXRPC_CALL_SERVER_PREALLOC, /* - service preallocation */
512509 RXRPC_CALL_SERVER_SECURING, /* - server securing request connection */
513
- RXRPC_CALL_SERVER_ACCEPTING, /* - server accepting request */
514510 RXRPC_CALL_SERVER_RECV_REQUEST, /* - server receiving request */
515511 RXRPC_CALL_SERVER_ACK_REQUEST, /* - server pending ACK of request */
516512 RXRPC_CALL_SERVER_SEND_REPLY, /* - server sending reply */
517513 RXRPC_CALL_SERVER_AWAIT_ACK, /* - server awaiting final ACK */
518514 RXRPC_CALL_COMPLETE, /* - call complete */
519515 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
520528 };
521529
522530 /*
....@@ -540,6 +548,7 @@
540548 struct rxrpc_peer *peer; /* Peer record for remote address */
541549 struct rxrpc_sock __rcu *socket; /* socket responsible */
542550 struct rxrpc_net *rxnet; /* Network namespace to which call belongs */
551
+ const struct rxrpc_security *security; /* applied security module */
543552 struct mutex user_mutex; /* User access mutex */
544553 unsigned long ack_at; /* When deferred ACK needs to happen */
545554 unsigned long ack_lost_at; /* When ACK is figured as lost */
....@@ -551,11 +560,12 @@
551560 unsigned long expect_term_by; /* When we expect call termination by */
552561 u32 next_rx_timo; /* Timeout for next Rx packet (jif) */
553562 u32 next_req_timo; /* Timeout for next Rx request packet (jif) */
563
+ struct skcipher_request *cipher_req; /* Packet cipher request buffer */
554564 struct timer_list timer; /* Combined event timer */
555565 struct work_struct processor; /* Event processor */
556566 rxrpc_notify_rx_t notify_rx; /* kernel service Rx notification function */
557567 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 */
559569 struct hlist_node error_link; /* link in error distribution list */
560570 struct list_head accept_link; /* Link in rx->acceptq */
561571 struct list_head recvmsg_link; /* Link in rx->recvmsg_q */
....@@ -575,14 +585,16 @@
575585 int error; /* Local error incurred */
576586 enum rxrpc_call_state state; /* current state of call */
577587 enum rxrpc_call_completion completion; /* Call completion condition */
578
- atomic_t usage;
588
+ refcount_t ref;
579589 u16 service_id; /* service ID */
580590 u8 security_ix; /* Security type */
591
+ enum rxrpc_interruptibility interruptibility; /* At what point call may be interrupted */
581592 u32 call_id; /* call ID on connection */
582593 u32 cid; /* connection ID plus channel index */
583594 int debug_id; /* debug ID for printks */
584595 unsigned short rx_pkt_offset; /* Current recvmsg packet offset */
585596 unsigned short rx_pkt_len; /* Current recvmsg packet len */
597
+ bool rx_pkt_last; /* Current recvmsg packet is last */
586598
587599 /* Rx/Tx circular buffer, depending on phase.
588600 *
....@@ -606,8 +618,7 @@
606618 #define RXRPC_TX_ANNO_LAST 0x04
607619 #define RXRPC_TX_ANNO_RESENT 0x08
608620
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 */
611622 #define RXRPC_RX_ANNO_VERIFIED 0x80 /* Set if verified and decrypted */
612623 rxrpc_seq_t tx_hard_ack; /* Dead slot in buffer; the first transmitted but
613624 * not hard-ACK'd packet follows this.
....@@ -641,22 +652,25 @@
641652
642653 spinlock_t input_lock; /* Lock for packet input to this call */
643654
644
- /* receive-phase ACK management */
655
+ /* Receive-phase ACK management (ACKs we send). */
645656 u8 ackr_reason; /* reason to ACK */
646
- u16 ackr_skew; /* skew on packet being ACK'd */
647657 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 */
652661
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
656669
657
- /* transmission-phase ACK management */
670
+ /* Transmission-phase ACK management (ACKs we've received). */
658671 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 */
660674 rxrpc_seq_t acks_lowest_nak; /* Lowest NACK in the buffer (or ==tx_hard_ack) */
661675 rxrpc_seq_t acks_lost_top; /* tx_top at the time lost-ack ping sent */
662676 rxrpc_serial_t acks_lost_ping; /* Serial number of probe ACK */
....@@ -689,8 +703,8 @@
689703 enum rxrpc_command {
690704 RXRPC_CMD_SEND_DATA, /* send data message */
691705 RXRPC_CMD_SEND_ABORT, /* request abort generation */
692
- RXRPC_CMD_ACCEPT, /* [server] accept incoming call */
693706 RXRPC_CMD_REJECT_BUSY, /* [server] reject a call as busy */
707
+ RXRPC_CMD_CHARGE_ACCEPT, /* [server] charge accept preallocation */
694708 };
695709
696710 struct rxrpc_call_params {
....@@ -702,6 +716,8 @@
702716 u32 normal; /* Max time since last call packet (msec) */
703717 } timeouts;
704718 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? */
705721 };
706722
707723 struct rxrpc_send_params {
....@@ -729,25 +745,21 @@
729745 struct rxrpc_sock *,
730746 struct sk_buff *);
731747 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);
735749
736750 /*
737751 * call_event.c
738752 */
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,
740754 enum rxrpc_propose_ack_trace);
741755 void rxrpc_process_call(struct work_struct *);
742756
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);
751763
752764 /*
753765 * call_object.c
....@@ -764,19 +776,14 @@
764776 struct sockaddr_rxrpc *,
765777 struct rxrpc_call_params *, gfp_t,
766778 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);
772779 void rxrpc_incoming_call(struct rxrpc_sock *, struct rxrpc_call *,
773780 struct sk_buff *);
774781 void rxrpc_release_call(struct rxrpc_sock *, struct rxrpc_call *);
775
-int rxrpc_prepare_call_for_retry(struct rxrpc_sock *, struct rxrpc_call *);
776782 void rxrpc_release_calls_on_socket(struct rxrpc_sock *);
777783 bool __rxrpc_queue_call(struct rxrpc_call *);
778784 bool rxrpc_queue_call(struct rxrpc_call *);
779785 void rxrpc_see_call(struct rxrpc_call *);
786
+bool rxrpc_try_get_call(struct rxrpc_call *call, enum rxrpc_call_trace op);
780787 void rxrpc_get_call(struct rxrpc_call *, enum rxrpc_call_trace);
781788 void rxrpc_put_call(struct rxrpc_call *, enum rxrpc_call_trace);
782789 void rxrpc_cleanup_call(struct rxrpc_call *);
....@@ -793,114 +800,21 @@
793800 }
794801
795802 /*
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
-/*
890803 * conn_client.c
891804 */
892
-extern unsigned int rxrpc_max_client_connections;
893805 extern unsigned int rxrpc_reap_client_connections;
894806 extern unsigned long rxrpc_conn_idle_client_expiry;
895807 extern unsigned long rxrpc_conn_idle_client_fast_expiry;
896808 extern struct idr rxrpc_client_conn_ids;
897809
898810 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 *);
899813 int rxrpc_connect_call(struct rxrpc_sock *, struct rxrpc_call *,
900814 struct rxrpc_conn_parameters *, struct sockaddr_rxrpc *,
901815 gfp_t);
902816 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 *);
904818 void rxrpc_put_client_conn(struct rxrpc_connection *);
905819 void rxrpc_discard_expired_client_conns(struct work_struct *);
906820 void rxrpc_destroy_all_client_connections(struct rxrpc_net *);
....@@ -910,6 +824,7 @@
910824 * conn_event.c
911825 */
912826 void rxrpc_process_connection(struct work_struct *);
827
+void rxrpc_process_delayed_final_acks(struct rxrpc_connection *, bool);
913828
914829 /*
915830 * conn_object.c
....@@ -926,7 +841,7 @@
926841 void rxrpc_kill_connection(struct rxrpc_connection *);
927842 bool rxrpc_queue_conn(struct rxrpc_connection *);
928843 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 *);
930845 struct rxrpc_connection *rxrpc_get_connection_maybe(struct rxrpc_connection *);
931846 void rxrpc_put_service_conn(struct rxrpc_connection *);
932847 void rxrpc_service_connection_reaper(struct work_struct *);
....@@ -965,8 +880,9 @@
965880 struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *,
966881 struct sk_buff *);
967882 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 *);
970886 void rxrpc_unpublish_service_conn(struct rxrpc_connection *);
971887
972888 /*
....@@ -985,8 +901,8 @@
985901 extern struct key_type key_type_rxrpc;
986902 extern struct key_type key_type_rxrpc_s;
987903
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);
990906 int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time64_t,
991907 u32);
992908
....@@ -1027,7 +943,6 @@
1027943 extern unsigned int rxrpc_rx_window_size;
1028944 extern unsigned int rxrpc_rx_mtu;
1029945 extern unsigned int rxrpc_rx_jumbo_max;
1030
-extern unsigned long rxrpc_resend_timeout;
1031946
1032947 extern const s8 rxrpc_ack_priority[];
1033948
....@@ -1055,8 +970,6 @@
1055970 * peer_event.c
1056971 */
1057972 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);
1060973 void rxrpc_peer_keepalive_worker(struct work_struct *);
1061974
1062975 /*
....@@ -1080,12 +993,47 @@
1080993 */
1081994 extern const struct seq_operations rxrpc_call_seq_ops;
1082995 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;
1083998
1084999 /*
10851000 * recvmsg.c
10861001 */
10871002 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);
10881009 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 *);
10891037
10901038 /*
10911039 * rxkad.c
....@@ -1100,7 +1048,9 @@
11001048 int __init rxrpc_init_security(void);
11011049 void rxrpc_exit_security(void);
11021050 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 *);
11041054
11051055 /*
11061056 * sendmsg.c
....@@ -1114,9 +1064,9 @@
11141064 void rxrpc_packet_destructor(struct sk_buff *);
11151065 void rxrpc_new_skb(struct sk_buff *, enum rxrpc_skb_trace);
11161066 void rxrpc_see_skb(struct sk_buff *, enum rxrpc_skb_trace);
1067
+void rxrpc_eaten_skb(struct sk_buff *, enum rxrpc_skb_trace);
11171068 void rxrpc_get_skb(struct sk_buff *, enum rxrpc_skb_trace);
11181069 void rxrpc_free_skb(struct sk_buff *, enum rxrpc_skb_trace);
1119
-void rxrpc_lose_skb(struct sk_buff *, enum rxrpc_skb_trace);
11201070 void rxrpc_purge_queue(struct sk_buff_head *);
11211071
11221072 /*
....@@ -1133,8 +1083,7 @@
11331083 /*
11341084 * utils.c
11351085 */
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 *);
11381087
11391088 static inline bool before(u32 seq1, u32 seq2)
11401089 {