Skip to content

Commit

Permalink
module: icp: remove unused CRYPTO_{NOTIFY_OPDONE,SKIP_REQID,RESTRICTED}
Browse files Browse the repository at this point in the history
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes openzfs#12901
  • Loading branch information
nabijaczleweli authored and andrewc12 committed Sep 23, 2022
1 parent 627b679 commit 62c8730
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 29 deletions.
8 changes: 0 additions & 8 deletions include/sys/crypto/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,7 @@ typedef void *crypto_bc_t;
typedef void *crypto_context_t;
typedef void *crypto_ctx_template_t;

typedef uint32_t crypto_call_flag_t;

/* crypto_call_flag's values */
#define CRYPTO_NOTIFY_OPDONE 0x00000002 /* Notify intermediate steps */
#define CRYPTO_SKIP_REQID 0x00000004 /* Skip request ID generation */
#define CRYPTO_RESTRICTED 0x00000008 /* cannot use restricted prov */

typedef struct {
crypto_call_flag_t cr_flag;
void (*cr_callback_func)(void *, int);
void *cr_callback_arg;
crypto_req_id_t cr_reqid;
Expand Down
4 changes: 2 additions & 2 deletions module/icp/api/kcf_cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ crypto_encrypt(crypto_mechanism_t *mech, crypto_data_t *plaintext,
retry:
/* pd is returned held */
if ((pd = kcf_get_mech_provider(mech->cm_type, &me, &error,
list, CRYPTO_FG_ENCRYPT_ATOMIC, CHECK_RESTRICT(crq))) == NULL) {
list, CRYPTO_FG_ENCRYPT_ATOMIC)) == NULL) {
if (list != NULL)
kcf_free_triedlist(list);
return (error);
Expand Down Expand Up @@ -161,7 +161,7 @@ crypto_decrypt(crypto_mechanism_t *mech, crypto_data_t *ciphertext,
retry:
/* pd is returned held */
if ((pd = kcf_get_mech_provider(mech->cm_type, &me, &error,
list, CRYPTO_FG_DECRYPT_ATOMIC, CHECK_RESTRICT(crq))) == NULL) {
list, CRYPTO_FG_DECRYPT_ATOMIC)) == NULL) {
if (list != NULL)
kcf_free_triedlist(list);
return (error);
Expand Down
4 changes: 2 additions & 2 deletions module/icp/api/kcf_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ crypto_mac(crypto_mechanism_t *mech, crypto_data_t *data,
retry:
/* The pd is returned held */
if ((pd = kcf_get_mech_provider(mech->cm_type, &me, &error,
list, CRYPTO_FG_MAC_ATOMIC, CHECK_RESTRICT(crq))) == NULL) {
list, CRYPTO_FG_MAC_ATOMIC)) == NULL) {
if (list != NULL)
kcf_free_triedlist(list);
return (error);
Expand Down Expand Up @@ -219,7 +219,7 @@ crypto_mac_init(crypto_mechanism_t *mech, crypto_key_t *key,
retry:
/* The pd is returned held */
if ((pd = kcf_get_mech_provider(mech->cm_type, &me, &error,
list, CRYPTO_FG_MAC, CHECK_RESTRICT(crq))) == NULL) {
list, CRYPTO_FG_MAC)) == NULL) {
if (list != NULL)
kcf_free_triedlist(list);
return (error);
Expand Down
8 changes: 2 additions & 6 deletions module/icp/core/kcf_callprov.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,10 @@ is_in_triedlist(kcf_provider_desc_t *pd, kcf_prov_tried_t *triedl)
* search to find one. This is fine as we assume there are only a few
* number of providers in this list. If this assumption ever changes,
* we should revisit this.
*
* call_restrict represents if the caller should not be allowed to
* use restricted providers.
*/
kcf_provider_desc_t *
kcf_get_mech_provider(crypto_mech_type_t mech_type, kcf_mech_entry_t **mepp,
int *error, kcf_prov_tried_t *triedl, crypto_func_group_t fg,
boolean_t call_restrict)
int *error, kcf_prov_tried_t *triedl, crypto_func_group_t fg)
{
kcf_provider_desc_t *pd = NULL;
kcf_prov_mech_desc_t *mdesc;
Expand Down Expand Up @@ -119,7 +115,7 @@ kcf_get_mech_provider(crypto_mech_type_t mech_type, kcf_mech_entry_t **mepp,
if (!IS_FG_SUPPORTED(mdesc, fg) ||
!KCF_IS_PROV_USABLE(pd) ||
IS_PROVIDER_TRIED(pd, triedl) ||
(call_restrict && (pd->pd_flags & KCF_PROV_RESTRICTED)))
(pd->pd_flags & KCF_PROV_RESTRICTED))
pd = NULL;
}

Expand Down
8 changes: 2 additions & 6 deletions module/icp/core/kcf_sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ kcf_resubmit_request(kcf_areq_node_t *areq)
return (error);

new_pd = kcf_get_mech_provider(mech1->cm_type, NULL, &error,
areq->an_tried_plist, fg,
(areq->an_reqarg.cr_flag & CRYPTO_RESTRICTED));
areq->an_tried_plist, fg);

if (new_pd == NULL)
return (error);
Expand Down Expand Up @@ -684,16 +683,13 @@ kcf_aop_done(kcf_areq_node_t *areq, int error)
* atomic operations.
*/
skip_notify = (IS_UPDATE_OP(optype) || IS_INIT_OP(optype)) &&
(!(areq->an_reqarg.cr_flag & CRYPTO_NOTIFY_OPDONE)) &&
(error == CRYPTO_SUCCESS);

if (!skip_notify) {
NOTIFY_CLIENT(areq, error);
}

if (!(areq->an_reqarg.cr_flag & CRYPTO_SKIP_REQID))
kcf_reqid_delete(areq);

kcf_reqid_delete(areq);
KCF_AREQ_REFRELE(areq);
}

Expand Down
6 changes: 1 addition & 5 deletions module/icp/include/sys/crypto/sched_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ typedef enum kcf_call_type {
CRYPTO_ASYNCH
} kcf_call_type_t;

#define CHECK_RESTRICT(crq) (crq != NULL && \
((crq)->cr_flag & CRYPTO_RESTRICTED))

#define KCF_KMFLAG(crq) (((crq) == NULL) ? KM_SLEEP : KM_NOSLEEP)

/*
Expand Down Expand Up @@ -445,8 +442,7 @@ extern void kcf_free_triedlist(kcf_prov_tried_t *);
extern kcf_prov_tried_t *kcf_insert_triedlist(kcf_prov_tried_t **,
kcf_provider_desc_t *, int);
extern kcf_provider_desc_t *kcf_get_mech_provider(crypto_mech_type_t,
kcf_mech_entry_t **, int *, kcf_prov_tried_t *, crypto_func_group_t,
boolean_t);
kcf_mech_entry_t **, int *, kcf_prov_tried_t *, crypto_func_group_t);
extern crypto_ctx_t *kcf_new_ctx(crypto_call_req_t *, kcf_provider_desc_t *,
crypto_session_id_t);
extern void kcf_sched_destroy(void);
Expand Down

0 comments on commit 62c8730

Please sign in to comment.