Skip to content

Commit

Permalink
crypto: user - made crypto_user_stat optional
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
montjoie authored and herbertx committed Dec 7, 2018
1 parent c97e4df commit 2ced260
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ cryptomgr-y := algboss.o testmgr.o

obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
crypto_user-y := crypto_user_base.o crypto_user_stat.o
crypto_user-y := crypto_user_base.o
crypto_user-$(CONFIG_CRYPTO_STATS) += crypto_user_stat.o
obj-$(CONFIG_CRYPTO_CMAC) += cmac.o
obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
obj-$(CONFIG_CRYPTO_VMAC) += vmac.o
Expand Down
2 changes: 2 additions & 0 deletions crypto/algapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,15 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
list_add(&alg->cra_list, &crypto_alg_list);
list_add(&larval->alg.cra_list, &crypto_alg_list);

#ifdef CONFIG_CRYPTO_STATS
atomic_set(&alg->encrypt_cnt, 0);
atomic_set(&alg->decrypt_cnt, 0);
atomic64_set(&alg->encrypt_tlen, 0);
atomic64_set(&alg->decrypt_tlen, 0);
atomic_set(&alg->verify_cnt, 0);
atomic_set(&alg->cipher_err_cnt, 0);
atomic_set(&alg->sign_cnt, 0);
#endif

out:
return larval;
Expand Down
17 changes: 17 additions & 0 deletions include/crypto/internal/cryptouser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@

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

#ifdef CONFIG_CRYPTO_STATS
int crypto_dump_reportstat(struct sk_buff *skb, struct netlink_callback *cb);
int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs);
int crypto_dump_reportstat_done(struct netlink_callback *cb);
#else
static int crypto_dump_reportstat(struct sk_buff *skb, struct netlink_callback *cb)
{
return -ENOTSUPP;
}

static int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs)
{
return -ENOTSUPP;
}

static int crypto_dump_reportstat_done(struct netlink_callback *cb)
{
return -ENOTSUPP;
}
#endif
2 changes: 2 additions & 0 deletions include/linux/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ struct crypto_alg {

struct module *cra_module;

#ifdef CONFIG_CRYPTO_STATS
union {
atomic_t encrypt_cnt;
atomic_t compress_cnt;
Expand Down Expand Up @@ -552,6 +553,7 @@ struct crypto_alg {
atomic_t compute_shared_secret_cnt;
};
atomic_t sign_cnt;
#endif /* CONFIG_CRYPTO_STATS */

} CRYPTO_MINALIGN_ATTR;

Expand Down

0 comments on commit 2ced260

Please sign in to comment.