mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Reisner <philipp.reisner@linbit.com>
To: linux-kernel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com
Subject: [PATCH 09/16] drbd: Remove obsolete drbd_crypto_is_hash()
Date: Wed,  5 Oct 2011 11:37:57 +0200	[thread overview]
Message-ID: <1317807484-24628-10-git-send-email-philipp.reisner@linbit.com> (raw)
In-Reply-To: <1317807484-24628-1-git-send-email-philipp.reisner@linbit.com>

From: Andreas Gruenbacher <agruen@linbit.com>

We allocate hash transformations with crypto_alloc_hash() which will
only return hash algorithms.  It is not necessary to reconfirm that we
actually got a hash algorithm.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
---
 drivers/block/drbd/drbd_nl.c       |   25 +++++++++++--------------
 drivers/block/drbd/drbd_receiver.c |    5 -----
 drivers/block/drbd/drbd_wrappers.h |    6 ------
 3 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index efae733..fd97ffb 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1830,7 +1830,7 @@ struct crypto {
 };
 
 static int
-alloc_tfm(struct crypto_hash **tfm, char *tfm_name, int err_alg, int err_nd)
+alloc_hash(struct crypto_hash **tfm, char *tfm_name, int err_alg)
 {
 	if (!tfm_name[0])
 		return NO_ERROR;
@@ -1841,9 +1841,6 @@ alloc_tfm(struct crypto_hash **tfm, char *tfm_name, int err_alg, int err_nd)
 		return err_alg;
 	}
 
-	if (!drbd_crypto_is_hash(crypto_hash_tfm(*tfm)))
-		return err_nd;
-
 	return NO_ERROR;
 }
 
@@ -1854,28 +1851,28 @@ alloc_crypto(struct crypto *crypto, struct net_conf *new_conf)
 	enum drbd_ret_code rv;
 	int hash_size;
 
-	rv = alloc_tfm(&crypto->csums_tfm, new_conf->csums_alg,
-		       ERR_CSUMS_ALG, ERR_CSUMS_ALG_ND);
+	rv = alloc_hash(&crypto->csums_tfm, new_conf->csums_alg,
+		       ERR_CSUMS_ALG);
 	if (rv != NO_ERROR)
 		return rv;
-	rv = alloc_tfm(&crypto->verify_tfm, new_conf->verify_alg,
-		       ERR_VERIFY_ALG, ERR_VERIFY_ALG_ND);
+	rv = alloc_hash(&crypto->verify_tfm, new_conf->verify_alg,
+		       ERR_VERIFY_ALG);
 	if (rv != NO_ERROR)
 		return rv;
-	rv = alloc_tfm(&crypto->integrity_tfm, new_conf->integrity_alg,
-		       ERR_INTEGRITY_ALG, ERR_INTEGRITY_ALG_ND);
+	rv = alloc_hash(&crypto->integrity_tfm, new_conf->integrity_alg,
+		       ERR_INTEGRITY_ALG);
 	if (rv != NO_ERROR)
 		return rv;
-	rv = alloc_tfm(&crypto->peer_integrity_tfm, new_conf->integrity_alg,
-		       ERR_INTEGRITY_ALG, ERR_INTEGRITY_ALG_ND);
+	rv = alloc_hash(&crypto->peer_integrity_tfm, new_conf->integrity_alg,
+		       ERR_INTEGRITY_ALG);
 	if (rv != NO_ERROR)
 		return rv;
 	if (new_conf->cram_hmac_alg[0] != 0) {
 		snprintf(hmac_name, CRYPTO_MAX_ALG_NAME, "hmac(%s)",
 			 new_conf->cram_hmac_alg);
 
-		rv = alloc_tfm(&crypto->cram_hmac_tfm, hmac_name,
-			       ERR_AUTH_ALG, ERR_AUTH_ALG_ND);
+		rv = alloc_hash(&crypto->cram_hmac_tfm, hmac_name,
+			       ERR_AUTH_ALG);
 	}
 	if (crypto->integrity_tfm) {
 		hash_size = crypto_hash_digestsize(crypto->integrity_tfm);
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 36b846b..30b6556 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3100,11 +3100,6 @@ struct crypto_hash *drbd_crypto_alloc_digest_safe(const struct drbd_conf *mdev,
 			alg, name, PTR_ERR(tfm));
 		return tfm;
 	}
