Merge tag '5.11-rc-smb3' of git://git.samba.org/sfrench/cifs-2.6
[linux-2.6-microblaze.git] / net / rxrpc / ar-internal.h
index 97aebb5..7bd6f8a 100644 (file)
@@ -12,6 +12,7 @@
 #include <net/netns/generic.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
+#include <keys/rxrpc-type.h>
 #include "protocol.h"
 
 #if 0
@@ -34,6 +35,7 @@ struct rxrpc_crypt {
 #define rxrpc_queue_delayed_work(WS,D) \
        queue_delayed_work(rxrpc_workqueue, (WS), (D))
 
+struct key_preparsed_payload;
 struct rxrpc_connection;
 
 /*
@@ -76,14 +78,12 @@ struct rxrpc_net {
        struct work_struct      service_conn_reaper;
        struct timer_list       service_conn_reap_timer;
 
-       unsigned int            nr_client_conns;
-       unsigned int            nr_active_client_conns;
-       bool                    kill_all_client_conns;
        bool                    live;
+
+       bool                    kill_all_client_conns;
+       atomic_t                nr_client_conns;
        spinlock_t              client_conn_cache_lock; /* Lock for ->*_client_conns */
        spinlock_t              client_conn_discard_lock; /* Prevent multiple discarders */
-       struct list_head        waiting_client_conns;
-       struct list_head        active_client_conns;
        struct list_head        idle_client_conns;
        struct work_struct      client_conn_reaper;
        struct timer_list       client_conn_reap_timer;
@@ -218,17 +218,30 @@ struct rxrpc_security {
        /* Clean up a security service */
        void (*exit)(void);
 
+       /* Parse the information from a server key */
+       int (*preparse_server_key)(struct key_preparsed_payload *);
+
+       /* Clean up the preparse buffer after parsing a server key */
+       void (*free_preparse_server_key)(struct key_preparsed_payload *);
+
+       /* Destroy the payload of a server key */
+       void (*destroy_server_key)(struct key *);
+
+       /* Describe a server key */
+       void (*describe_server_key)(const struct key *, struct seq_file *);
+
        /* initialise a connection's security */
-       int (*init_connection_security)(struct rxrpc_connection *);
+       int (*init_connection_security)(struct rxrpc_connection *,
+                                       struct rxrpc_key_token *);
 
-       /* prime a connection's packet security */
-       int (*prime_packet_security)(struct rxrpc_connection *);
+       /* Work out how much data we can store in a packet, given an estimate
+        * of the amount of data remaining.
+        */
+       int (*how_much_data)(struct rxrpc_call *, size_t,
+                            size_t *, size_t *, size_t *);
 
        /* impose security on a packet */
-       int (*secure_packet)(struct rxrpc_call *,
-                            struct sk_buff *,
-                            size_t,
-                            void *);
+       int (*secure_packet)(struct rxrpc_call *, struct sk_buff *, size_t);
 
        /* verify the security on a received packet */
        int (*verify_packet)(struct rxrpc_call *, struct sk_buff *,
@@ -275,8 +288,8 @@ struct rxrpc_local {
        struct rw_semaphore     defrag_sem;     /* control re-enablement of IP DF bit */
        struct sk_buff_head     reject_queue;   /* packets awaiting rejection */
        struct sk_buff_head     event_queue;    /* endpoint event packets awaiting processing */
-       struct rb_root          client_conns;   /* Client connections by socket params */
-       spinlock_t              client_conns_lock; /* Lock for client_conns */
+       struct rb_root          client_bundles; /* Client connection bundles by socket params */
+       spinlock_t              client_bundles_lock; /* Lock for client_bundles */
        spinlock_t              lock;           /* access lock */
        rwlock_t                services_lock;  /* lock for services list */
        int                     debug_id;       /* debug ID for printks */
@@ -353,10 +366,7 @@ struct rxrpc_conn_parameters {
 enum rxrpc_conn_flag {
        RXRPC_CONN_HAS_IDR,             /* Has a client conn ID assigned */
        RXRPC_CONN_IN_SERVICE_CONNS,    /* Conn is in peer->service_conns */
-       RXRPC_CONN_IN_CLIENT_CONNS,     /* Conn is in local->client_conns */
-       RXRPC_CONN_EXPOSED,             /* Conn has extra ref for exposure */
        RXRPC_CONN_DONT_REUSE,          /* Don't reuse this connection */
-       RXRPC_CONN_COUNTED,             /* Counted by rxrpc_nr_client_conns */
        RXRPC_CONN_PROBING_FOR_UPGRADE, /* Probing for service upgrade */
        RXRPC_CONN_FINAL_ACK_0,         /* Need final ACK for channel 0 */
        RXRPC_CONN_FINAL_ACK_1,         /* Need final ACK for channel 1 */
@@ -376,19 +386,6 @@ enum rxrpc_conn_event {
        RXRPC_CONN_EV_CHALLENGE,        /* Send challenge packet */
 };
 
-/*
- * The connection cache state.
- */
-enum rxrpc_conn_cache_state {
-       RXRPC_CONN_CLIENT_INACTIVE,     /* Conn is not yet listed */
-       RXRPC_CONN_CLIENT_WAITING,      /* Conn is on wait list, waiting for capacity */
-       RXRPC_CONN_CLIENT_ACTIVE,       /* Conn is on active list, doing calls */
-       RXRPC_CONN_CLIENT_UPGRADE,      /* Conn is on active list, probing for upgrade */
-       RXRPC_CONN_CLIENT_CULLED,       /* Conn is culled and delisted, doing calls */
-       RXRPC_CONN_CLIENT_IDLE,         /* Conn is on idle list, doing mostly nothing */
-       RXRPC_CONN__NR_CACHE_STATES
-};
-
 /*
  * The connection protocol state.
  */
@@ -404,6 +401,23 @@ enum rxrpc_conn_proto_state {
        RXRPC_CONN__NR_STATES
 };
 
+/*
+ * RxRPC client connection bundle.
+ */
+struct rxrpc_bundle {
+       struct rxrpc_conn_parameters params;
+       atomic_t                usage;
+       unsigned int            debug_id;
+       bool                    try_upgrade;    /* True if the bundle is attempting upgrade */
+       bool                    alloc_conn;     /* True if someone's getting a conn */
+       short                   alloc_error;    /* Error from last conn allocation */
+       spinlock_t              channel_lock;
+       struct rb_node          local_node;     /* Node in local->client_conns */
+       struct list_head        waiting_calls;  /* Calls waiting for channels */
+       unsigned long           avail_chans;    /* Mask of available channels */
+       struct rxrpc_connection *conns[4];      /* The connections in the bundle (max 4) */
+};
+
 /*
  * RxRPC connection definition
  * - matched by { local, peer, epoch, conn_id, direction }
@@ -417,10 +431,7 @@ struct rxrpc_connection {
        struct rcu_head         rcu;
        struct list_head        cache_link;
 
-       spinlock_t              channel_lock;
-       unsigned char           active_chans;   /* Mask of active channels */
-#define RXRPC_ACTIVE_CHANS_MASK        ((1 << RXRPC_MAXCALLS) - 1)
-       struct list_head        waiting_calls;  /* Calls waiting for channels */
+       unsigned char           act_chans;      /* Mask of active channels */
        struct rxrpc_channel {
                unsigned long           final_ack_at;   /* Time at which to issue final ACK */
                struct rxrpc_call __rcu *call;          /* Active call */
@@ -437,33 +448,33 @@ struct rxrpc_connection {
 
        struct timer_list       timer;          /* Conn event timer */
        struct work_struct      processor;      /* connection event processor */
-       union {
-               struct rb_node  client_node;    /* Node in local->client_conns */
-               struct rb_node  service_node;   /* Node in peer->service_conns */
-       };
+       struct rxrpc_bundle     *bundle;        /* Client connection bundle */
+       struct rb_node          service_node;   /* Node in peer->service_conns */
        struct list_head        proc_link;      /* link in procfs list */
        struct list_head        link;           /* link in master connection list */
        struct sk_buff_head     rx_queue;       /* received conn-level packets */
+
        const struct rxrpc_security *security;  /* applied security module */
-       struct key              *server_key;    /* security for this service */
-       struct crypto_sync_skcipher *cipher;    /* encryption handle */
-       struct rxrpc_crypt      csum_iv;        /* packet checksum base */
+       union {
+               struct {
+                       struct crypto_sync_skcipher *cipher;    /* encryption handle */
+                       struct rxrpc_crypt csum_iv;     /* packet checksum base */
+                       u32     nonce;          /* response re-use preventer */
+               } rxkad;
+       };
        unsigned long           flags;
        unsigned long           events;
        unsigned long           idle_timestamp; /* Time at which last became idle */
        spinlock_t              state_lock;     /* state-change lock */
-       enum rxrpc_conn_cache_state cache_state;
        enum rxrpc_conn_proto_state state;      /* current state of connection */
        u32                     abort_code;     /* Abort code of connection abort */
        int                     debug_id;       /* debug ID for printks */
        atomic_t                serial;         /* packet serial number counter */
        unsigned int            hi_serial;      /* highest serial number received */
-       u32                     security_nonce; /* response re-use preventer */
        u32                     service_id;     /* Service ID, possibly upgraded */
-       u8                      size_align;     /* data size alignment (for security) */
-       u8                      security_size;  /* security header size */
        u8                      security_ix;    /* security type */
        u8                      out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
+       u8                      bundle_shift;   /* Index into bundle->avail_chans */
        short                   error;          /* Local error code */
 };
 
@@ -493,6 +504,8 @@ enum rxrpc_call_flag {
        RXRPC_CALL_RX_HEARD,            /* The peer responded at least once to this call */
        RXRPC_CALL_RX_UNDERRUN,         /* Got data underrun */
        RXRPC_CALL_DISCONNECTED,        /* The call has been disconnected */
+       RXRPC_CALL_KERNEL,              /* The call was made by the kernel */
+       RXRPC_CALL_UPGRADE,             /* Service upgrade was requested for the call */
 };
 
 /*
@@ -576,7 +589,7 @@ struct rxrpc_call {
        struct work_struct      processor;      /* Event processor */
        rxrpc_notify_rx_t       notify_rx;      /* kernel service Rx notification function */
        struct list_head        link;           /* link in master call list */
-       struct list_head        chan_wait_link; /* Link in conn->waiting_calls */
+       struct list_head        chan_wait_link; /* Link in conn->bundle->waiting_calls */
        struct hlist_node       error_link;     /* link in error distribution list */
        struct list_head        accept_link;    /* Link in rx->acceptq */
        struct list_head        recvmsg_link;   /* Link in rx->recvmsg_q */
@@ -726,6 +739,7 @@ struct rxrpc_call_params {
                u32             normal;         /* Max time since last call packet (msec) */
        } timeouts;
        u8                      nr_timeouts;    /* Number of timeouts specified */
+       bool                    kernel;         /* T if kernel is making the call */
        enum rxrpc_interruptibility interruptibility; /* How is interruptible is the call? */
 };
 
@@ -812,18 +826,19 @@ static inline bool rxrpc_is_client_call(const struct rxrpc_call *call)
 /*
  * conn_client.c
  */
-extern unsigned int rxrpc_max_client_connections;
 extern unsigned int rxrpc_reap_client_connections;
 extern unsigned long rxrpc_conn_idle_client_expiry;
 extern unsigned long rxrpc_conn_idle_client_fast_expiry;
 extern struct idr rxrpc_client_conn_ids;
 
 void rxrpc_destroy_client_conn_ids(void);
+struct rxrpc_bundle *rxrpc_get_bundle(struct rxrpc_bundle *);
+void rxrpc_put_bundle(struct rxrpc_bundle *);
 int rxrpc_connect_call(struct rxrpc_sock *, struct rxrpc_call *,
                       struct rxrpc_conn_parameters *, struct sockaddr_rxrpc *,
                       gfp_t);
 void rxrpc_expose_client_call(struct rxrpc_call *);
-void rxrpc_disconnect_client_call(struct rxrpc_call *);
+void rxrpc_disconnect_client_call(struct rxrpc_bundle *, struct rxrpc_call *);
 void rxrpc_put_client_conn(struct rxrpc_connection *);
 void rxrpc_discard_expired_client_conns(struct work_struct *);
 void rxrpc_destroy_all_client_connections(struct rxrpc_net *);
@@ -833,6 +848,7 @@ void rxrpc_clean_up_local_conns(struct rxrpc_local *);
  * conn_event.c
  */
 void rxrpc_process_connection(struct work_struct *);
+void rxrpc_process_delayed_final_acks(struct rxrpc_connection *, bool);
 
 /*
  * conn_object.c
@@ -849,7 +865,7 @@ void rxrpc_disconnect_call(struct rxrpc_call *);
 void rxrpc_kill_connection(struct rxrpc_connection *);
 bool rxrpc_queue_conn(struct rxrpc_connection *);
 void rxrpc_see_connection(struct rxrpc_connection *);
-void rxrpc_get_connection(struct rxrpc_connection *);
+struct rxrpc_connection *rxrpc_get_connection(struct rxrpc_connection *);
 struct rxrpc_connection *rxrpc_get_connection_maybe(struct rxrpc_connection *);
 void rxrpc_put_service_conn(struct rxrpc_connection *);
 void rxrpc_service_connection_reaper(struct work_struct *);
@@ -889,8 +905,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *,
                                                     struct sk_buff *);
 struct rxrpc_connection *rxrpc_prealloc_service_connection(struct rxrpc_net *, gfp_t);
 void rxrpc_new_incoming_connection(struct rxrpc_sock *, struct rxrpc_connection *,
-                                  const struct rxrpc_security *, struct key *,
-                                  struct sk_buff *);
+                                  const struct rxrpc_security *, struct sk_buff *);
 void rxrpc_unpublish_service_conn(struct rxrpc_connection *);
 
 /*
@@ -907,10 +922,8 @@ extern const struct rxrpc_security rxrpc_no_security;
  * key.c
  */
 extern struct key_type key_type_rxrpc;
-extern struct key_type key_type_rxrpc_s;
 
 int rxrpc_request_key(struct rxrpc_sock *, sockptr_t , int);
-int rxrpc_server_keyring(struct rxrpc_sock *, sockptr_t, int);
 int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time64_t,
                              u32);
 
@@ -1053,17 +1066,26 @@ extern const struct rxrpc_security rxkad;
  * security.c
  */
 int __init rxrpc_init_security(void);
+const struct rxrpc_security *rxrpc_security_lookup(u8);
 void rxrpc_exit_security(void);
 int rxrpc_init_client_conn_security(struct rxrpc_connection *);
-bool rxrpc_look_up_server_security(struct rxrpc_local *, struct rxrpc_sock *,
-                                  const struct rxrpc_security **, struct key **,
-                                  struct sk_buff *);
+const struct rxrpc_security *rxrpc_get_incoming_security(struct rxrpc_sock *,
+                                                        struct sk_buff *);
+struct key *rxrpc_look_up_server_security(struct rxrpc_connection *,
+                                         struct sk_buff *, u32, u32);
 
 /*
  * sendmsg.c
  */
 int rxrpc_do_sendmsg(struct rxrpc_sock *, struct msghdr *, size_t);
 
+/*
+ * server_key.c
+ */
+extern struct key_type key_type_rxrpc_s;
+
+int rxrpc_server_keyring(struct rxrpc_sock *, sockptr_t, int);
+
 /*
  * skbuff.c
  */