Skip to content

Commit 2ced260

Browse files
montjoieherbertx
authored andcommitted
crypto: user - made crypto_user_stat optional
Even if CRYPTO_STATS is set to n, some part of CRYPTO_STATS are compiled. This patch made all part of crypto_user_stat uncompiled in that case. Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent c97e4df commit 2ced260

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎crypto/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ cryptomgr-y := algboss.o testmgr.o
5454

5555
obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
5656
obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
57-
crypto_user-y := crypto_user_base.o crypto_user_stat.o
57+
crypto_user-y := crypto_user_base.o
58+
crypto_user-$(CONFIG_CRYPTO_STATS) += crypto_user_stat.o
5859
obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
5960
obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
6061
obj-$(CONFIG_CRYPTO_VMAC) += vmac.o

‎crypto/algapi.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,15 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
258258
list_add(&alg->cra_list, &crypto_alg_list);
259259
list_add(&larval->alg.cra_list, &crypto_alg_list);
260260

261+
#ifdef CONFIG_CRYPTO_STATS
261262
atomic_set(&alg->encrypt_cnt, 0);
262263
atomic_set(&alg->decrypt_cnt, 0);
263264
atomic64_set(&alg->encrypt_tlen, 0);
264265
atomic64_set(&alg->decrypt_tlen, 0);
265266
atomic_set(&alg->verify_cnt, 0);
266267
atomic_set(&alg->cipher_err_cnt, 0);
267268
atomic_set(&alg->sign_cnt, 0);
269+
#endif
268270

269271
out:
270272
return larval;

‎include/crypto/internal/cryptouser.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
33

44
struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact);
55

6+
#ifdef CONFIG_CRYPTO_STATS
67
int crypto_dump_reportstat(struct sk_buff *skb, struct netlink_callback *cb);
78
int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs);
89
int crypto_dump_reportstat_done(struct netlink_callback *cb);
10+
#else
11+
static int crypto_dump_reportstat(struct sk_buff *skb, struct netlink_callback *cb)
12+
{
13+
return -ENOTSUPP;
14+
}
15+
16+
static int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs)
17+
{
18+
return -ENOTSUPP;
19+
}
20+
21+
static int crypto_dump_reportstat_done(struct netlink_callback *cb)
22+
{
23+
return -ENOTSUPP;
24+
}
25+
#endif

‎include/linux/crypto.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ struct crypto_alg {
515515

516516
struct module *cra_module;
517517

518+
#ifdef CONFIG_CRYPTO_STATS
518519
union {
519520
atomic_t encrypt_cnt;
520521
atomic_t compress_cnt;
@@ -552,6 +553,7 @@ struct crypto_alg {
552553
atomic_t compute_shared_secret_cnt;
553554
};
554555
atomic_t sign_cnt;
556+
#endif /* CONFIG_CRYPTO_STATS */
555557

556558
} CRYPTO_MINALIGN_ATTR;
557559

0 commit comments

Comments
 (0)