-	if (!drbd_crypto_is_hash(crypto_hash_tfm(tfm))) {
-		crypto_free_hash(tfm);
-		dev_err(DEV, "\"%s\" is not a digest (%s)\n", alg, name);
-		return ERR_PTR(-EINVAL);
-	}
 	return tfm;
 }
 
diff --git a/drivers/block/drbd/drbd_wrappers.h b/drivers/block/drbd/drbd_wrappers.h
index decf9b2..46a6d99 100644
--- a/drivers/block/drbd/drbd_wrappers.h
+++ b/drivers/block/drbd/drbd_wrappers.h
@@ -45,12 +45,6 @@ static inline void drbd_generic_make_request(struct drbd_conf *mdev,
 		generic_make_request(bio);
 }
 
-static inline int drbd_crypto_is_hash(struct crypto_tfm *tfm)
-{
-        return (crypto_tfm_alg_type(tfm) & CRYPTO_ALG_TYPE_HASH_MASK)
-                == CRYPTO_ALG_TYPE_HASH;
-}
-
 #ifndef __CHECKER__
 # undef __cond_lock
 # define __cond_lock(x,c) (c)
-- 
1.7.4.1


  parent reply	other threads:[~2011-10-05  9:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-05  9:37 [RFC 00/16] drbd: part 14 of adding multiple volume support to drbd Philipp Reisner
2011-10-05  9:37 ` [PATCH 01/16] drbd: Consider all crypto options in connect and in net-options Philipp Reisner
2011-10-05  9:37 ` [PATCH 02/16] drbd: on reconfiguration requests, mind the SET_DEFAULTS flag Philipp Reisner
2011-10-05  9:37 ` [PATCH 03/16] drbd: rename variable ndc to new_disk_conf Philipp Reisner
2011-10-05  9:37 ` [PATCH 04/16] drbd: rename variable sc to res_opts Philipp Reisner
2011-10-05  9:37 ` [PATCH 05/16] drbd: fix copy/paste error in comment Philipp Reisner
2011-10-05  9:37 ` [PATCH 06/16] drbd: Wrong use of RCU in receive_protocol() Philipp Reisner
2011-10-05  9:37 ` [PATCH 07/16] drbd: Rename integrity_w_tfm -> integrity_tfm Philipp Reisner
2011-10-05  9:37 ` [PATCH 08/16] drbd: Rename integrity_r_tfm -> peer_integrity_tfm Philipp Reisner
2011-10-05  9:37 ` Philipp Reisner [this message]
2011-10-05  9:37 ` [PATCH 10/16] drbd: Introduce a "lockless" variant of drbd_send_protocoll() Philipp Reisner
2011-10-05  9:37 ` [PATCH 11/16] drbd: Allow to change data-integrity-alg on the fly Philipp Reisner
2011-10-05  9:38 ` [PATCH 12/16] drbd: fix race when forcefully disconnecting Philipp Reisner
2011-10-05  9:38 ` [PATCH 13/16] drbd: fix thread stop deadlock Philipp Reisner
2011-10-05  9:38 ` [PATCH 14/16] drbd: fix schedule in atomic Philipp Reisner
2011-10-05  9:38 ` [PATCH 15/16] drbd: Remove left-over unused define Philipp Reisner
2011-10-05  9:38 ` [PATCH 16/16] drbd: Generate the drbd_set_*_defaults() functions from drbd_genl.h Philipp Reisner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1317807484-24628-10-git-send-email-philipp.reisner@linbit.com \
    --to=philipp.reisner@linbit.com \
    --cc=axboe@kernel.dk \
    --cc=drbd-dev@lists.linbit.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®