[ewg] [PATCH] RHEL5 backport crypto.h and scatterlist.h cleanup
Jon Mason
jon at opengridcomputing.com
Wed May 6 08:45:31 PDT 2009
Lustre is getting a struct redeinfition due to its declaration in the
Lustre header files as well as in the RHEL5 backports. Fortunately,
OFED can avoid defining the struct all together, as it already exists in
the base kernel's header files in ncrypto.h. By using the ncrypto.h
header file in the base kernel, it removes a significant amount of
duplicate functionality already existing in crypto.h and scatterlist.h
in the RHEL5.2 and RHEL5.3 backports. Also, this functionality
duplication can cause problems if both the OFED headers and ncrypto.h
are included in the same file.
This fixes Bugzilla Bug 1620.
Signed-Off-By: Jon Mason <jon at opengridcomputing.com>
---
diff --git a/kernel_addons/backport/2.6.18-EL5.2/include/linux/crypto.h b/kernel_addons/backport/2.6.18-EL5.2/include/linux/crypto.h
index d7d2551..7dbf768 100644
--- a/kernel_addons/backport/2.6.18-EL5.2/include/linux/crypto.h
+++ b/kernel_addons/backport/2.6.18-EL5.2/include/linux/crypto.h
@@ -2,116 +2,8 @@
#define BACKPORT_LINUX_CRYPTO_H
#include_next <linux/crypto.h>
+#include <linux/ncrypto.h>
-#define CRYPTO_ALG_ASYNC 0x00000080
-
-struct hash_desc
-{
- struct crypto_tfm *tfm;
- u32 flags;
-};
-
-struct crypto_blkcipher {
- struct crypto_tfm base;
-};
-
-struct blkcipher_desc {
- struct crypto_blkcipher *tfm;
- void *info;
- u32 flags;
-};
-
-static inline int crypto_hash_init(struct hash_desc *desc)
-{
- crypto_digest_init(desc->tfm);
- return 0;
-}
-
-static inline int crypto_hash_digest(struct hash_desc *desc,
- struct scatterlist *sg,
- unsigned int nbytes, u8 *out)
-{
- crypto_digest_digest(desc->tfm, sg, 1, out);
- return nbytes;
-}
-
-static inline int crypto_hash_update(struct hash_desc *desc,
- struct scatterlist *sg,
- unsigned int nbytes)
-{
- crypto_digest_update(desc->tfm, sg, 1);
- return nbytes;
-}
-
-static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
-{
- crypto_digest_final(desc->tfm, out);
- return 0;
-}
-
-static inline struct crypto_tfm *crypto_alloc_hash(const char *alg_name,
- u32 type, u32 mask)
-{
- struct crypto_tfm *ret = crypto_alloc_tfm(alg_name ,type);
- return ret ? ret : ERR_PTR(-ENOMEM);
-}
-
-static inline void crypto_free_hash(struct crypto_tfm *tfm)
-{
- crypto_free_tfm(tfm);
-}
-
-#define crypto_hash_digestsize(tfm) crypto_tfm_alg_digestsize(tfm)
-#define crypto_hash_setkey(a,b,c) crypto_digest_setkey(a,b,c)
-
-static inline struct crypto_tfm *crypto_blkcipher_tfm(
- struct crypto_blkcipher *tfm)
-{
- return &tfm->base;
-}
-
-static inline unsigned int crypto_blkcipher_blocksize(
- struct crypto_blkcipher *tfm)
-{
- return crypto_tfm_alg_blocksize(crypto_blkcipher_tfm(tfm));
-}
-
-static inline unsigned int crypto_blkcipher_ivsize(struct crypto_blkcipher *tfm)
-{
- return crypto_tfm_alg_ivsize(crypto_blkcipher_tfm(tfm));
-}
-
-static inline int crypto_blkcipher_encrypt_iv(struct blkcipher_desc *desc,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes)
-{
- return crypto_cipher_encrypt_iv(crypto_blkcipher_tfm(desc->tfm), dst, src, nbytes, (u8 *)desc->info);
-}
-
-static inline int crypto_blkcipher_decrypt_iv(struct blkcipher_desc *desc,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes)
-{
- return crypto_cipher_decrypt_iv(crypto_blkcipher_tfm(desc->tfm), dst, src, nbytes, (u8 *)desc->info);
-}
-
-static inline struct crypto_blkcipher *crypto_alloc_blkcipher(
- const char *alg_name, u32 type, u32 mask)
-{
- return (struct crypto_blkcipher *)crypto_alloc_tfm(alg_name, mask);
-}
-
-static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm)
-{
- crypto_free_tfm(crypto_blkcipher_tfm(tfm));
-}
-
-static inline int crypto_blkcipher_setkey(struct crypto_blkcipher *tfm,
- const u8 *key, unsigned int keylen)
-{
- return crypto_cipher_setkey(crypto_blkcipher_tfm(tfm), key, keylen);
-}
+#define CRYPTO_ALG_ASYNC NCRYPTO_ALG_ASYNC
#endif
diff --git a/kernel_addons/backport/2.6.18-EL5.2/include/linux/scatterlist.h b/kernel_addons/backport/2.6.18-EL5.2/include/linux/scatterlist.h
index 41e7805..c228575 100644
--- a/kernel_addons/backport/2.6.18-EL5.2/include/linux/scatterlist.h
+++ b/kernel_addons/backport/2.6.18-EL5.2/include/linux/scatterlist.h
@@ -1,27 +1,14 @@
#ifndef __BACKPORT_LINUX_SCATTERLIST_H_TO_2_6_23__
#define __BACKPORT_LINUX_SCATTERLIST_H_TO_2_6_23__
-#include_next<linux/scatterlist.h>
-static inline void sg_set_page(struct scatterlist *sg, struct page *page,
- unsigned int len, unsigned int offset)
-{
- sg->page = page;
- sg->offset = offset;
- sg->length = len;
-}
+#include_next<linux/scatterlist.h>
+#include <linux/ncrypto.h>
static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
{
sg->page = page;
}
-static inline void sg_mark_end(struct scatterlist *sg)
-{
-}
-
-#define sg_page(a) (a)->page
-#define sg_init_table(a, b)
-
#define for_each_sg(sglist, sg, nr, __i) \
for (__i = 0, sg = (sglist); __i < (nr); __i++, sg++)
diff --git a/kernel_addons/backport/2.6.18-EL5.3/include/linux/crypto.h b/kernel_addons/backport/2.6.18-EL5.3/include/linux/crypto.h
index d7d2551..7dbf768 100644
--- a/kernel_addons/backport/2.6.18-EL5.3/include/linux/crypto.h
+++ b/kernel_addons/backport/2.6.18-EL5.3/include/linux/crypto.h
@@ -2,116 +2,8 @@
#define BACKPORT_LINUX_CRYPTO_H
#include_next <linux/crypto.h>
+#include <linux/ncrypto.h>
-#define CRYPTO_ALG_ASYNC 0x00000080
-
-struct hash_desc
-{
- struct crypto_tfm *tfm;
- u32 flags;
-};
-
-struct crypto_blkcipher {
- struct crypto_tfm base;
-};
-
-struct blkcipher_desc {
- struct crypto_blkcipher *tfm;
- void *info;
- u32 flags;
-};
-
-static inline int crypto_hash_init(struct hash_desc *desc)
-{
- crypto_digest_init(desc->tfm);
- return 0;
-}
-
-static inline int crypto_hash_digest(struct hash_desc *desc,
- struct scatterlist *sg,
- unsigned int nbytes, u8 *out)
-{
- crypto_digest_digest(desc->tfm, sg, 1, out);
- return nbytes;
-}
-
-static inline int crypto_hash_update(struct hash_desc *desc,
- struct scatterlist *sg,
- unsigned int nbytes)
-{
- crypto_digest_update(desc->tfm, sg, 1);
- return nbytes;
-}
-
-static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
-{
- crypto_digest_final(desc->tfm, out);
- return 0;
-}
-
-static inline struct crypto_tfm *crypto_alloc_hash(const char *alg_name,
- u32 type, u32 mask)
-{
- struct crypto_tfm *ret = crypto_alloc_tfm(alg_name ,type);
- return ret ? ret : ERR_PTR(-ENOMEM);
-}
-
-static inline void crypto_free_hash(struct crypto_tfm *tfm)
-{
- crypto_free_tfm(tfm);
-}
-
-#define crypto_hash_digestsize(tfm) crypto_tfm_alg_digestsize(tfm)
-#define crypto_hash_setkey(a,b,c) crypto_digest_setkey(a,b,c)
-
-static inline struct crypto_tfm *crypto_blkcipher_tfm(
- struct crypto_blkcipher *tfm)
-{
- return &tfm->base;
-}
-
-static inline unsigned int crypto_blkcipher_blocksize(
- struct crypto_blkcipher *tfm)
-{
- return crypto_tfm_alg_blocksize(crypto_blkcipher_tfm(tfm));
-}
-
-static inline unsigned int crypto_blkcipher_ivsize(struct crypto_blkcipher *tfm)
-{
- return crypto_tfm_alg_ivsize(crypto_blkcipher_tfm(tfm));
-}
-
-static inline int crypto_blkcipher_encrypt_iv(struct blkcipher_desc *desc,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes)
-{
- return crypto_cipher_encrypt_iv(crypto_blkcipher_tfm(desc->tfm), dst, src, nbytes, (u8 *)desc->info);
-}
-
-static inline int crypto_blkcipher_decrypt_iv(struct blkcipher_desc *desc,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes)
-{
- return crypto_cipher_decrypt_iv(crypto_blkcipher_tfm(desc->tfm), dst, src, nbytes, (u8 *)desc->info);
-}
-
-static inline struct crypto_blkcipher *crypto_alloc_blkcipher(
- const char *alg_name, u32 type, u32 mask)
-{
- return (struct crypto_blkcipher *)crypto_alloc_tfm(alg_name, mask);
-}
-
-static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm)
-{
- crypto_free_tfm(crypto_blkcipher_tfm(tfm));
-}
-
-static inline int crypto_blkcipher_setkey(struct crypto_blkcipher *tfm,
- const u8 *key, unsigned int keylen)
-{
- return crypto_cipher_setkey(crypto_blkcipher_tfm(tfm), key, keylen);
-}
+#define CRYPTO_ALG_ASYNC NCRYPTO_ALG_ASYNC
#endif
diff --git a/kernel_addons/backport/2.6.18-EL5.3/include/linux/scatterlist.h b/kernel_addons/backport/2.6.18-EL5.3/include/linux/scatterlist.h
index 41e7805..c228575 100644
--- a/kernel_addons/backport/2.6.18-EL5.3/include/linux/scatterlist.h
+++ b/kernel_addons/backport/2.6.18-EL5.3/include/linux/scatterlist.h
@@ -1,27 +1,14 @@
#ifndef __BACKPORT_LINUX_SCATTERLIST_H_TO_2_6_23__
#define __BACKPORT_LINUX_SCATTERLIST_H_TO_2_6_23__
-#include_next<linux/scatterlist.h>
-static inline void sg_set_page(struct scatterlist *sg, struct page *page,
- unsigned int len, unsigned int offset)
-{
- sg->page = page;
- sg->offset = offset;
- sg->length = len;
-}
+#include_next<linux/scatterlist.h>
+#include <linux/ncrypto.h>
static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
{
sg->page = page;
}
-static inline void sg_mark_end(struct scatterlist *sg)
-{
-}
-
-#define sg_page(a) (a)->page
-#define sg_init_table(a, b)
-
#define for_each_sg(sglist, sg, nr, __i) \
for (__i = 0, sg = (sglist); __i < (nr); __i++, sg++)
More information about the ewg
mailing list