summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-09-14 20:01:23 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-09-14 20:04:42 +0200
commitd2eb95b27f87a8428e99f54efeed98699ea05c5f (patch)
treee52f33b416f12ad1e9819f74a401ec933356504b
parent7ff5aca8df37839496d242097f481843c57dfc5c (diff)
downloadcryptodev-linux-d2eb95b27f87a8428e99f54efeed98699ea05c5f.tar.gz
cryptodev-linux-d2eb95b27f87a8428e99f54efeed98699ea05c5f.tar.xz
cryptodev-linux-d2eb95b27f87a8428e99f54efeed98699ea05c5f.zip
Only record transform type, not whole address
-rw-r--r--cryptodev_main.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/cryptodev_main.c b/cryptodev_main.c
index fa70b98..dba3d63 100644
--- a/cryptodev_main.c
+++ b/cryptodev_main.c
@@ -103,10 +103,15 @@ struct data_sock {
unsigned index;
};
+enum alg_op_type {
+ OP_NONE = 0, /* bind() not performed */
+ OP_HASH
+};
+
/* A socket holding a crypto_tfm. */
struct alg_sock {
struct sock sk;
- struct sockaddr_alg addr;
+ enum alg_op_type op_type;
struct data_sock *slaves[1];
unsigned num_slaves, accept_idx;
struct hash_data hash;
@@ -144,8 +149,22 @@ static void __dump_data_sock(int line, const struct data_sock *dsk)
static void __dump_alg_sock(int line, const struct alg_sock *ask)
{
- printk(KERN_DEBUG "@%d: %p: cnt %d, slave %p: %u/%u, hash %d\n", line,
- ask, atomic_read(&ask->sk.sk_refcnt), ask->slaves[0],
+ static const char *const types[] = {
+ [OP_NONE] = "OP_NONE",
+ [OP_HASH] = "OP_HASH",
+ };
+
+ const char *type;
+ char type_buf[32];
+
+ if (ask->op_type < ARRAY_SIZE(types) && types[ask->op_type] != NULL)
+ type = types[ask->op_type];
+ else {
+ sprintf(type_buf, "%d", (int)type);
+ type = type_buf;
+ }
+ printk(KERN_DEBUG "@%d: %p: cnt %d, %s, slave %p: %u/%u, hash %d\n",
+ line, ask, atomic_read(&ask->sk.sk_refcnt), type, ask->slaves[0],
ask->accept_idx, ask->num_slaves, ask->hash.init);
}
#define DUMP_ASK(ASK) (__dump_alg_sock(__LINE__, (ASK)))
@@ -474,19 +493,18 @@ static int alg_bind(struct socket *sock, struct sockaddr *myaddr,
// FIXME: locking
- if (ask->addr.salg_type[0] != 0)
+ if (ask->op_type != OP_NONE)
return -EINVAL;
- // FIXME
- if (strncmp(addr->salg_type, "hash", sizeof(addr->salg_type)) != 0)
+ if (strncmp(addr->salg_type, "hash", sizeof(addr->salg_type)) == 0) {
+ BUG_ON(ask->hash.init != 0);
+ res = cryptodev_hash_init(&ask->hash, addr->salg_tfm, NULL, 0);
+ if (res != 0)
+ return res;
+ ask->op_type = OP_HASH;
+ } else
return -EINVAL;
- BUG_ON(ask->hash.init != 0);
- res = cryptodev_hash_init(&ask->hash, addr->salg_tfm, NULL, 0);
- if (res != 0)
- return res;
-
- ask->addr = *addr;
DUMP_ASK(ask);
return 0;
}
@@ -531,7 +549,7 @@ static int alg_listen(struct socket *sock, int len)
ask = alg_sk(sock->sk);
DUMP_ASK(ask);
- if (ask->addr.salg_type[0] == 0)
+ if (ask->op_type == OP_NONE)
return -EDESTADDRREQ;
if (ask->num_slaves != 0)
@@ -595,7 +613,7 @@ static int alg_sendmsg(struct kiocb *iocb, struct socket *sock,
DUMP_ASK(ask);
// FIXME: locking
- if (ask->addr.salg_type[0] == 0)
+ if (ask->op_type == OP_NONE)
return -ENOTCONN;
return do_data_sendmsg(iocb, ask, 0, m, total_len);
@@ -611,7 +629,7 @@ static int alg_recvmsg(struct kiocb *iocb, struct socket *sock,
DUMP_ASK(ask);
// FIXME: locking
- if (ask->addr.salg_type[0] == 0)
+ if (ask->op_type == OP_NONE)
return -ENOTCONN;
return do_data_recvmsg(iocb, ask, 0, m, total_len, flags);