Commit 8d47a43c authored by David Howells's avatar David Howells

rxrpc: Merge prime_packet_security into init_connection_security

Merge the ->prime_packet_security() into the ->init_connection_security()
hook as they're always called together.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent 177b8989
...@@ -234,8 +234,6 @@ struct rxrpc_security { ...@@ -234,8 +234,6 @@ struct rxrpc_security {
int (*init_connection_security)(struct rxrpc_connection *, int (*init_connection_security)(struct rxrpc_connection *,
struct rxrpc_key_token *); struct rxrpc_key_token *);
/* prime a connection's packet security */
int (*prime_packet_security)(struct rxrpc_connection *);
/* impose security on a packet */ /* impose security on a packet */
int (*secure_packet)(struct rxrpc_call *, int (*secure_packet)(struct rxrpc_call *,
......
...@@ -180,10 +180,6 @@ rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp) ...@@ -180,10 +180,6 @@ rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp)
if (ret < 0) if (ret < 0)
goto error_1; goto error_1;
ret = conn->security->prime_packet_security(conn);
if (ret < 0)
goto error_2;
atomic_inc(&rxnet->nr_conns); atomic_inc(&rxnet->nr_conns);
write_lock(&rxnet->conn_lock); write_lock(&rxnet->conn_lock);
list_add_tail(&conn->proc_link, &rxnet->conn_proc_list); list_add_tail(&conn->proc_link, &rxnet->conn_proc_list);
...@@ -203,8 +199,6 @@ rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp) ...@@ -203,8 +199,6 @@ rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp)
_leave(" = %p", conn); _leave(" = %p", conn);
return conn; return conn;
error_2:
conn->security->clear(conn);
error_1: error_1:
rxrpc_put_client_connection_id(conn); rxrpc_put_client_connection_id(conn);
error_0: error_0:
......
...@@ -338,10 +338,6 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, ...@@ -338,10 +338,6 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = conn->security->prime_packet_security(conn);
if (ret < 0)
return ret;
spin_lock(&conn->bundle->channel_lock); spin_lock(&conn->bundle->channel_lock);
spin_lock_bh(&conn->state_lock); spin_lock_bh(&conn->state_lock);
......
...@@ -14,11 +14,6 @@ static int none_init_connection_security(struct rxrpc_connection *conn, ...@@ -14,11 +14,6 @@ static int none_init_connection_security(struct rxrpc_connection *conn,
return 0; return 0;
} }
static int none_prime_packet_security(struct rxrpc_connection *conn)
{
return 0;
}
static int none_secure_packet(struct rxrpc_call *call, static int none_secure_packet(struct rxrpc_call *call,
struct sk_buff *skb, struct sk_buff *skb,
size_t data_size, size_t data_size,
...@@ -87,7 +82,6 @@ const struct rxrpc_security rxrpc_no_security = { ...@@ -87,7 +82,6 @@ const struct rxrpc_security rxrpc_no_security = {
.init = none_init, .init = none_init,
.exit = none_exit, .exit = none_exit,
.init_connection_security = none_init_connection_security, .init_connection_security = none_init_connection_security,
.prime_packet_security = none_prime_packet_security,
.free_call_crypto = none_free_call_crypto, .free_call_crypto = none_free_call_crypto,
.secure_packet = none_secure_packet, .secure_packet = none_secure_packet,
.verify_packet = none_verify_packet, .verify_packet = none_verify_packet,
......
...@@ -38,6 +38,9 @@ struct rxkad_level2_hdr { ...@@ -38,6 +38,9 @@ struct rxkad_level2_hdr {
__be32 checksum; /* decrypted data checksum */ __be32 checksum; /* decrypted data checksum */
}; };
static int rxkad_prime_packet_security(struct rxrpc_connection *conn,
struct crypto_sync_skcipher *ci);
/* /*
* this holds a pinned cipher so that keventd doesn't get called by the cipher * this holds a pinned cipher so that keventd doesn't get called by the cipher
* alloc routine, but since we have it to hand, we use it to decrypt RESPONSE * alloc routine, but since we have it to hand, we use it to decrypt RESPONSE
...@@ -130,8 +133,15 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn, ...@@ -130,8 +133,15 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn,
goto error; goto error;
} }
ret = rxkad_prime_packet_security(conn, ci);
if (ret < 0)
goto error_ci;
conn->cipher = ci; conn->cipher = ci;
ret = 0; return 0;
error_ci:
crypto_free_sync_skcipher(ci);
error: error:
_leave(" = %d", ret); _leave(" = %d", ret);
return ret; return ret;
...@@ -141,7 +151,8 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn, ...@@ -141,7 +151,8 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn,
* prime the encryption state with the invariant parts of a connection's * prime the encryption state with the invariant parts of a connection's
* description * description
*/ */
static int rxkad_prime_packet_security(struct rxrpc_connection *conn) static int rxkad_prime_packet_security(struct rxrpc_connection *conn,
struct crypto_sync_skcipher *ci)
{ {
struct skcipher_request *req; struct skcipher_request *req;
struct rxrpc_key_token *token; struct rxrpc_key_token *token;
...@@ -159,7 +170,7 @@ static int rxkad_prime_packet_security(struct rxrpc_connection *conn) ...@@ -159,7 +170,7 @@ static int rxkad_prime_packet_security(struct rxrpc_connection *conn)
if (!tmpbuf) if (!tmpbuf)
return -ENOMEM; return -ENOMEM;
req = skcipher_request_alloc(&conn->cipher->base, GFP_NOFS); req = skcipher_request_alloc(&ci->base, GFP_NOFS);
if (!req) { if (!req) {
kfree(tmpbuf); kfree(tmpbuf);
return -ENOMEM; return -ENOMEM;
...@@ -174,7 +185,7 @@ static int rxkad_prime_packet_security(struct rxrpc_connection *conn) ...@@ -174,7 +185,7 @@ static int rxkad_prime_packet_security(struct rxrpc_connection *conn)
tmpbuf[3] = htonl(conn->security_ix); tmpbuf[3] = htonl(conn->security_ix);
sg_init_one(&sg, tmpbuf, tmpsize); sg_init_one(&sg, tmpbuf, tmpsize);
skcipher_request_set_sync_tfm(req, conn->cipher); skcipher_request_set_sync_tfm(req, ci);
skcipher_request_set_callback(req, 0, NULL, NULL); skcipher_request_set_callback(req, 0, NULL, NULL);
skcipher_request_set_crypt(req, &sg, &sg, tmpsize, iv.x); skcipher_request_set_crypt(req, &sg, &sg, tmpsize, iv.x);
crypto_skcipher_encrypt(req); crypto_skcipher_encrypt(req);
...@@ -1350,7 +1361,6 @@ const struct rxrpc_security rxkad = { ...@@ -1350,7 +1361,6 @@ const struct rxrpc_security rxkad = {
.free_preparse_server_key = rxkad_free_preparse_server_key, .free_preparse_server_key = rxkad_free_preparse_server_key,
.destroy_server_key = rxkad_destroy_server_key, .destroy_server_key = rxkad_destroy_server_key,
.init_connection_security = rxkad_init_connection_security, .init_connection_security = rxkad_init_connection_security,
.prime_packet_security = rxkad_prime_packet_security,
.secure_packet = rxkad_secure_packet, .secure_packet = rxkad_secure_packet,
.verify_packet = rxkad_verify_packet, .verify_packet = rxkad_verify_packet,
.free_call_crypto = rxkad_free_call_crypto, .free_call_crypto = rxkad_free_call_crypto,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment