Print this page
Bayard's initial drop, needs finishing, or at least testing.
@@ -18,10 +18,11 @@
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stream.h>
@@ -2266,11 +2267,11 @@
struct spd_ext_actions *act;
struct spd_attribute *attr;
spdsock_t *ss = (spdsock_t *)q->q_ptr;
ipsec_stack_t *ipss = ss->spdsock_spds->spds_netstack->netstack_ipsec;
- mutex_enter(&ipss->ipsec_alg_lock);
+ rw_enter(&ipss->ipsec_alg_lock, RW_READER);
/*
* The SPD client expects to receive separate entries for
* AH authentication and ESP authentication supported algorithms.
*
* Don't return the "any" algorithms, if defined, as no
@@ -2294,11 +2295,11 @@
ASSERT(ALIGNED64(size));
m = allocb(size, BPRI_HI);
if (m == NULL) {
- mutex_exit(&ipss->ipsec_alg_lock);
+ rw_exit(&ipss->ipsec_alg_lock);
spdsock_error(q, mp, ENOMEM, 0);
return;
}
m->b_wptr = m->b_rptr + size;
@@ -2365,11 +2366,11 @@
EMITALGATTRS(SPDSOCK_ESP_ENCR);
}
}
}
- mutex_exit(&ipss->ipsec_alg_lock);
+ rw_exit(&ipss->ipsec_alg_lock);
#undef EMITALGATTRS
#undef EMIT
#undef ATTRPERALG
@@ -2402,11 +2403,11 @@
uint_t i;
uint_t alg_size;
spdsock_t *ss = (spdsock_t *)q->q_ptr;
ipsec_stack_t *ipss = ss->spdsock_spds->spds_netstack->netstack_ipsec;
- mutex_enter(&ipss->ipsec_alg_lock);
+ rw_enter(&ipss->ipsec_alg_lock, RW_READER);
/*
* For each algorithm, we encode:
* ALG / MINBITS / MAXBITS / DEFBITS / INCRBITS / {END, NEXT}
*
@@ -2435,11 +2436,11 @@
ASSERT(ALIGNED64(size));
m = allocb(size, BPRI_HI);
if (m == NULL) {
- mutex_exit(&ipss->ipsec_alg_lock);
+ rw_exit(&ipss->ipsec_alg_lock);
spdsock_error(q, mp, ENOMEM, 0);
return;
}
m->b_wptr = m->b_rptr + size;
@@ -2469,11 +2470,11 @@
* If there aren't any algorithms registered, return an empty message.
* spdsock_get_ext() knows how to deal with this.
*/
if (act->spd_actions_count == 0) {
act->spd_actions_len = 0;
- mutex_exit(&ipss->ipsec_alg_lock);
+ rw_exit(&ipss->ipsec_alg_lock);
goto error;
}
attr = (struct spd_attribute *)cur;
@@ -2521,11 +2522,11 @@
EMIT(SPD_ATTR_NEXT, 0);
}
}
- mutex_exit(&ipss->ipsec_alg_lock);
+ rw_exit(&ipss->ipsec_alg_lock);
#undef EMITALGATTRS
#undef EMIT
#undef ATTRPERALG
@@ -3682,11 +3683,11 @@
alg->alg_mech_type = mt;
alg->alg_flags |= algflags;
}
}
- mutex_enter(&ipss->ipsec_alg_lock);
+ rw_enter(&ipss->ipsec_alg_lock, RW_WRITER);
/*
* For each algorithm currently defined, check if it is
* present in the new tables created from the SPD_UPDATEALGS
* message received from user-space.
@@ -3738,11 +3739,11 @@
for (algtype = 0; algtype < IPSEC_NALGTYPES; algtype++) {
ipss->ipsec_algs_exec_mode[algtype] =
spds->spds_algs_exec_mode[algtype];
}
- mutex_exit(&ipss->ipsec_alg_lock);
+ rw_exit(&ipss->ipsec_alg_lock);
crypto_free_mech_list(mechs, mech_count);
ipsecah_algs_changed(ns);
ipsecesp_algs_changed(ns);