aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/auth_gss
diff options
context:
space:
mode:
authorOlga Kornievskaia <aglo@citi.umich.edu>2006-12-04 20:22:33 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-06 10:46:44 -0500
commit37a4e6cb0391f2293ba3d59e3a63ec0e56ed720d (patch)
treec4c039bd801fedbaa9b8f9da67aeda3948fe9f38 /net/sunrpc/auth_gss
parent87d918d667e51962938392759aef6ca368d6e96d (diff)
rpc: move process_xdr_buf
Since process_xdr_buf() is useful outside of the kerberos-specific code, we move it to net/sunrpc/xdr.c, export it, and rename it in keeping with xdr_* naming convention of xdr.c. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/auth_gss')
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c73
1 files changed, 4 insertions, 69 deletions
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index 4c53896f1b08..10d05ea37213 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -43,6 +43,7 @@
43#include <linux/highmem.h> 43#include <linux/highmem.h>
44#include <linux/pagemap.h> 44#include <linux/pagemap.h>
45#include <linux/sunrpc/gss_krb5.h> 45#include <linux/sunrpc/gss_krb5.h>
46#include <linux/sunrpc/xdr.h>
46 47
47#ifdef RPC_DEBUG 48#ifdef RPC_DEBUG
48# define RPCDBG_FACILITY RPCDBG_AUTH 49# define RPCDBG_FACILITY RPCDBG_AUTH
@@ -120,72 +121,6 @@ out:
120EXPORT_SYMBOL(krb5_decrypt); 121EXPORT_SYMBOL(krb5_decrypt);
121 122
122static int 123static int
123process_xdr_buf(struct xdr_buf *buf, int offset, int len,
124 int (*actor)(struct scatterlist *, void *), void *data)
125{
126 int i, page_len, thislen, page_offset, ret = 0;
127 struct scatterlist sg[1];
128
129 if (offset >= buf->head[0].iov_len) {
130 offset -= buf->head[0].iov_len;
131 } else {
132 thislen = buf->head[0].iov_len - offset;
133 if (thislen > len)
134 thislen = len;
135 sg_set_buf(sg, buf->head[0].iov_base + offset, thislen);
136 ret = actor(sg, data);
137 if (ret)
138 goto out;
139 offset = 0;
140 len -= thislen;
141 }
142 if (len == 0)
143 goto out;
144
145 if (offset >= buf->page_len) {
146 offset -= buf->page_len;
147 } else {
148 page_len = buf->page_len - offset;
149 if (page_len > len)
150 page_len = len;
151 len -= page_len;
152 page_offset = (offset + buf->page_base) & (PAGE_CACHE_SIZE - 1);
153 i = (offset + buf->page_base) >> PAGE_CACHE_SHIFT;
154 thislen = PAGE_CACHE_SIZE - page_offset;
155 do {
156 if (thislen > page_len)
157 thislen = page_len;
158 sg->page = buf->pages[i];
159 sg->offset = page_offset;
160 sg->length = thislen;
161 ret = actor(sg, data);
162 if (ret)
163 goto out;
164 page_len -= thislen;
165 i++;
166 page_offset = 0;
167 thislen = PAGE_CACHE_SIZE;
168 } while (page_len != 0);
169 offset = 0;
170 }
171 if (len == 0)
172 goto out;
173
174 if (offset < buf->tail[0].iov_len) {
175 thislen = buf->tail[0].iov_len - offset;
176 if (thislen > len)
177 thislen = len;
178 sg_set_buf(sg, buf->tail[0].iov_base + offset, thislen);
179 ret = actor(sg, data);
180 len -= thislen;
181 }
182 if (len != 0)
183 ret = -EINVAL;
184out:
185 return ret;
186}
187
188static int
189checksummer(struct scatterlist *sg, void *data) 124checksummer(struct scatterlist *sg, void *data)
190{ 125{
191 struct hash_desc *desc = data; 126 struct hash_desc *desc = data;
@@ -225,7 +160,7 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
225 err = crypto_hash_update(&desc, sg, hdrlen); 160 err = crypto_hash_update(&desc, sg, hdrlen);
226 if (err) 161 if (err)
227 goto out; 162 goto out;
228 err = process_xdr_buf(body, body_offset, body->len - body_offset, 163 err = xdr_process_buf(body, body_offset, body->len - body_offset,
229 checksummer, &desc); 164 checksummer, &desc);
230 if (err) 165 if (err)
231 goto out; 166 goto out;
@@ -323,7 +258,7 @@ gss_encrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *buf,
323 desc.fragno = 0; 258 desc.fragno = 0;
324 desc.fraglen = 0; 259 desc.fraglen = 0;
325 260
326 ret = process_xdr_buf(buf, offset, buf->len - offset, encryptor, &desc); 261 ret = xdr_process_buf(buf, offset, buf->len - offset, encryptor, &desc);
327 return ret; 262 return ret;
328} 263}
329 264
@@ -389,7 +324,7 @@ gss_decrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *buf,
389 desc.desc.flags = 0; 324 desc.desc.flags = 0;
390 desc.fragno = 0; 325 desc.fragno = 0;
391 desc.fraglen = 0; 326 desc.fraglen = 0;
392 return process_xdr_buf(buf, offset, buf->len - offset, decryptor, &desc); 327 return xdr_process_buf(buf, offset, buf->len - offset, decryptor, &desc);
393} 328}
394 329
395EXPORT_SYMBOL(gss_decrypt_xdr_buf); 330EXPORT_SYMBOL(gss_decrypt_xdr_buf);