Whamcloud - gitweb
LU-14151 gss: use skcipher when sync_skcipher not available 68/40768/9
authorSebastien Buisson <sbuisson@ddn.com>
Thu, 26 Nov 2020 16:22:49 +0000 (11:22 -0500)
committerOleg Drokin <green@whamcloud.com>
Sun, 13 Dec 2020 08:23:42 +0000 (08:23 +0000)
Linux 4.2 introduced support for skcipher in commit
7a7ffe65c8c5 crypto: skcipher - Add top-level skcipher interface

Based on the existence of crypto_alloc_skcipher, use the skcipher API
instead of the blkcipher API, in case the sync_skcipher API is not
available.

Test-Parameters: clientdistro=el8.2 env=SHARED_KEY=true,SK_FLAVOR=skpi mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 testlist=sanity
Test-Parameters: clientdistro=el7.8 env=SHARED_KEY=true,SK_FLAVOR=skpi mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 testlist=sanity
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I4e62cd5c8219a215c5528f81d525c054215073e3
Reviewed-on: https://review.whamcloud.com/40768
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/ptlrpc/gss/gss_crypto.h

index 79c4d0b..286f717 100644 (file)
@@ -1143,6 +1143,24 @@ account_page_dirtied, [
 ]) # LC_ACCOUNT_PAGE_DIRTIED_3ARGS
 
 #
 ]) # LC_ACCOUNT_PAGE_DIRTIED_3ARGS
 
 #
+# LC_HAVE_CRYPTO_ALLOC_SKCIPHER
+#
+# Kernel version 4.12 commit 7a7ffe65c8c5
+# introduced crypto_alloc_skcipher().
+#
+AC_DEFUN([LC_HAVE_CRYPTO_ALLOC_SKCIPHER], [
+LB_CHECK_COMPILE([if crypto_alloc_skcipher is defined],
+crypto_alloc_skcipher, [
+       #include <crypto/skcipher.h>
+],[
+       crypto_alloc_skcipher(NULL, 0, 0);
+],[
+       AC_DEFINE(HAVE_CRYPTO_ALLOC_SKCIPHER, 1,
+               [crypto_alloc_skcipher is defined])
+])
+]) # LC_HAVE_CRYPTO_ALLOC_SKCIPHER
+
+#
 # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
 #
 # 4.3 replace interval with interval_exp in 'struct blk_integrity'
 # LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
 #
 # 4.3 replace interval with interval_exp in 'struct blk_integrity'
@@ -2365,6 +2383,7 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_BIO_ENDIO_USES_ONE_ARG
        LC_SYMLINK_OPS_USE_NAMEIDATA
        LC_ACCOUNT_PAGE_DIRTIED_3ARGS
        LC_BIO_ENDIO_USES_ONE_ARG
        LC_SYMLINK_OPS_USE_NAMEIDATA
        LC_ACCOUNT_PAGE_DIRTIED_3ARGS
+       LC_HAVE_CRYPTO_ALLOC_SKCIPHER
 
        # 4.3
        LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
 
        # 4.3
        LC_HAVE_INTERVAL_EXP_BLK_INTEGRITY
index 5dbc9f5..7653e21 100644 (file)
 
 #else /* ! SYNC_SKCIPHER_REQUEST_ON_STACK */
 
 
 #else /* ! SYNC_SKCIPHER_REQUEST_ON_STACK */
 
+#ifdef HAVE_CRYPTO_ALLOC_SKCIPHER
+
+#define crypto_sync_skcipher           crypto_skcipher
+
+#define SYNC_SKCIPHER_REQUEST_ON_STACK SKCIPHER_REQUEST_ON_STACK
+
+#define skcipher_request_set_sync_tfm  skcipher_request_set_tfm
+
+#define skcipher_request_set_crypt_iv(d)
+
+#define crypto_sync_skcipher_blocksize crypto_skcipher_blocksize
+
+#define crypto_sync_skcipher_setkey    crypto_skcipher_setkey
+
+#define crypto_alloc_sync_skcipher     crypto_alloc_skcipher
+
+#define crypto_free_sync_skcipher      crypto_free_skcipher
+
+#define crypto_sync_skcipher_ivsize    crypto_skcipher_ivsize
+
+#define crypto_skcipher_encrypt_iv(desc, dst, src, blocksize)  \
+       crypto_skcipher_encrypt((desc))
+
+#define crypto_skcipher_decrypt_iv(desc, dst, src, blocksize)  \
+       crypto_skcipher_decrypt((desc))
+
+#define skcipher_request_zero(req) /* nop */
+
+#else /* ! HAVE_CRYPTO_ALLOC_SKCIPHER */
+
 #define        crypto_sync_skcipher            crypto_blkcipher
 
 #define SYNC_SKCIPHER_REQUEST_ON_STACK(name, tfm)                      \
 #define        crypto_sync_skcipher            crypto_blkcipher
 
 #define SYNC_SKCIPHER_REQUEST_ON_STACK(name, tfm)                      \
@@ -66,6 +96,7 @@
 
 #define skcipher_request_zero(req) /* nop */
 
 
 #define skcipher_request_zero(req) /* nop */
 
+#endif /* HAVE_CRYPTO_ALLOC_SKCIPHER */
 #endif /* SYNC_SKCIPHER_REQUEST_ON_STACK */
 
 struct gss_keyblock {
 #endif /* SYNC_SKCIPHER_REQUEST_ON_STACK */
 
 struct gss_keyblock {