From 6996bc66e2d26fcd1153da40d6765b5b6f357dca Mon Sep 17 00:00:00 2001
From: ericm <ericm>
Date: Tue, 28 Aug 2007 16:46:40 +0000
Subject: [PATCH] branch: HEAD another missing part related to the gss_bulk.c

---
 lustre/include/lustre_sec.h  |  1 +
 lustre/ptlrpc/gss/gss_bulk.c | 19 ++++++++++++-------
 lustre/ptlrpc/sec_bulk.c     |  8 ++++++++
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/lustre/include/lustre_sec.h b/lustre/include/lustre_sec.h
index be0904e439..c677a78a77 100644
--- a/lustre/include/lustre_sec.h
+++ b/lustre/include/lustre_sec.h
@@ -405,6 +405,7 @@ struct ptlrpc_bulk_sec_desc {
 
 const char * sptlrpc_bulk_csum_alg2name(__u32 csum_alg);
 const char * sptlrpc_bulk_priv_alg2name(__u32 priv_alg);
+__u32 sptlrpc_bulk_priv_alg2flags(__u32 priv_alg);
 
 /*
  * lprocfs
diff --git a/lustre/ptlrpc/gss/gss_bulk.c b/lustre/ptlrpc/gss/gss_bulk.c
index c477ffae67..77aa4013e9 100644
--- a/lustre/ptlrpc/gss/gss_bulk.c
+++ b/lustre/ptlrpc/gss/gss_bulk.c
@@ -72,16 +72,18 @@ int do_bulk_privacy(struct gss_ctx *gctx,
         /* compute the secret iv */
         lgss_plain_encrypt(gctx, sizeof(local_iv), bsd->bsd_iv, local_iv);
 
-        tfm = crypto_alloc_tfm(priv_types[alg].name, priv_types[alg].flags);
+        tfm = crypto_alloc_tfm(sptlrpc_bulk_priv_alg2name(alg),
+                               sptlrpc_bulk_priv_alg2flags(alg));
         if (tfm == NULL) {
-                CERROR("Failed to allocate TFM %s\n", priv_types[alg].name);
+                CERROR("Failed to allocate TFM %s\n",
+                       sptlrpc_bulk_priv_alg2name(alg));
                 return -ENOMEM;
         }
 
         rc = crypto_cipher_setkey(tfm, local_iv, sizeof(local_iv));
         if (rc) {
                 CERROR("Failed to set key for TFM %s: %d\n",
-                       priv_types[alg].name, rc);
+                       sptlrpc_bulk_priv_alg2name(alg), rc);
                 crypto_free_tfm(tfm);
                 return rc;
         }
@@ -91,10 +93,10 @@ int do_bulk_privacy(struct gss_ctx *gctx,
                 sg.offset = desc->bd_iov[i].kiov_offset;
                 sg.length = desc->bd_iov[i].kiov_len;
 
-                if (desc->bd_enc_iov) {
-                        sg2.page = desc->bd_enc_iov[i].kiov_page;
-                        sg2.offset = desc->bd_enc_iov[i].kiov_offset;
-                        sg2.length = desc->bd_enc_iov[i].kiov_len;
+                if (desc->bd_enc_pages) {
+                        sg2.page = desc->bd_enc_pages[i];
+                        sg2.offset = desc->bd_iov[i].kiov_offset;
+                        sg2.length = desc->bd_iov[i].kiov_len;
 
                         sgd = &sg2;
                 } else
@@ -107,6 +109,9 @@ int do_bulk_privacy(struct gss_ctx *gctx,
 
                 LASSERT(rc == 0);
 
+                if (desc->bd_enc_pages)
+                        desc->bd_iov[i].kiov_page = desc->bd_enc_pages[i];
+
                 /* although the procedure might be lengthy, the crypto functions
                  * internally called cond_resched() from time to time.
                  */
diff --git a/lustre/ptlrpc/sec_bulk.c b/lustre/ptlrpc/sec_bulk.c
index b8de051f10..c13650a584 100644
--- a/lustre/ptlrpc/sec_bulk.c
+++ b/lustre/ptlrpc/sec_bulk.c
@@ -1010,3 +1010,11 @@ const char * sptlrpc_bulk_priv_alg2name(__u32 priv_alg)
         return "unknown_priv";
 }
 EXPORT_SYMBOL(sptlrpc_bulk_priv_alg2name);
+
+__u32 sptlrpc_bulk_priv_alg2flags(__u32 priv_alg)
+{
+        if (priv_alg < BULK_PRIV_ALG_MAX)
+                return priv_types[priv_alg].flags;
+        return 0;
+}
+EXPORT_SYMBOL(sptlrpc_bulk_priv_alg2flags);
-- 
GitLab