summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2016-04-04 09:00:36 -0400
committerDavid Howells <dhowells@redhat.com>2016-06-22 04:09:59 -0400
commit19ffa01c9c45861ad6b181323e0d36904298e326 (patch)
treeb81cd9ec90ca2c51829ffe9f765fd7a6b26e5e7b
parent2f9f9f5210887b1019fbd0327ffdf7c3aff271fd (diff)
rxrpc: Use structs to hold connection params and protocol info
Define and use a structure to hold connection parameters. This makes it easier to pass multiple connection parameters around. Define and use a structure to hold protocol information used to hash a connection for lookup on incoming packet. Most of these fields will be disposed of eventually, including the duplicate local pointer. Whilst we're at it rename "proto" to "family" when referring to a protocol family. Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--net/rxrpc/af_rxrpc.c55
-rw-r--r--net/rxrpc/ar-internal.h61
-rw-r--r--net/rxrpc/call_event.c6
-rw-r--r--net/rxrpc/call_object.c44
-rw-r--r--net/rxrpc/conn_event.c8
-rw-r--r--net/rxrpc/conn_object.c103
-rw-r--r--net/rxrpc/input.c4
-rw-r--r--net/rxrpc/key.c2
-rw-r--r--net/rxrpc/output.c24
-rw-r--r--net/rxrpc/proc.c12
-rw-r--r--net/rxrpc/recvmsg.c2
-rw-r--r--net/rxrpc/rxkad.c62
-rw-r--r--net/rxrpc/security.c6
13 files changed, 226 insertions, 163 deletions
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 9dd160bb16d2..48b45a0280c0 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -97,7 +97,7 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
97 srx->transport_len > len) 97 srx->transport_len > len)
98 return -EINVAL; 98 return -EINVAL;
99 99
100 if (srx->transport.family != rx->proto) 100 if (srx->transport.family != rx->family)
101 return -EAFNOSUPPORT; 101 return -EAFNOSUPPORT;
102 102
103 switch (srx->transport.family) { 103 switch (srx->transport.family) {
@@ -227,32 +227,30 @@ static int rxrpc_listen(struct socket *sock, int backlog)
227/* 227/*
228 * find a transport by address 228 * find a transport by address
229 */ 229 */
230struct rxrpc_transport *rxrpc_name_to_transport(struct rxrpc_sock *rx, 230struct rxrpc_transport *
231 struct sockaddr *addr, 231rxrpc_name_to_transport(struct rxrpc_conn_parameters *cp,
232 int addr_len, int flags, 232 struct sockaddr *addr,
233 gfp_t gfp) 233 int addr_len,
234 gfp_t gfp)
234{ 235{
235 struct sockaddr_rxrpc *srx = (struct sockaddr_rxrpc *) addr; 236 struct sockaddr_rxrpc *srx = (struct sockaddr_rxrpc *) addr;
236 struct rxrpc_transport *trans; 237 struct rxrpc_transport *trans;
237 struct rxrpc_peer *peer;
238 238
239 _enter("%p,%p,%d,%d", rx, addr, addr_len, flags); 239 _enter("%p,%d", addr, addr_len);
240
241 ASSERT(rx->local != NULL);
242 240
243 if (rx->srx.transport_type != srx->transport_type) 241 if (cp->local->srx.transport_type != srx->transport_type)
244 return ERR_PTR(-ESOCKTNOSUPPORT); 242 return ERR_PTR(-ESOCKTNOSUPPORT);
245 if (rx->srx.transport.family != srx->transport.family) 243 if (cp->local->srx.transport.family != srx->transport.family)
246 return ERR_PTR(-EAFNOSUPPORT); 244 return ERR_PTR(-EAFNOSUPPORT);
247 245
248 /* find a remote transport endpoint from the local one */ 246 /* find a remote transport endpoint from the local one */
249 peer = rxrpc_lookup_peer(rx->local, srx, gfp); 247 cp->peer = rxrpc_lookup_peer(cp->local, srx, gfp);
250 if (!peer) 248 if (!cp->peer)
251 return ERR_PTR(-ENOMEM); 249 return ERR_PTR(-ENOMEM);
252 250
253 /* find a transport */ 251 /* find a transport */
254 trans = rxrpc_get_transport(rx->local, peer, gfp); 252 trans = rxrpc_get_transport(cp->local, cp->peer, gfp);
255 rxrpc_put_peer(peer); 253 rxrpc_put_peer(cp->peer);
256 _leave(" = %p", trans); 254 _leave(" = %p", trans);
257 return trans; 255 return trans;
258} 256}
@@ -277,6 +275,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
277 unsigned long user_call_ID, 275 unsigned long user_call_ID,
278 gfp_t gfp) 276 gfp_t gfp)
279{ 277{
278 struct rxrpc_conn_parameters cp;
280 struct rxrpc_conn_bundle *bundle; 279 struct rxrpc_conn_bundle *bundle;
281 struct rxrpc_transport *trans; 280 struct rxrpc_transport *trans;
282 struct rxrpc_call *call; 281 struct rxrpc_call *call;
@@ -286,18 +285,26 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
286 285
287 lock_sock(&rx->sk); 286 lock_sock(&rx->sk);
288 287
289 trans = rxrpc_name_to_transport(rx, (struct sockaddr *)srx, 288 if (!key)
290 sizeof(*srx), 0, gfp); 289 key = rx->key;
290 if (key && !key->payload.data[0])
291 key = NULL; /* a no-security key */
292
293 memset(&cp, 0, sizeof(cp));
294 cp.local = rx->local;
295 cp.key = key;
296 cp.security_level = 0;
297 cp.exclusive = false;
298 cp.service_id = srx->srx_service;
299
300 trans = rxrpc_name_to_transport(&cp, (struct sockaddr *)srx,
301 sizeof(*srx), gfp);
291 if (IS_ERR(trans)) { 302 if (IS_ERR(trans)) {
292 call = ERR_CAST(trans); 303 call = ERR_CAST(trans);
293 trans = NULL; 304 trans = NULL;
294 goto out_notrans; 305 goto out_notrans;
295 } 306 }
296 307 cp.peer = trans->peer;
297 if (!key)
298 key = rx->key;
299 if (key && !key->payload.data[0])
300 key = NULL; /* a no-security key */
301 308
302 bundle = rxrpc_get_bundle(rx, trans, key, srx->srx_service, gfp); 309 bundle = rxrpc_get_bundle(rx, trans, key, srx->srx_service, gfp);
303 if (IS_ERR(bundle)) { 310 if (IS_ERR(bundle)) {
@@ -305,7 +312,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
305 goto out; 312 goto out;
306 } 313 }
307 314
308 call = rxrpc_new_client_call(rx, trans, bundle, user_call_ID, gfp); 315 call = rxrpc_new_client_call(rx, &cp, trans, bundle, user_call_ID, gfp);
309 rxrpc_put_bundle(trans, bundle); 316 rxrpc_put_bundle(trans, bundle);
310out: 317out:
311 rxrpc_put_transport(trans); 318 rxrpc_put_transport(trans);
@@ -600,7 +607,7 @@ static int rxrpc_create(struct net *net, struct socket *sock, int protocol,
600 sk->sk_destruct = rxrpc_sock_destructor; 607 sk->sk_destruct = rxrpc_sock_destructor;
601 608
602 rx = rxrpc_sk(sk); 609 rx = rxrpc_sk(sk);
603 rx->proto = protocol; 610 rx->family = protocol;
604 rx->calls = RB_ROOT; 611 rx->calls = RB_ROOT;
605 612
606 INIT_LIST_HEAD(&rx->listen_link); 613 INIT_LIST_HEAD(&rx->listen_link);
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index c168268467cd..efe6673deb28 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -72,7 +72,7 @@ struct rxrpc_sock {
72#define RXRPC_SECURITY_MAX RXRPC_SECURITY_ENCRYPT 72#define RXRPC_SECURITY_MAX RXRPC_SECURITY_ENCRYPT
73 struct sockaddr_rxrpc srx; /* local address */ 73 struct sockaddr_rxrpc srx; /* local address */
74 struct sockaddr_rxrpc connect_srx; /* Default client address from connect() */ 74 struct sockaddr_rxrpc connect_srx; /* Default client address from connect() */
75 sa_family_t proto; /* protocol created with */ 75 sa_family_t family; /* protocol family created with */
76}; 76};
77 77
78#define rxrpc_sk(__sk) container_of((__sk), struct rxrpc_sock, sk) 78#define rxrpc_sk(__sk) container_of((__sk), struct rxrpc_sock, sk)
@@ -262,6 +262,34 @@ struct rxrpc_conn_bundle {
262}; 262};
263 263
264/* 264/*
265 * Keys for matching a connection.
266 */
267struct rxrpc_conn_proto {
268 unsigned long hash_key;
269 struct rxrpc_local *local; /* Representation of local endpoint */
270 u32 epoch; /* epoch of this connection */
271 u32 cid; /* connection ID */
272 u8 in_clientflag; /* RXRPC_CLIENT_INITIATED if we are server */
273 u8 addr_size; /* Size of the address */
274 sa_family_t family; /* Transport protocol */
275 __be16 port; /* Peer UDP/UDP6 port */
276 union { /* Peer address */
277 struct in_addr ipv4_addr;
278 struct in6_addr ipv6_addr;
279 u32 raw_addr[0];
280 };
281};
282
283struct rxrpc_conn_parameters {
284 struct rxrpc_local *local; /* Representation of local endpoint */
285 struct rxrpc_peer *peer; /* Remote endpoint */
286 struct key *key; /* Security details */
287 bool exclusive; /* T if conn is exclusive */
288 u16 service_id; /* Service ID for this connection */
289 u32 security_level; /* Security level selected */
290};
291
292/*
265 * RxRPC connection definition 293 * RxRPC connection definition
266 * - matched by { transport, service_id, conn_id, direction, key } 294 * - matched by { transport, service_id, conn_id, direction, key }
267 * - each connection can only handle four simultaneous calls 295 * - each connection can only handle four simultaneous calls
@@ -269,6 +297,9 @@ struct rxrpc_conn_bundle {
269struct rxrpc_connection { 297struct rxrpc_connection {
270 struct rxrpc_transport *trans; /* transport session */ 298 struct rxrpc_transport *trans; /* transport session */
271 struct rxrpc_conn_bundle *bundle; /* connection bundle (client) */ 299 struct rxrpc_conn_bundle *bundle; /* connection bundle (client) */
300 struct rxrpc_conn_proto proto;
301 struct rxrpc_conn_parameters params;
302
272 struct work_struct processor; /* connection event processor */ 303 struct work_struct processor; /* connection event processor */
273 struct rb_node node; /* node in transport's lookup tree */ 304 struct rb_node node; /* node in transport's lookup tree */
274 struct list_head link; /* link in master connection list */ 305 struct list_head link; /* link in master connection list */
@@ -277,7 +308,6 @@ struct rxrpc_connection {
277 struct sk_buff_head rx_queue; /* received conn-level packets */ 308 struct sk_buff_head rx_queue; /* received conn-level packets */
278 struct rxrpc_call *channels[RXRPC_MAXCALLS]; /* channels (active calls) */ 309 struct rxrpc_call *channels[RXRPC_MAXCALLS]; /* channels (active calls) */
279 const struct rxrpc_security *security; /* applied security module */ 310 const struct rxrpc_security *security; /* applied security module */
280 struct key *key; /* security for this connection (client) */
281 struct key *server_key; /* security for this service */ 311 struct key *server_key; /* security for this service */
282 struct crypto_skcipher *cipher; /* encryption handle */ 312 struct crypto_skcipher *cipher; /* encryption handle */
283 struct rxrpc_crypt csum_iv; /* packet checksum base */ 313 struct rxrpc_crypt csum_iv; /* packet checksum base */
@@ -308,13 +338,8 @@ struct rxrpc_connection {
308 u8 size_align; /* data size alignment (for security) */ 338 u8 size_align; /* data size alignment (for security) */
309 u8 header_size; /* rxrpc + security header size */ 339 u8 header_size; /* rxrpc + security header size */
310 u8 security_size; /* security header size */ 340 u8 security_size; /* security header size */
311 u32 security_level; /* security level negotiated */
312 u32 security_nonce; /* response re-use preventer */ 341 u32 security_nonce; /* response re-use preventer */
313 u32 epoch; /* epoch of this connection */
314 u32 cid; /* connection ID */
315 u16 service_id; /* service ID for this connection */
316 u8 security_ix; /* security type */ 342 u8 security_ix; /* security type */
317 u8 in_clientflag; /* RXRPC_CLIENT_INITIATED if we are server */
318 u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */ 343 u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
319}; 344};
320 345
@@ -448,7 +473,7 @@ struct rxrpc_call {
448 unsigned long hash_key; /* Full hash key */ 473 unsigned long hash_key; /* Full hash key */
449 u8 in_clientflag; /* Copy of conn->in_clientflag for hashing */ 474 u8 in_clientflag; /* Copy of conn->in_clientflag for hashing */
450 struct rxrpc_local *local; /* Local endpoint. Used for hashing. */ 475 struct rxrpc_local *local; /* Local endpoint. Used for hashing. */
451 sa_family_t proto; /* Frame protocol */ 476 sa_family_t family; /* Frame protocol */
452 u32 call_id; /* call ID on connection */ 477 u32 call_id; /* call ID on connection */
453 u32 cid; /* connection ID plus channel index */ 478 u32 cid; /* connection ID plus channel index */
454 u32 epoch; /* epoch of this connection */ 479 u32 epoch; /* epoch of this connection */
@@ -481,9 +506,9 @@ extern u32 rxrpc_epoch;
481extern atomic_t rxrpc_debug_id; 506extern atomic_t rxrpc_debug_id;
482extern struct workqueue_struct *rxrpc_workqueue; 507extern struct workqueue_struct *rxrpc_workqueue;
483 508
484extern struct rxrpc_transport *rxrpc_name_to_transport(struct rxrpc_sock *, 509extern struct rxrpc_transport *rxrpc_name_to_transport(struct rxrpc_conn_parameters *,
485 struct sockaddr *, 510 struct sockaddr *,
486 int, int, gfp_t); 511 int, gfp_t);
487 512
488/* 513/*
489 * call_accept.c 514 * call_accept.c
@@ -512,6 +537,7 @@ struct rxrpc_call *rxrpc_find_call_hash(struct rxrpc_host_header *,
512 void *, sa_family_t, const void *); 537 void *, sa_family_t, const void *);
513struct rxrpc_call *rxrpc_find_call_by_user_ID(struct rxrpc_sock *, unsigned long); 538struct rxrpc_call *rxrpc_find_call_by_user_ID(struct rxrpc_sock *, unsigned long);
514struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *, 539struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *,
540 struct rxrpc_conn_parameters *,
515 struct rxrpc_transport *, 541 struct rxrpc_transport *,
516 struct rxrpc_conn_bundle *, 542 struct rxrpc_conn_bundle *,
517 unsigned long, gfp_t); 543 unsigned long, gfp_t);
@@ -541,8 +567,9 @@ struct rxrpc_conn_bundle *rxrpc_get_bundle(struct rxrpc_sock *,
541 struct rxrpc_transport *, 567 struct rxrpc_transport *,
542 struct key *, u16, gfp_t); 568 struct key *, u16, gfp_t);
543void rxrpc_put_bundle(struct rxrpc_transport *, struct rxrpc_conn_bundle *); 569void rxrpc_put_bundle(struct rxrpc_transport *, struct rxrpc_conn_bundle *);
544int rxrpc_connect_call(struct rxrpc_sock *, struct rxrpc_transport *, 570int rxrpc_connect_call(struct rxrpc_sock *, struct rxrpc_conn_parameters *,
545 struct rxrpc_conn_bundle *, struct rxrpc_call *, gfp_t); 571 struct rxrpc_transport *, struct rxrpc_conn_bundle *,
572 struct rxrpc_call *, gfp_t);
546void rxrpc_put_connection(struct rxrpc_connection *); 573void rxrpc_put_connection(struct rxrpc_connection *);
547void __exit rxrpc_destroy_all_connections(void); 574void __exit rxrpc_destroy_all_connections(void);
548struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *, 575struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *,
@@ -550,6 +577,16 @@ struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *,
550extern struct rxrpc_connection * 577extern struct rxrpc_connection *
551rxrpc_incoming_connection(struct rxrpc_transport *, struct rxrpc_host_header *); 578rxrpc_incoming_connection(struct rxrpc_transport *, struct rxrpc_host_header *);
552 579
580static inline bool rxrpc_conn_is_client(const struct rxrpc_connection *conn)
581{
582 return conn->out_clientflag;
583}
584
585static inline bool rxrpc_conn_is_service(const struct rxrpc_connection *conn)
586{
587 return conn->proto.in_clientflag;
588}
589
553/* 590/*
554 * input.c 591 * input.c
555 */ 592 */
diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index e610b106c913..1571dfb95aa3 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -842,7 +842,7 @@ void rxrpc_process_call(struct work_struct *work)
842 msg.msg_controllen = 0; 842 msg.msg_controllen = 0;
843 msg.msg_flags = 0; 843 msg.msg_flags = 0;
844 844
845 whdr.epoch = htonl(call->conn->epoch); 845 whdr.epoch = htonl(call->conn->proto.epoch);
846 whdr.cid = htonl(call->cid); 846 whdr.cid = htonl(call->cid);
847 whdr.callNumber = htonl(call->call_id); 847 whdr.callNumber = htonl(call->call_id);
848 whdr.seq = 0; 848 whdr.seq = 0;
@@ -1264,7 +1264,7 @@ maybe_reschedule:
1264 if (call->state >= RXRPC_CALL_COMPLETE && 1264 if (call->state >= RXRPC_CALL_COMPLETE &&
1265 !list_empty(&call->accept_link)) { 1265 !list_empty(&call->accept_link)) {
1266 _debug("X unlinking once-pending call %p { e=%lx f=%lx c=%x }", 1266 _debug("X unlinking once-pending call %p { e=%lx f=%lx c=%x }",
1267 call, call->events, call->flags, call->conn->cid); 1267 call, call->events, call->flags, call->conn->proto.cid);
1268 1268
1269 read_lock_bh(&call->state_lock); 1269 read_lock_bh(&call->state_lock);
1270 if (!test_bit(RXRPC_CALL_RELEASED, &call->flags) && 1270 if (!test_bit(RXRPC_CALL_RELEASED, &call->flags) &&
@@ -1282,7 +1282,7 @@ error:
1282 * this means there's a race between clearing the flag and setting the 1282 * this means there's a race between clearing the flag and setting the
1283 * work pending bit and the work item being processed again */ 1283 * work pending bit and the work item being processed again */
1284 if (call->events && !work_pending(&call->processor)) { 1284 if (call->events && !work_pending(&call->processor)) {
1285 _debug("jumpstart %x", call->conn->cid); 1285 _debug("jumpstart %x", call->conn->proto.cid);
1286 rxrpc_queue_call(call); 1286 rxrpc_queue_call(call);
1287 } 1287 }
1288 1288
diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c
index 8b4d47b3ccac..b7c6011c71bb 100644
--- a/net/rxrpc/call_object.c
+++ b/net/rxrpc/call_object.c
@@ -71,7 +71,7 @@ static unsigned long rxrpc_call_hashfunc(
71 u32 call_id, 71 u32 call_id,
72 u32 epoch, 72 u32 epoch,
73 u16 service_id, 73 u16 service_id,
74 sa_family_t proto, 74 sa_family_t family,
75 void *localptr, 75 void *localptr,
76 unsigned int addr_size, 76 unsigned int addr_size,
77 const u8 *peer_addr) 77 const u8 *peer_addr)
@@ -92,7 +92,7 @@ static unsigned long rxrpc_call_hashfunc(
92 key += (cid & RXRPC_CIDMASK) >> RXRPC_CIDSHIFT; 92 key += (cid & RXRPC_CIDMASK) >> RXRPC_CIDSHIFT;
93 key += cid & RXRPC_CHANNELMASK; 93 key += cid & RXRPC_CHANNELMASK;
94 key += in_clientflag; 94 key += in_clientflag;
95 key += proto; 95 key += family;
96 /* Step through the peer address in 16-bit portions for speed */ 96 /* Step through the peer address in 16-bit portions for speed */
97 for (i = 0, p = (const u16 *)peer_addr; i < addr_size >> 1; i++, p++) 97 for (i = 0, p = (const u16 *)peer_addr; i < addr_size >> 1; i++, p++)
98 key += *p; 98 key += *p;
@@ -109,7 +109,7 @@ static void rxrpc_call_hash_add(struct rxrpc_call *call)
109 unsigned int addr_size = 0; 109 unsigned int addr_size = 0;
110 110
111 _enter(""); 111 _enter("");
112 switch (call->proto) { 112 switch (call->family) {
113 case AF_INET: 113 case AF_INET:
114 addr_size = sizeof(call->peer_ip.ipv4_addr); 114 addr_size = sizeof(call->peer_ip.ipv4_addr);
115 break; 115 break;
@@ -121,7 +121,7 @@ static void rxrpc_call_hash_add(struct rxrpc_call *call)
121 } 121 }
122 key = rxrpc_call_hashfunc(call->in_clientflag, call->cid, 122 key = rxrpc_call_hashfunc(call->in_clientflag, call->cid,
123 call->call_id, call->epoch, 123 call->call_id, call->epoch,
124 call->service_id, call->proto, 124 call->service_id, call->family,
125 call->conn->trans->local, addr_size, 125 call->conn->trans->local, addr_size,
126 call->peer_ip.ipv6_addr); 126 call->peer_ip.ipv6_addr);
127 /* Store the full key in the call */ 127 /* Store the full key in the call */
@@ -151,7 +151,7 @@ static void rxrpc_call_hash_del(struct rxrpc_call *call)
151struct rxrpc_call *rxrpc_find_call_hash( 151struct rxrpc_call *rxrpc_find_call_hash(
152 struct rxrpc_host_header *hdr, 152 struct rxrpc_host_header *hdr,
153 void *localptr, 153 void *localptr,
154 sa_family_t proto, 154 sa_family_t family,
155 const void *peer_addr) 155 const void *peer_addr)
156{ 156{
157 unsigned long key; 157 unsigned long key;
@@ -161,7 +161,7 @@ struct rxrpc_call *rxrpc_find_call_hash(
161 u8 in_clientflag = hdr->flags & RXRPC_CLIENT_INITIATED; 161 u8 in_clientflag = hdr->flags & RXRPC_CLIENT_INITIATED;
162 162
163 _enter(""); 163 _enter("");
164 switch (proto) { 164 switch (family) {
165 case AF_INET: 165 case AF_INET:
166 addr_size = sizeof(call->peer_ip.ipv4_addr); 166 addr_size = sizeof(call->peer_ip.ipv4_addr);
167 break; 167 break;
@@ -174,7 +174,7 @@ struct rxrpc_call *rxrpc_find_call_hash(
174 174
175 key = rxrpc_call_hashfunc(in_clientflag, hdr->cid, hdr->callNumber, 175 key = rxrpc_call_hashfunc(in_clientflag, hdr->cid, hdr->callNumber,
176 hdr->epoch, hdr->serviceId, 176 hdr->epoch, hdr->serviceId,
177 proto, localptr, addr_size, 177 family, localptr, addr_size,
178 peer_addr); 178 peer_addr);
179 hash_for_each_possible_rcu(rxrpc_call_hash, call, hash_node, key) { 179 hash_for_each_possible_rcu(rxrpc_call_hash, call, hash_node, key) {
180 if (call->hash_key == key && 180 if (call->hash_key == key &&
@@ -182,7 +182,7 @@ struct rxrpc_call *rxrpc_find_call_hash(
182 call->cid == hdr->cid && 182 call->cid == hdr->cid &&
183 call->in_clientflag == in_clientflag && 183 call->in_clientflag == in_clientflag &&
184 call->service_id == hdr->serviceId && 184 call->service_id == hdr->serviceId &&
185 call->proto == proto && 185 call->family == family &&
186 call->local == localptr && 186 call->local == localptr &&
187 memcmp(call->peer_ip.ipv6_addr, peer_addr, 187 memcmp(call->peer_ip.ipv6_addr, peer_addr,
188 addr_size) == 0 && 188 addr_size) == 0 &&
@@ -286,6 +286,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
286 */ 286 */
287static struct rxrpc_call *rxrpc_alloc_client_call( 287static struct rxrpc_call *rxrpc_alloc_client_call(
288 struct rxrpc_sock *rx, 288 struct rxrpc_sock *rx,
289 struct rxrpc_conn_parameters *cp,
289 struct rxrpc_transport *trans, 290 struct rxrpc_transport *trans,
290 struct rxrpc_conn_bundle *bundle, 291 struct rxrpc_conn_bundle *bundle,
291 gfp_t gfp) 292 gfp_t gfp)
@@ -307,16 +308,16 @@ static struct rxrpc_call *rxrpc_alloc_client_call(
307 call->socket = rx; 308 call->socket = rx;
308 call->rx_data_post = 1; 309 call->rx_data_post = 1;
309 310
310 ret = rxrpc_connect_call(rx, trans, bundle, call, gfp); 311 ret = rxrpc_connect_call(rx, cp, trans, bundle, call, gfp);
311 if (ret < 0) { 312 if (ret < 0) {
312 kmem_cache_free(rxrpc_call_jar, call); 313 kmem_cache_free(rxrpc_call_jar, call);
313 return ERR_PTR(ret); 314 return ERR_PTR(ret);
314 } 315 }
315 316
316 /* Record copies of information for hashtable lookup */ 317 /* Record copies of information for hashtable lookup */
317 call->proto = rx->proto; 318 call->family = rx->family;
318 call->local = trans->local; 319 call->local = call->conn->params.local;
319 switch (call->proto) { 320 switch (call->family) {
320 case AF_INET: 321 case AF_INET:
321 call->peer_ip.ipv4_addr = 322 call->peer_ip.ipv4_addr =
322 trans->peer->srx.transport.sin.sin_addr.s_addr; 323 trans->peer->srx.transport.sin.sin_addr.s_addr;
@@ -327,9 +328,9 @@ static struct rxrpc_call *rxrpc_alloc_client_call(
327 sizeof(call->peer_ip.ipv6_addr)); 328 sizeof(call->peer_ip.ipv6_addr));
328 break; 329 break;
329 } 330 }
330 call->epoch = call->conn->epoch; 331 call->epoch = call->conn->proto.epoch;
331 call->service_id = call->conn->service_id; 332 call->service_id = call->conn->params.service_id;
332 call->in_clientflag = call->conn->in_clientflag; 333 call->in_clientflag = call->conn->proto.in_clientflag;
333 /* Add the new call to the hashtable */ 334 /* Add the new call to the hashtable */
334 rxrpc_call_hash_add(call); 335 rxrpc_call_hash_add(call);
335 336
@@ -349,6 +350,7 @@ static struct rxrpc_call *rxrpc_alloc_client_call(
349 * - called in process context with IRQs enabled 350 * - called in process context with IRQs enabled
350 */ 351 */
351struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx, 352struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,
353 struct rxrpc_conn_parameters *cp,
352 struct rxrpc_transport *trans, 354 struct rxrpc_transport *trans,
353 struct rxrpc_conn_bundle *bundle, 355 struct rxrpc_conn_bundle *bundle,
354 unsigned long user_call_ID, 356 unsigned long user_call_ID,
@@ -361,7 +363,7 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,
361 rx, trans->debug_id, bundle ? bundle->debug_id : -1, 363 rx, trans->debug_id, bundle ? bundle->debug_id : -1,
362 user_call_ID); 364 user_call_ID);
363 365
364 call = rxrpc_alloc_client_call(rx, trans, bundle, gfp); 366 call = rxrpc_alloc_client_call(rx, cp, trans, bundle, gfp);
365 if (IS_ERR(call)) { 367 if (IS_ERR(call)) {
366 _leave(" = %ld", PTR_ERR(call)); 368 _leave(" = %ld", PTR_ERR(call));
367 return call; 369 return call;
@@ -524,9 +526,9 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
524 write_unlock_bh(&rxrpc_call_lock); 526 write_unlock_bh(&rxrpc_call_lock);
525 527
526 /* Record copies of information for hashtable lookup */ 528 /* Record copies of information for hashtable lookup */
527 call->proto = rx->proto; 529 call->family = rx->family;
528 call->local = conn->trans->local; 530 call->local = conn->trans->local;
529 switch (call->proto) { 531 switch (call->family) {
530 case AF_INET: 532 case AF_INET:
531 call->peer_ip.ipv4_addr = 533 call->peer_ip.ipv4_addr =
532 conn->trans->peer->srx.transport.sin.sin_addr.s_addr; 534 conn->trans->peer->srx.transport.sin.sin_addr.s_addr;
@@ -539,9 +541,9 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
539 default: 541 default:
540 break; 542 break;
541 } 543 }
542 call->epoch = conn->epoch; 544 call->epoch = conn->proto.epoch;
543 call->service_id = conn->service_id; 545 call->service_id = conn->params.service_id;
544 call->in_clientflag = conn->in_clientflag; 546 call->in_clientflag = conn->proto.in_clientflag;
545 /* Add the new call to the hashtable */ 547 /* Add the new call to the hashtable */
546 rxrpc_call_hash_add(call); 548 rxrpc_call_hash_add(call);
547 549
diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c
index 00c92b614485..51e280c662e0 100644
--- a/net/rxrpc/conn_event.c
+++ b/net/rxrpc/conn_event.c
@@ -94,8 +94,8 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
94 msg.msg_controllen = 0; 94 msg.msg_controllen = 0;
95 msg.msg_flags = 0; 95 msg.msg_flags = 0;
96 96
97 whdr.epoch = htonl(conn->epoch); 97 whdr.epoch = htonl(conn->proto.epoch);
98 whdr.cid = htonl(conn->cid); 98 whdr.cid = htonl(conn->proto.cid);
99 whdr.callNumber = 0; 99 whdr.callNumber = 0;
100 whdr.seq = 0; 100 whdr.seq = 0;
101 whdr.type = RXRPC_PACKET_TYPE_ABORT; 101 whdr.type = RXRPC_PACKET_TYPE_ABORT;
@@ -103,7 +103,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
103 whdr.userStatus = 0; 103 whdr.userStatus = 0;
104 whdr.securityIndex = conn->security_ix; 104 whdr.securityIndex = conn->security_ix;
105 whdr._rsvd = 0; 105 whdr._rsvd = 0;
106 whdr.serviceId = htons(conn->service_id); 106 whdr.serviceId = htons(conn->params.service_id);
107 107
108 word = htonl(conn->local_abort); 108 word = htonl(conn->local_abort);
109 109
@@ -220,7 +220,7 @@ static void rxrpc_secure_connection(struct rxrpc_connection *conn)
220 220
221 ASSERT(conn->security_ix != 0); 221 ASSERT(conn->security_ix != 0);
222 222
223 if (!conn->key) { 223 if (!conn->params.key) {
224 _debug("set up security"); 224 _debug("set up security");
225 ret = rxrpc_init_server_conn_security(conn); 225 ret = rxrpc_init_server_conn_security(conn);
226 switch (ret) { 226 switch (ret) {
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index 8ecde4b77b55..c6787b6f459f 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -220,7 +220,7 @@ static void rxrpc_assign_connection_id(struct rxrpc_connection *conn)
220 220
221 _enter(""); 221 _enter("");
222 222
223 epoch = conn->epoch; 223 epoch = conn->proto.epoch;
224 224
225 write_lock_bh(&conn->trans->conn_lock); 225 write_lock_bh(&conn->trans->conn_lock);
226 226
@@ -237,13 +237,13 @@ attempt_insertion:
237 parent = *p; 237 parent = *p;
238 xconn = rb_entry(parent, struct rxrpc_connection, node); 238 xconn = rb_entry(parent, struct rxrpc_connection, node);
239 239
240 if (epoch < xconn->epoch) 240 if (epoch < xconn->proto.epoch)
241 p = &(*p)->rb_left; 241 p = &(*p)->rb_left;
242 else if (epoch > xconn->epoch) 242 else if (epoch > xconn->proto.epoch)
243 p = &(*p)->rb_right; 243 p = &(*p)->rb_right;
244 else if (cid < xconn->cid) 244 else if (cid < xconn->proto.cid)
245 p = &(*p)->rb_left; 245 p = &(*p)->rb_left;
246 else if (cid > xconn->cid) 246 else if (cid > xconn->proto.cid)
247 p = &(*p)->rb_right; 247 p = &(*p)->rb_right;
248 else 248 else
249 goto id_exists; 249 goto id_exists;
@@ -254,7 +254,7 @@ attempt_insertion:
254 rb_link_node(&conn->node, parent, p); 254 rb_link_node(&conn->node, parent, p);
255 rb_insert_color(&conn->node, &conn->trans->client_conns); 255 rb_insert_color(&conn->node, &conn->trans->client_conns);
256 256
257 conn->cid = cid; 257 conn->proto.cid = cid;
258 write_unlock_bh(&conn->trans->conn_lock); 258 write_unlock_bh(&conn->trans->conn_lock);
259 _leave(" [CID %x]", cid); 259 _leave(" [CID %x]", cid);
260 return; 260 return;
@@ -275,8 +275,8 @@ id_exists:
275 goto attempt_insertion; 275 goto attempt_insertion;
276 276
277 xconn = rb_entry(parent, struct rxrpc_connection, node); 277 xconn = rb_entry(parent, struct rxrpc_connection, node);
278 if (epoch < xconn->epoch || 278 if (epoch < xconn->proto.epoch ||
279 cid < xconn->cid) 279 cid < xconn->proto.cid)
280 goto attempt_insertion; 280 goto attempt_insertion;
281 } 281 }
282} 282}
@@ -318,8 +318,8 @@ static void rxrpc_add_call_ID_to_conn(struct rxrpc_connection *conn,
318 * connect a call on an exclusive connection 318 * connect a call on an exclusive connection
319 */ 319 */
320static int rxrpc_connect_exclusive(struct rxrpc_sock *rx, 320static int rxrpc_connect_exclusive(struct rxrpc_sock *rx,
321 struct rxrpc_conn_parameters *cp,
321 struct rxrpc_transport *trans, 322 struct rxrpc_transport *trans,
322 u16 service_id,
323 struct rxrpc_call *call, 323 struct rxrpc_call *call,
324 gfp_t gfp) 324 gfp_t gfp)
325{ 325{
@@ -340,19 +340,21 @@ static int rxrpc_connect_exclusive(struct rxrpc_sock *rx,
340 340
341 conn->trans = trans; 341 conn->trans = trans;
342 conn->bundle = NULL; 342 conn->bundle = NULL;
343 conn->service_id = service_id; 343 conn->params = *cp;
344 conn->epoch = rxrpc_epoch; 344 conn->proto.local = cp->local;
345 conn->in_clientflag = 0; 345 conn->proto.epoch = rxrpc_epoch;
346 conn->proto.cid = 0;
347 conn->proto.in_clientflag = 0;
348 conn->proto.family = cp->peer->srx.transport.family;
346 conn->out_clientflag = RXRPC_CLIENT_INITIATED; 349 conn->out_clientflag = RXRPC_CLIENT_INITIATED;
347 conn->cid = 0;
348 conn->state = RXRPC_CONN_CLIENT; 350 conn->state = RXRPC_CONN_CLIENT;
349 conn->avail_calls = RXRPC_MAXCALLS - 1; 351 conn->avail_calls = RXRPC_MAXCALLS - 1;
350 conn->security_level = rx->min_sec_level; 352
351 conn->key = key_get(rx->key); 353 key_get(conn->params.key);
352 354
353 ret = rxrpc_init_client_conn_security(conn); 355 ret = rxrpc_init_client_conn_security(conn);
354 if (ret < 0) { 356 if (ret < 0) {
355 key_put(conn->key); 357 key_put(conn->params.key);
356 kfree(conn); 358 kfree(conn);
357 _leave(" = %d [key]", ret); 359 _leave(" = %d [key]", ret);
358 return ret; 360 return ret;
@@ -389,7 +391,7 @@ found_channel:
389 conn->channels[chan] = call; 391 conn->channels[chan] = call;
390 call->conn = conn; 392 call->conn = conn;
391 call->channel = chan; 393 call->channel = chan;
392 call->cid = conn->cid | chan; 394 call->cid = conn->proto.cid | chan;
393 call->call_id = ++conn->call_counter; 395 call->call_id = ++conn->call_counter;
394 396
395 _net("CONNECT client on conn %d chan %d as call %x", 397 _net("CONNECT client on conn %d chan %d as call %x",
@@ -412,6 +414,7 @@ no_free_channels:
412 * - called in process context with IRQs enabled 414 * - called in process context with IRQs enabled
413 */ 415 */
414int rxrpc_connect_call(struct rxrpc_sock *rx, 416int rxrpc_connect_call(struct rxrpc_sock *rx,
417 struct rxrpc_conn_parameters *cp,
415 struct rxrpc_transport *trans, 418 struct rxrpc_transport *trans,
416 struct rxrpc_conn_bundle *bundle, 419 struct rxrpc_conn_bundle *bundle,
417 struct rxrpc_call *call, 420 struct rxrpc_call *call,
@@ -425,8 +428,7 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
425 _enter("%p,%lx,", rx, call->user_call_ID); 428 _enter("%p,%lx,", rx, call->user_call_ID);
426 429
427 if (test_bit(RXRPC_SOCK_EXCLUSIVE_CONN, &rx->flags)) 430 if (test_bit(RXRPC_SOCK_EXCLUSIVE_CONN, &rx->flags))
428 return rxrpc_connect_exclusive(rx, trans, bundle->service_id, 431 return rxrpc_connect_exclusive(rx, cp, trans, call, gfp);
429 call, gfp);
430 432
431 spin_lock(&trans->client_lock); 433 spin_lock(&trans->client_lock);
432 for (;;) { 434 for (;;) {
@@ -517,19 +519,21 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
517 519
518 candidate->trans = trans; 520 candidate->trans = trans;
519 candidate->bundle = bundle; 521 candidate->bundle = bundle;
520 candidate->service_id = bundle->service_id; 522 candidate->params = *cp;
521 candidate->epoch = rxrpc_epoch; 523 candidate->proto.local = cp->local;
522 candidate->in_clientflag = 0; 524 candidate->proto.epoch = rxrpc_epoch;
525 candidate->proto.cid = 0;
526 candidate->proto.in_clientflag = 0;
527 candidate->proto.family = cp->peer->srx.transport.family;
523 candidate->out_clientflag = RXRPC_CLIENT_INITIATED; 528 candidate->out_clientflag = RXRPC_CLIENT_INITIATED;
524 candidate->cid = 0;
525 candidate->state = RXRPC_CONN_CLIENT; 529 candidate->state = RXRPC_CONN_CLIENT;
526 candidate->avail_calls = RXRPC_MAXCALLS; 530 candidate->avail_calls = RXRPC_MAXCALLS;
527 candidate->security_level = rx->min_sec_level; 531
528 candidate->key = key_get(bundle->key); 532 key_get(candidate->params.key);
529 533
530 ret = rxrpc_init_client_conn_security(candidate); 534 ret = rxrpc_init_client_conn_security(candidate);
531 if (ret < 0) { 535 if (ret < 0) {
532 key_put(candidate->key); 536 key_put(candidate->params.key);
533 kfree(candidate); 537 kfree(candidate);
534 _leave(" = %d [key]", ret); 538 _leave(" = %d [key]", ret);
535 return ret; 539 return ret;
@@ -577,7 +581,7 @@ found_channel:
577 conn->channels[chan] = call; 581 conn->channels[chan] = call;
578 call->conn = conn; 582 call->conn = conn;
579 call->channel = chan; 583 call->channel = chan;
580 call->cid = conn->cid | chan; 584 call->cid = conn->proto.cid | chan;
581 call->call_id = ++conn->call_counter; 585 call->call_id = ++conn->call_counter;
582 586
583 _net("CONNECT client on conn %d chan %d as call %x", 587 _net("CONNECT client on conn %d chan %d as call %x",
@@ -626,15 +630,15 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
626 while (p) { 630 while (p) {
627 conn = rb_entry(p, struct rxrpc_connection, node); 631 conn = rb_entry(p, struct rxrpc_connection, node);
628 632
629 _debug("maybe %x", conn->cid); 633 _debug("maybe %x", conn->proto.cid);
630 634
631 if (epoch < conn->epoch) 635 if (epoch < conn->proto.epoch)
632 p = p->rb_left; 636 p = p->rb_left;
633 else if (epoch > conn->epoch) 637 else if (epoch > conn->proto.epoch)
634 p = p->rb_right; 638 p = p->rb_right;
635 else if (cid < conn->cid) 639 else if (cid < conn->proto.cid)
636 p = p->rb_left; 640 p = p->rb_left;
637 else if (cid > conn->cid) 641 else if (cid > conn->proto.cid)
638 p = p->rb_right; 642 p = p->rb_right;
639 else 643 else
640 goto found_extant_connection; 644 goto found_extant_connection;
@@ -650,14 +654,17 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
650 } 654 }
651 655
652 candidate->trans = trans; 656 candidate->trans = trans;
653 candidate->epoch = hdr->epoch; 657 candidate->proto.local = trans->local;
654 candidate->cid = hdr->cid & RXRPC_CIDMASK; 658 candidate->proto.epoch = hdr->epoch;
655 candidate->service_id = hdr->serviceId; 659 candidate->proto.cid = hdr->cid & RXRPC_CIDMASK;
660 candidate->proto.in_clientflag = RXRPC_CLIENT_INITIATED;
661 candidate->params.local = trans->local;
662 candidate->params.peer = trans->peer;
663 candidate->params.service_id = hdr->serviceId;
656 candidate->security_ix = hdr->securityIndex; 664 candidate->security_ix = hdr->securityIndex;
657 candidate->in_clientflag = RXRPC_CLIENT_INITIATED;
658 candidate->out_clientflag = 0; 665 candidate->out_clientflag = 0;
659 candidate->state = RXRPC_CONN_SERVER; 666 candidate->state = RXRPC_CONN_SERVER;
660 if (candidate->service_id) 667 if (candidate->params.service_id)
661 candidate->state = RXRPC_CONN_SERVER_UNSECURED; 668 candidate->state = RXRPC_CONN_SERVER_UNSECURED;
662 669
663 write_lock_bh(&trans->conn_lock); 670 write_lock_bh(&trans->conn_lock);
@@ -668,13 +675,13 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
668 p = *pp; 675 p = *pp;
669 conn = rb_entry(p, struct rxrpc_connection, node); 676 conn = rb_entry(p, struct rxrpc_connection, node);
670 677
671 if (epoch < conn->epoch) 678 if (epoch < conn->proto.epoch)
672 pp = &(*pp)->rb_left; 679 pp = &(*pp)->rb_left;
673 else if (epoch > conn->epoch) 680 else if (epoch > conn->proto.epoch)
674 pp = &(*pp)->rb_right; 681 pp = &(*pp)->rb_right;
675 else if (cid < conn->cid) 682 else if (cid < conn->proto.cid)
676 pp = &(*pp)->rb_left; 683 pp = &(*pp)->rb_left;
677 else if (cid > conn->cid) 684 else if (cid > conn->proto.cid)
678 pp = &(*pp)->rb_right; 685 pp = &(*pp)->rb_right;
679 else 686 else
680 goto found_extant_second; 687 goto found_extant_second;
@@ -696,7 +703,7 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
696 new = "new"; 703 new = "new";
697 704
698success: 705success:
699 _net("CONNECTION %s %d {%x}", new, conn->debug_id, conn->cid); 706 _net("CONNECTION %s %d {%x}", new, conn->debug_id, conn->proto.cid);
700 707
701 _leave(" = %p {u=%d}", conn, atomic_read(&conn->usage)); 708 _leave(" = %p {u=%d}", conn, atomic_read(&conn->usage));
702 return conn; 709 return conn;
@@ -754,15 +761,15 @@ struct rxrpc_connection *rxrpc_find_connection(struct rxrpc_transport *trans,
754 while (p) { 761 while (p) {
755 conn = rb_entry(p, struct rxrpc_connection, node); 762 conn = rb_entry(p, struct rxrpc_connection, node);
756 763
757 _debug("maybe %x", conn->cid); 764 _debug("maybe %x", conn->proto.cid);
758 765
759 if (epoch < conn->epoch) 766 if (epoch < conn->proto.epoch)
760 p = p->rb_left; 767 p = p->rb_left;
761 else if (epoch > conn->epoch) 768 else if (epoch > conn->proto.epoch)
762 p = p->rb_right; 769 p = p->rb_right;
763 else if (cid < conn->cid) 770 else if (cid < conn->proto.cid)
764 p = p->rb_left; 771 p = p->rb_left;
765 else if (cid > conn->cid) 772 else if (cid > conn->proto.cid)
766 p = p->rb_right; 773 p = p->rb_right;
767 else 774 else
768 goto found; 775 goto found;
@@ -816,7 +823,7 @@ static void rxrpc_destroy_connection(struct rxrpc_connection *conn)
816 rxrpc_purge_queue(&conn->rx_queue); 823 rxrpc_purge_queue(&conn->rx_queue);
817 824
818 conn->security->clear(conn); 825 conn->security->clear(conn);
819 key_put(conn->key); 826 key_put(conn->params.key);
820 key_put(conn->server_key); 827 key_put(conn->server_key);
821 828
822 rxrpc_put_transport(conn->trans); 829 rxrpc_put_transport(conn->trans);
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index e11e4d785127..c030abd4d2d8 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -360,7 +360,7 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
360 case RXRPC_PACKET_TYPE_BUSY: 360 case RXRPC_PACKET_TYPE_BUSY:
361 _proto("Rx BUSY %%%u", sp->hdr.serial); 361 _proto("Rx BUSY %%%u", sp->hdr.serial);
362 362
363 if (call->conn->out_clientflag) 363 if (rxrpc_conn_is_service(call->conn))
364 goto protocol_error; 364 goto protocol_error;
365 365
366 write_lock_bh(&call->state_lock); 366 write_lock_bh(&call->state_lock);
@@ -533,7 +533,7 @@ static void rxrpc_post_packet_to_call(struct rxrpc_call *call,
533 case RXRPC_CALL_COMPLETE: 533 case RXRPC_CALL_COMPLETE:
534 case RXRPC_CALL_CLIENT_FINAL_ACK: 534 case RXRPC_CALL_CLIENT_FINAL_ACK:
535 /* complete server call */ 535 /* complete server call */
536 if (call->conn->in_clientflag) 536 if (rxrpc_conn_is_service(call->conn))
537 goto dead_call; 537 goto dead_call;
538 /* resend last packet of a completed call */ 538 /* resend last packet of a completed call */
539 _debug("final ack again"); 539 _debug("final ack again");
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c
index 4ad56fafe3a7..18c737a61d80 100644
--- a/net/rxrpc/key.c
+++ b/net/rxrpc/key.c
@@ -987,7 +987,7 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *conn,
987 if (ret < 0) 987 if (ret < 0)
988 goto error; 988 goto error;
989 989
990 conn->key = key; 990 conn->params.key = key;
991 _leave(" = 0 [%d]", key_serial(key)); 991 _leave(" = 0 [%d]", key_serial(key));
992 return 0; 992 return 0;
993 993
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index e6fb3863b0bc..8c51745cccea 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -133,6 +133,7 @@ static struct rxrpc_call *
133rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, 133rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,
134 unsigned long user_call_ID) 134 unsigned long user_call_ID)
135{ 135{
136 struct rxrpc_conn_parameters cp;
136 struct rxrpc_conn_bundle *bundle; 137 struct rxrpc_conn_bundle *bundle;
137 struct rxrpc_transport *trans; 138 struct rxrpc_transport *trans;
138 struct rxrpc_call *call; 139 struct rxrpc_call *call;
@@ -146,23 +147,32 @@ rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,
146 if (!msg->msg_name) 147 if (!msg->msg_name)
147 return ERR_PTR(-EDESTADDRREQ); 148 return ERR_PTR(-EDESTADDRREQ);
148 149
149 trans = rxrpc_name_to_transport(rx, msg->msg_name, msg->msg_namelen, 0, 150 key = rx->key;
151 if (key && !rx->key->payload.data[0])
152 key = NULL;
153
154 memset(&cp, 0, sizeof(cp));
155 cp.local = rx->local;
156 cp.key = rx->key;
157 cp.security_level = rx->min_sec_level;
158 cp.exclusive = test_bit(RXRPC_SOCK_EXCLUSIVE_CONN, &rx->flags);
159 cp.service_id = srx->srx_service;
160 trans = rxrpc_name_to_transport(&cp, msg->msg_name, msg->msg_namelen,
150 GFP_KERNEL); 161 GFP_KERNEL);
151 if (IS_ERR(trans)) { 162 if (IS_ERR(trans)) {
152 ret = PTR_ERR(trans); 163 ret = PTR_ERR(trans);
153 goto out; 164 goto out;
154 } 165 }
166 cp.peer = trans->peer;
155 167
156 key = rx->key; 168 bundle = rxrpc_get_bundle(rx, trans, cp.key, srx->srx_service,
157 if (key && !rx->key->payload.data[0]) 169 GFP_KERNEL);
158 key = NULL;
159 bundle = rxrpc_get_bundle(rx, trans, key, srx->srx_service, GFP_KERNEL);
160 if (IS_ERR(bundle)) { 170 if (IS_ERR(bundle)) {
161 ret = PTR_ERR(bundle); 171 ret = PTR_ERR(bundle);
162 goto out_trans; 172 goto out_trans;
163 } 173 }
164 174
165 call = rxrpc_new_client_call(rx, trans, bundle, user_call_ID, 175 call = rxrpc_new_client_call(rx, &cp, trans, bundle, user_call_ID,
166 GFP_KERNEL); 176 GFP_KERNEL);
167 rxrpc_put_bundle(trans, bundle); 177 rxrpc_put_bundle(trans, bundle);
168 rxrpc_put_transport(trans); 178 rxrpc_put_transport(trans);
@@ -664,7 +674,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
664 674
665 seq = atomic_inc_return(&call->sequence); 675 seq = atomic_inc_return(&call->sequence);
666 676
667 sp->hdr.epoch = conn->epoch; 677 sp->hdr.epoch = conn->proto.epoch;
668 sp->hdr.cid = call->cid; 678 sp->hdr.cid = call->cid;
669 sp->hdr.callNumber = call->call_id; 679 sp->hdr.callNumber = call->call_id;
670 sp->hdr.seq = seq; 680 sp->hdr.seq = seq;
diff --git a/net/rxrpc/proc.c b/net/rxrpc/proc.c
index 225163bc658d..bbee05850801 100644
--- a/net/rxrpc/proc.c
+++ b/net/rxrpc/proc.c
@@ -74,10 +74,10 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
74 " %-8.8s %08x %lx\n", 74 " %-8.8s %08x %lx\n",
75 lbuff, 75 lbuff,
76 rbuff, 76 rbuff,
77 call->conn->service_id, 77 call->conn->params.service_id,
78 call->cid, 78 call->cid,
79 call->call_id, 79 call->call_id,
80 call->conn->in_clientflag ? "Svc" : "Clt", 80 rxrpc_conn_is_service(call->conn) ? "Svc" : "Clt",
81 atomic_read(&call->usage), 81 atomic_read(&call->usage),
82 rxrpc_call_states[call->state], 82 rxrpc_call_states[call->state],
83 call->remote_abort ?: call->local_abort, 83 call->remote_abort ?: call->local_abort,
@@ -157,13 +157,13 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
157 " %s %08x %08x %08x\n", 157 " %s %08x %08x %08x\n",
158 lbuff, 158 lbuff,
159 rbuff, 159 rbuff,
160 conn->service_id, 160 conn->params.service_id,
161 conn->cid, 161 conn->proto.cid,
162 conn->call_counter, 162 conn->call_counter,
163 conn->in_clientflag ? "Svc" : "Clt", 163 rxrpc_conn_is_service(conn) ? "Svc" : "Clt",
164 atomic_read(&conn->usage), 164 atomic_read(&conn->usage),
165 rxrpc_conn_states[conn->state], 165 rxrpc_conn_states[conn->state],
166 key_serial(conn->key), 166 key_serial(conn->params.key),
167 atomic_read(&conn->serial), 167 atomic_read(&conn->serial),
168 atomic_read(&conn->hi_serial)); 168 atomic_read(&conn->hi_serial));
169 169
diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
index 59706b9f2f7a..c5bac4e0db71 100644
--- a/net/rxrpc/recvmsg.c
+++ b/net/rxrpc/recvmsg.c
@@ -205,7 +205,7 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
205 /* we transferred the whole data packet */ 205 /* we transferred the whole data packet */
206 if (sp->hdr.flags & RXRPC_LAST_PACKET) { 206 if (sp->hdr.flags & RXRPC_LAST_PACKET) {
207 _debug("last"); 207 _debug("last");
208 if (call->conn->out_clientflag) { 208 if (rxrpc_conn_is_client(call->conn)) {
209 /* last byte of reply received */ 209 /* last byte of reply received */
210 ret = copied; 210 ret = copied;
211 goto terminal_message; 211 goto terminal_message;
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index 36a634027d9d..134c2713ae23 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -58,9 +58,9 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn)
58 struct rxrpc_key_token *token; 58 struct rxrpc_key_token *token;
59 int ret; 59 int ret;
60 60
61 _enter("{%d},{%x}", conn->debug_id, key_serial(conn->key)); 61 _enter("{%d},{%x}", conn->debug_id, key_serial(conn->params.key));
62 62
63 token = conn->key->payload.data[0]; 63 token = conn->params.key->payload.data[0];
64 conn->security_ix = token->security_index; 64 conn->security_ix = token->security_index;
65 65
66 ci = crypto_alloc_skcipher("pcbc(fcrypt)", 0, CRYPTO_ALG_ASYNC); 66 ci = crypto_alloc_skcipher("pcbc(fcrypt)", 0, CRYPTO_ALG_ASYNC);
@@ -74,7 +74,7 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn)
74 sizeof(token->kad->session_key)) < 0) 74 sizeof(token->kad->session_key)) < 0)
75 BUG(); 75 BUG();
76 76
77 switch (conn->security_level) { 77 switch (conn->params.security_level) {
78 case RXRPC_SECURITY_PLAIN: 78 case RXRPC_SECURITY_PLAIN:
79 break; 79 break;
80 case RXRPC_SECURITY_AUTH: 80 case RXRPC_SECURITY_AUTH:
@@ -115,14 +115,14 @@ static void rxkad_prime_packet_security(struct rxrpc_connection *conn)
115 115
116 _enter(""); 116 _enter("");
117 117
118 if (!conn->key) 118 if (!conn->params.key)
119 return; 119 return;
120 120
121 token = conn->key->payload.data[0]; 121 token = conn->params.key->payload.data[0];
122 memcpy(&iv, token->kad->session_key, sizeof(iv)); 122 memcpy(&iv, token->kad->session_key, sizeof(iv));
123 123
124 tmpbuf.x[0] = htonl(conn->epoch); 124 tmpbuf.x[0] = htonl(conn->proto.epoch);
125 tmpbuf.x[1] = htonl(conn->cid); 125 tmpbuf.x[1] = htonl(conn->proto.cid);
126 tmpbuf.x[2] = 0; 126 tmpbuf.x[2] = 0;
127 tmpbuf.x[3] = htonl(conn->security_ix); 127 tmpbuf.x[3] = htonl(conn->security_ix);
128 128
@@ -220,7 +220,7 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call,
220 rxkhdr.checksum = 0; 220 rxkhdr.checksum = 0;
221 221
222 /* encrypt from the session key */ 222 /* encrypt from the session key */
223 token = call->conn->key->payload.data[0]; 223 token = call->conn->params.key->payload.data[0];
224 memcpy(&iv, token->kad->session_key, sizeof(iv)); 224 memcpy(&iv, token->kad->session_key, sizeof(iv));
225 225
226 sg_init_one(&sg[0], sechdr, sizeof(rxkhdr)); 226 sg_init_one(&sg[0], sechdr, sizeof(rxkhdr));
@@ -277,13 +277,13 @@ static int rxkad_secure_packet(const struct rxrpc_call *call,
277 sp = rxrpc_skb(skb); 277 sp = rxrpc_skb(skb);
278 278
279 _enter("{%d{%x}},{#%u},%zu,", 279 _enter("{%d{%x}},{#%u},%zu,",
280 call->debug_id, key_serial(call->conn->key), sp->hdr.seq, 280 call->debug_id, key_serial(call->conn->params.key),
281 data_size); 281 sp->hdr.seq, data_size);
282 282
283 if (!call->conn->cipher) 283 if (!call->conn->cipher)
284 return 0; 284 return 0;
285 285
286 ret = key_validate(call->conn->key); 286 ret = key_validate(call->conn->params.key);
287 if (ret < 0) 287 if (ret < 0)
288 return ret; 288 return ret;
289 289
@@ -312,7 +312,7 @@ static int rxkad_secure_packet(const struct rxrpc_call *call,
312 y = 1; /* zero checksums are not permitted */ 312 y = 1; /* zero checksums are not permitted */
313 sp->hdr.cksum = y; 313 sp->hdr.cksum = y;
314 314
315 switch (call->conn->security_level) { 315 switch (call->conn->params.security_level) {
316 case RXRPC_SECURITY_PLAIN: 316 case RXRPC_SECURITY_PLAIN:
317 ret = 0; 317 ret = 0;
318 break; 318 break;
@@ -446,7 +446,7 @@ static int rxkad_verify_packet_encrypt(const struct rxrpc_call *call,
446 skb_to_sgvec(skb, sg, 0, skb->len); 446 skb_to_sgvec(skb, sg, 0, skb->len);
447 447
448 /* decrypt from the session key */ 448 /* decrypt from the session key */
449 token = call->conn->key->payload.data[0]; 449 token = call->conn->params.key->payload.data[0];
450 memcpy(&iv, token->kad->session_key, sizeof(iv)); 450 memcpy(&iv, token->kad->session_key, sizeof(iv));
451 451
452 skcipher_request_set_tfm(req, call->conn->cipher); 452 skcipher_request_set_tfm(req, call->conn->cipher);
@@ -516,7 +516,7 @@ static int rxkad_verify_packet(const struct rxrpc_call *call,
516 sp = rxrpc_skb(skb); 516 sp = rxrpc_skb(skb);
517 517
518 _enter("{%d{%x}},{#%u}", 518 _enter("{%d{%x}},{#%u}",
519 call->debug_id, key_serial(call->conn->key), sp->hdr.seq); 519 call->debug_id, key_serial(call->conn->params.key), sp->hdr.seq);
520 520
521 if (!call->conn->cipher) 521 if (!call->conn->cipher)
522 return 0; 522 return 0;
@@ -557,7 +557,7 @@ static int rxkad_verify_packet(const struct rxrpc_call *call,
557 return -EPROTO; 557 return -EPROTO;
558 } 558 }
559 559
560 switch (call->conn->security_level) { 560 switch (call->conn->params.security_level) {
561 case RXRPC_SECURITY_PLAIN: 561 case RXRPC_SECURITY_PLAIN:
562 ret = 0; 562 ret = 0;
563 break; 563 break;
@@ -589,9 +589,9 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
589 u32 serial; 589 u32 serial;
590 int ret; 590 int ret;
591 591
592 _enter("{%d,%x}", conn->debug_id, key_serial(conn->key)); 592 _enter("{%d,%x}", conn->debug_id, key_serial(conn->params.key));
593 593
594 ret = key_validate(conn->key); 594 ret = key_validate(conn->params.key);
595 if (ret < 0) 595 if (ret < 0)
596 return ret; 596 return ret;
597 597
@@ -608,8 +608,8 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
608 msg.msg_controllen = 0; 608 msg.msg_controllen = 0;
609 msg.msg_flags = 0; 609 msg.msg_flags = 0;
610 610
611 whdr.epoch = htonl(conn->epoch); 611 whdr.epoch = htonl(conn->proto.epoch);
612 whdr.cid = htonl(conn->cid); 612 whdr.cid = htonl(conn->proto.cid);
613 whdr.callNumber = 0; 613 whdr.callNumber = 0;
614 whdr.seq = 0; 614 whdr.seq = 0;
615 whdr.type = RXRPC_PACKET_TYPE_CHALLENGE; 615 whdr.type = RXRPC_PACKET_TYPE_CHALLENGE;
@@ -617,7 +617,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
617 whdr.userStatus = 0; 617 whdr.userStatus = 0;
618 whdr.securityIndex = conn->security_ix; 618 whdr.securityIndex = conn->security_ix;
619 whdr._rsvd = 0; 619 whdr._rsvd = 0;
620 whdr.serviceId = htons(conn->service_id); 620 whdr.serviceId = htons(conn->params.service_id);
621 621
622 iov[0].iov_base = &whdr; 622 iov[0].iov_base = &whdr;
623 iov[0].iov_len = sizeof(whdr); 623 iov[0].iov_len = sizeof(whdr);
@@ -771,14 +771,14 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn,
771 u32 version, nonce, min_level, abort_code; 771 u32 version, nonce, min_level, abort_code;
772 int ret; 772 int ret;
773 773
774 _enter("{%d,%x}", conn->debug_id, key_serial(conn->key)); 774 _enter("{%d,%x}", conn->debug_id, key_serial(conn->params.key));
775 775
776 if (!conn->key) { 776 if (!conn->params.key) {
777 _leave(" = -EPROTO [no key]"); 777 _leave(" = -EPROTO [no key]");
778 return -EPROTO; 778 return -EPROTO;
779 } 779 }
780 780
781 ret = key_validate(conn->key); 781 ret = key_validate(conn->params.key);
782 if (ret < 0) { 782 if (ret < 0) {
783 *_abort_code = RXKADEXPIRED; 783 *_abort_code = RXKADEXPIRED;
784 return ret; 784 return ret;
@@ -801,20 +801,20 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn,
801 goto protocol_error; 801 goto protocol_error;
802 802
803 abort_code = RXKADLEVELFAIL; 803 abort_code = RXKADLEVELFAIL;
804 if (conn->security_level < min_level) 804 if (conn->params.security_level < min_level)
805 goto protocol_error; 805 goto protocol_error;
806 806
807 token = conn->key->payload.data[0]; 807 token = conn->params.key->payload.data[0];
808 808
809 /* build the response packet */ 809 /* build the response packet */
810 memset(&resp, 0, sizeof(resp)); 810 memset(&resp, 0, sizeof(resp));
811 811
812 resp.version = htonl(RXKAD_VERSION); 812 resp.version = htonl(RXKAD_VERSION);
813 resp.encrypted.epoch = htonl(conn->epoch); 813 resp.encrypted.epoch = htonl(conn->proto.epoch);
814 resp.encrypted.cid = htonl(conn->cid); 814 resp.encrypted.cid = htonl(conn->proto.cid);
815 resp.encrypted.securityIndex = htonl(conn->security_ix); 815 resp.encrypted.securityIndex = htonl(conn->security_ix);
816 resp.encrypted.inc_nonce = htonl(nonce + 1); 816 resp.encrypted.inc_nonce = htonl(nonce + 1);
817 resp.encrypted.level = htonl(conn->security_level); 817 resp.encrypted.level = htonl(conn->params.security_level);
818 resp.kvno = htonl(token->kad->kvno); 818 resp.kvno = htonl(token->kad->kvno);
819 resp.ticket_len = htonl(token->kad->ticket_len); 819 resp.ticket_len = htonl(token->kad->ticket_len);
820 820
@@ -1096,9 +1096,9 @@ static int rxkad_verify_response(struct rxrpc_connection *conn,
1096 rxkad_decrypt_response(conn, &response, &session_key); 1096 rxkad_decrypt_response(conn, &response, &session_key);
1097 1097
1098 abort_code = RXKADSEALEDINCON; 1098 abort_code = RXKADSEALEDINCON;
1099 if (ntohl(response.encrypted.epoch) != conn->epoch) 1099 if (ntohl(response.encrypted.epoch) != conn->proto.epoch)
1100 goto protocol_error_free; 1100 goto protocol_error_free;
1101 if (ntohl(response.encrypted.cid) != conn->cid) 1101 if (ntohl(response.encrypted.cid) != conn->proto.cid)
1102 goto protocol_error_free; 1102 goto protocol_error_free;
1103 if (ntohl(response.encrypted.securityIndex) != conn->security_ix) 1103 if (ntohl(response.encrypted.securityIndex) != conn->security_ix)
1104 goto protocol_error_free; 1104 goto protocol_error_free;
@@ -1122,7 +1122,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn,
1122 level = ntohl(response.encrypted.level); 1122 level = ntohl(response.encrypted.level);
1123 if (level > RXRPC_SECURITY_ENCRYPT) 1123 if (level > RXRPC_SECURITY_ENCRYPT)
1124 goto protocol_error_free; 1124 goto protocol_error_free;
1125 conn->security_level = level; 1125 conn->params.security_level = level;
1126 1126
1127 /* create a key to hold the security data and expiration time - after 1127 /* create a key to hold the security data and expiration time - after
1128 * this the connection security can be handled in exactly the same way 1128 * this the connection security can be handled in exactly the same way
diff --git a/net/rxrpc/security.c b/net/rxrpc/security.c
index d223253b22fa..40955d0f2693 100644
--- a/net/rxrpc/security.c
+++ b/net/rxrpc/security.c
@@ -76,7 +76,7 @@ int rxrpc_init_client_conn_security(struct rxrpc_connection *conn)
76{ 76{
77 const struct rxrpc_security *sec; 77 const struct rxrpc_security *sec;
78 struct rxrpc_key_token *token; 78 struct rxrpc_key_token *token;
79 struct key *key = conn->key; 79 struct key *key = conn->params.key;
80 int ret; 80 int ret;
81 81
82 _enter("{%d},{%x}", conn->debug_id, key_serial(key)); 82 _enter("{%d},{%x}", conn->debug_id, key_serial(key));
@@ -121,7 +121,7 @@ int rxrpc_init_server_conn_security(struct rxrpc_connection *conn)
121 121
122 _enter(""); 122 _enter("");
123 123
124 sprintf(kdesc, "%u:%u", conn->service_id, conn->security_ix); 124 sprintf(kdesc, "%u:%u", conn->params.service_id, conn->security_ix);
125 125
126 sec = rxrpc_security_lookup(conn->security_ix); 126 sec = rxrpc_security_lookup(conn->security_ix);
127 if (!sec) { 127 if (!sec) {
@@ -132,7 +132,7 @@ int rxrpc_init_server_conn_security(struct rxrpc_connection *conn)
132 /* find the service */ 132 /* find the service */
133 read_lock_bh(&local->services_lock); 133 read_lock_bh(&local->services_lock);
134 list_for_each_entry(rx, &local->services, listen_link) { 134 list_for_each_entry(rx, &local->services, listen_link) {
135 if (rx->srx.srx_service == conn->service_id) 135 if (rx->srx.srx_service == conn->params.service_id)
136 goto found_service; 136 goto found_service;
137 } 137 }
138 138