diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-08-26 04:12:40 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-09-20 21:46:22 -0400 |
commit | e4d5b79c661c7cfca9d8d5afd040a295f128d3cb (patch) | |
tree | 55a19ceca1b51b26d1934d388b26f0b1bed99a3e /net | |
parent | fce32d70ba834129b164c40c2d4260e5a7a7d850 (diff) |
[CRYPTO] users: Use crypto_comp and crypto_has_*
This patch converts all users to use the new crypto_comp type and the
crypto_has_* functions.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/ipcomp.c | 25 | ||||
-rw-r--r-- | net/ipv6/ipcomp6.c | 25 | ||||
-rw-r--r-- | net/xfrm/xfrm_algo.c | 27 |
3 files changed, 44 insertions, 33 deletions
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index a0c28b2b756e..5bb9c9f03fb6 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c | |||
@@ -32,7 +32,7 @@ | |||
32 | 32 | ||
33 | struct ipcomp_tfms { | 33 | struct ipcomp_tfms { |
34 | struct list_head list; | 34 | struct list_head list; |
35 | struct crypto_tfm **tfms; | 35 | struct crypto_comp **tfms; |
36 | int users; | 36 | int users; |
37 | }; | 37 | }; |
38 | 38 | ||
@@ -46,7 +46,7 @@ static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb) | |||
46 | int err, plen, dlen; | 46 | int err, plen, dlen; |
47 | struct ipcomp_data *ipcd = x->data; | 47 | struct ipcomp_data *ipcd = x->data; |
48 | u8 *start, *scratch; | 48 | u8 *start, *scratch; |
49 | struct crypto_tfm *tfm; | 49 | struct crypto_comp *tfm; |
50 | int cpu; | 50 | int cpu; |
51 | 51 | ||
52 | plen = skb->len; | 52 | plen = skb->len; |
@@ -107,7 +107,7 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb) | |||
107 | struct iphdr *iph = skb->nh.iph; | 107 | struct iphdr *iph = skb->nh.iph; |
108 | struct ipcomp_data *ipcd = x->data; | 108 | struct ipcomp_data *ipcd = x->data; |
109 | u8 *start, *scratch; | 109 | u8 *start, *scratch; |
110 | struct crypto_tfm *tfm; | 110 | struct crypto_comp *tfm; |
111 | int cpu; | 111 | int cpu; |
112 | 112 | ||
113 | ihlen = iph->ihl * 4; | 113 | ihlen = iph->ihl * 4; |
@@ -302,7 +302,7 @@ static void **ipcomp_alloc_scratches(void) | |||
302 | return scratches; | 302 | return scratches; |
303 | } | 303 | } |
304 | 304 | ||
305 | static void ipcomp_free_tfms(struct crypto_tfm **tfms) | 305 | static void ipcomp_free_tfms(struct crypto_comp **tfms) |
306 | { | 306 | { |
307 | struct ipcomp_tfms *pos; | 307 | struct ipcomp_tfms *pos; |
308 | int cpu; | 308 | int cpu; |
@@ -324,28 +324,28 @@ static void ipcomp_free_tfms(struct crypto_tfm **tfms) | |||
324 | return; | 324 | return; |
325 | 325 | ||
326 | for_each_possible_cpu(cpu) { | 326 | for_each_possible_cpu(cpu) { |
327 | struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu); | 327 | struct crypto_comp *tfm = *per_cpu_ptr(tfms, cpu); |
328 | crypto_free_tfm(tfm); | 328 | crypto_free_comp(tfm); |
329 | } | 329 | } |
330 | free_percpu(tfms); | 330 | free_percpu(tfms); |
331 | } | 331 | } |
332 | 332 | ||
333 | static struct crypto_tfm **ipcomp_alloc_tfms(const char *alg_name) | 333 | static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name) |
334 | { | 334 | { |
335 | struct ipcomp_tfms *pos; | 335 | struct ipcomp_tfms *pos; |
336 | struct crypto_tfm **tfms; | 336 | struct crypto_comp **tfms; |
337 | int cpu; | 337 | int cpu; |
338 | 338 | ||
339 | /* This can be any valid CPU ID so we don't need locking. */ | 339 | /* This can be any valid CPU ID so we don't need locking. */ |
340 | cpu = raw_smp_processor_id(); | 340 | cpu = raw_smp_processor_id(); |
341 | 341 | ||
342 | list_for_each_entry(pos, &ipcomp_tfms_list, list) { | 342 | list_for_each_entry(pos, &ipcomp_tfms_list, list) { |
343 | struct crypto_tfm *tfm; | 343 | struct crypto_comp *tfm; |
344 | 344 | ||
345 | tfms = pos->tfms; | 345 | tfms = pos->tfms; |
346 | tfm = *per_cpu_ptr(tfms, cpu); | 346 | tfm = *per_cpu_ptr(tfms, cpu); |
347 | 347 | ||
348 | if (!strcmp(crypto_tfm_alg_name(tfm), alg_name)) { | 348 | if (!strcmp(crypto_comp_name(tfm), alg_name)) { |
349 | pos->users++; | 349 | pos->users++; |
350 | return tfms; | 350 | return tfms; |
351 | } | 351 | } |
@@ -359,12 +359,13 @@ static struct crypto_tfm **ipcomp_alloc_tfms(const char *alg_name) | |||
359 | INIT_LIST_HEAD(&pos->list); | 359 | INIT_LIST_HEAD(&pos->list); |
360 | list_add(&pos->list, &ipcomp_tfms_list); | 360 | list_add(&pos->list, &ipcomp_tfms_list); |
361 | 361 | ||
362 | pos->tfms = tfms = alloc_percpu(struct crypto_tfm *); | 362 | pos->tfms = tfms = alloc_percpu(struct crypto_comp *); |
363 | if (!tfms) | 363 | if (!tfms) |
364 | goto error; | 364 | goto error; |
365 | 365 | ||
366 | for_each_possible_cpu(cpu) { | 366 | for_each_possible_cpu(cpu) { |
367 | struct crypto_tfm *tfm = crypto_alloc_tfm(alg_name, 0); | 367 | struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, |
368 | CRYPTO_ALG_ASYNC); | ||
368 | if (!tfm) | 369 | if (!tfm) |
369 | goto error; | 370 | goto error; |
370 | *per_cpu_ptr(tfms, cpu) = tfm; | 371 | *per_cpu_ptr(tfms, cpu) = tfm; |
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index 7e4d1c17bfbc..a81e9e9d93bd 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c | |||
@@ -53,7 +53,7 @@ | |||
53 | 53 | ||
54 | struct ipcomp6_tfms { | 54 | struct ipcomp6_tfms { |
55 | struct list_head list; | 55 | struct list_head list; |
56 | struct crypto_tfm **tfms; | 56 | struct crypto_comp **tfms; |
57 | int users; | 57 | int users; |
58 | }; | 58 | }; |
59 | 59 | ||
@@ -70,7 +70,7 @@ static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
70 | int plen, dlen; | 70 | int plen, dlen; |
71 | struct ipcomp_data *ipcd = x->data; | 71 | struct ipcomp_data *ipcd = x->data; |
72 | u8 *start, *scratch; | 72 | u8 *start, *scratch; |
73 | struct crypto_tfm *tfm; | 73 | struct crypto_comp *tfm; |
74 | int cpu; | 74 | int cpu; |
75 | 75 | ||
76 | if (skb_linearize_cow(skb)) | 76 | if (skb_linearize_cow(skb)) |
@@ -129,7 +129,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
129 | struct ipcomp_data *ipcd = x->data; | 129 | struct ipcomp_data *ipcd = x->data; |
130 | int plen, dlen; | 130 | int plen, dlen; |
131 | u8 *start, *scratch; | 131 | u8 *start, *scratch; |
132 | struct crypto_tfm *tfm; | 132 | struct crypto_comp *tfm; |
133 | int cpu; | 133 | int cpu; |
134 | 134 | ||
135 | hdr_len = skb->h.raw - skb->data; | 135 | hdr_len = skb->h.raw - skb->data; |
@@ -301,7 +301,7 @@ static void **ipcomp6_alloc_scratches(void) | |||
301 | return scratches; | 301 | return scratches; |
302 | } | 302 | } |
303 | 303 | ||
304 | static void ipcomp6_free_tfms(struct crypto_tfm **tfms) | 304 | static void ipcomp6_free_tfms(struct crypto_comp **tfms) |
305 | { | 305 | { |
306 | struct ipcomp6_tfms *pos; | 306 | struct ipcomp6_tfms *pos; |
307 | int cpu; | 307 | int cpu; |
@@ -323,28 +323,28 @@ static void ipcomp6_free_tfms(struct crypto_tfm **tfms) | |||
323 | return; | 323 | return; |
324 | 324 | ||
325 | for_each_possible_cpu(cpu) { | 325 | for_each_possible_cpu(cpu) { |
326 | struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu); | 326 | struct crypto_comp *tfm = *per_cpu_ptr(tfms, cpu); |
327 | crypto_free_tfm(tfm); | 327 | crypto_free_comp(tfm); |
328 | } | 328 | } |
329 | free_percpu(tfms); | 329 | free_percpu(tfms); |
330 | } | 330 | } |
331 | 331 | ||
332 | static struct crypto_tfm **ipcomp6_alloc_tfms(const char *alg_name) | 332 | static struct crypto_comp **ipcomp6_alloc_tfms(const char *alg_name) |
333 | { | 333 | { |
334 | struct ipcomp6_tfms *pos; | 334 | struct ipcomp6_tfms *pos; |
335 | struct crypto_tfm **tfms; | 335 | struct crypto_comp **tfms; |
336 | int cpu; | 336 | int cpu; |
337 | 337 | ||
338 | /* This can be any valid CPU ID so we don't need locking. */ | 338 | /* This can be any valid CPU ID so we don't need locking. */ |
339 | cpu = raw_smp_processor_id(); | 339 | cpu = raw_smp_processor_id(); |
340 | 340 | ||
341 | list_for_each_entry(pos, &ipcomp6_tfms_list, list) { | 341 | list_for_each_entry(pos, &ipcomp6_tfms_list, list) { |
342 | struct crypto_tfm *tfm; | 342 | struct crypto_comp *tfm; |
343 | 343 | ||
344 | tfms = pos->tfms; | 344 | tfms = pos->tfms; |
345 | tfm = *per_cpu_ptr(tfms, cpu); | 345 | tfm = *per_cpu_ptr(tfms, cpu); |
346 | 346 | ||
347 | if (!strcmp(crypto_tfm_alg_name(tfm), alg_name)) { | 347 | if (!strcmp(crypto_comp_name(tfm), alg_name)) { |
348 | pos->users++; | 348 | pos->users++; |
349 | return tfms; | 349 | return tfms; |
350 | } | 350 | } |
@@ -358,12 +358,13 @@ static struct crypto_tfm **ipcomp6_alloc_tfms(const char *alg_name) | |||
358 | INIT_LIST_HEAD(&pos->list); | 358 | INIT_LIST_HEAD(&pos->list); |
359 | list_add(&pos->list, &ipcomp6_tfms_list); | 359 | list_add(&pos->list, &ipcomp6_tfms_list); |
360 | 360 | ||
361 | pos->tfms = tfms = alloc_percpu(struct crypto_tfm *); | 361 | pos->tfms = tfms = alloc_percpu(struct crypto_comp *); |
362 | if (!tfms) | 362 | if (!tfms) |
363 | goto error; | 363 | goto error; |
364 | 364 | ||
365 | for_each_possible_cpu(cpu) { | 365 | for_each_possible_cpu(cpu) { |
366 | struct crypto_tfm *tfm = crypto_alloc_tfm(alg_name, 0); | 366 | struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0, |
367 | CRYPTO_ALG_ASYNC); | ||
367 | if (!tfm) | 368 | if (!tfm) |
368 | goto error; | 369 | goto error; |
369 | *per_cpu_ptr(tfms, cpu) = tfm; | 370 | *per_cpu_ptr(tfms, cpu) = tfm; |
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c index 87918f281bb4..5a0dbeb6bbe8 100644 --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c | |||
@@ -363,8 +363,8 @@ struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id) | |||
363 | EXPORT_SYMBOL_GPL(xfrm_calg_get_byid); | 363 | EXPORT_SYMBOL_GPL(xfrm_calg_get_byid); |
364 | 364 | ||
365 | static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list, | 365 | static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list, |
366 | int entries, char *name, | 366 | int entries, u32 type, u32 mask, |
367 | int probe) | 367 | char *name, int probe) |
368 | { | 368 | { |
369 | int i, status; | 369 | int i, status; |
370 | 370 | ||
@@ -382,7 +382,7 @@ static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list, | |||
382 | if (!probe) | 382 | if (!probe) |
383 | break; | 383 | break; |
384 | 384 | ||
385 | status = crypto_alg_available(name, 0); | 385 | status = crypto_has_alg(name, type, mask | CRYPTO_ALG_ASYNC); |
386 | if (!status) | 386 | if (!status) |
387 | break; | 387 | break; |
388 | 388 | ||
@@ -394,19 +394,25 @@ static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list, | |||
394 | 394 | ||
395 | struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe) | 395 | struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe) |
396 | { | 396 | { |
397 | return xfrm_get_byname(aalg_list, aalg_entries(), name, probe); | 397 | return xfrm_get_byname(aalg_list, aalg_entries(), |
398 | CRYPTO_ALG_TYPE_HASH, CRYPTO_ALG_TYPE_HASH_MASK, | ||
399 | name, probe); | ||
398 | } | 400 | } |
399 | EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname); | 401 | EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname); |
400 | 402 | ||
401 | struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe) | 403 | struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe) |
402 | { | 404 | { |
403 | return xfrm_get_byname(ealg_list, ealg_entries(), name, probe); | 405 | return xfrm_get_byname(ealg_list, ealg_entries(), |
406 | CRYPTO_ALG_TYPE_BLKCIPHER, CRYPTO_ALG_TYPE_MASK, | ||
407 | name, probe); | ||
404 | } | 408 | } |
405 | EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname); | 409 | EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname); |
406 | 410 | ||
407 | struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe) | 411 | struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe) |
408 | { | 412 | { |
409 | return xfrm_get_byname(calg_list, calg_entries(), name, probe); | 413 | return xfrm_get_byname(calg_list, calg_entries(), |
414 | CRYPTO_ALG_TYPE_COMPRESS, CRYPTO_ALG_TYPE_MASK, | ||
415 | name, probe); | ||
410 | } | 416 | } |
411 | EXPORT_SYMBOL_GPL(xfrm_calg_get_byname); | 417 | EXPORT_SYMBOL_GPL(xfrm_calg_get_byname); |
412 | 418 | ||
@@ -441,19 +447,22 @@ void xfrm_probe_algs(void) | |||
441 | BUG_ON(in_softirq()); | 447 | BUG_ON(in_softirq()); |
442 | 448 | ||
443 | for (i = 0; i < aalg_entries(); i++) { | 449 | for (i = 0; i < aalg_entries(); i++) { |
444 | status = crypto_alg_available(aalg_list[i].name, 0); | 450 | status = crypto_has_hash(aalg_list[i].name, 0, |
451 | CRYPTO_ALG_ASYNC); | ||
445 | if (aalg_list[i].available != status) | 452 | if (aalg_list[i].available != status) |
446 | aalg_list[i].available = status; | 453 | aalg_list[i].available = status; |
447 | } | 454 | } |
448 | 455 | ||
449 | for (i = 0; i < ealg_entries(); i++) { | 456 | for (i = 0; i < ealg_entries(); i++) { |
450 | status = crypto_alg_available(ealg_list[i].name, 0); | 457 | status = crypto_has_blkcipher(ealg_list[i].name, 0, |
458 | CRYPTO_ALG_ASYNC); | ||
451 | if (ealg_list[i].available != status) | 459 | if (ealg_list[i].available != status) |
452 | ealg_list[i].available = status; | 460 | ealg_list[i].available = status; |
453 | } | 461 | } |
454 | 462 | ||
455 | for (i = 0; i < calg_entries(); i++) { | 463 | for (i = 0; i < calg_entries(); i++) { |
456 | status = crypto_alg_available(calg_list[i].name, 0); | 464 | status = crypto_has_comp(calg_list[i].name, 0, |
465 | CRYPTO_ALG_ASYNC); | ||
457 | if (calg_list[i].available != status) | 466 | if (calg_list[i].available != status) |
458 | calg_list[i].available = status; | 467 | calg_list[i].available = status; |
459 | } | 468 | } |