17 * information: Portions Copyright [yyyy] [name of copyright owner] |
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
21 /* |
21 /* |
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
22 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
23 * Use is subject to license terms. |
|
24 */ |
23 */ |
25 |
24 |
26 #include <sys/param.h> |
25 #include <sys/param.h> |
27 #include <sys/types.h> |
26 #include <sys/types.h> |
28 #include <sys/stream.h> |
27 #include <sys/stream.h> |
154 static int spdsock_open(queue_t *, dev_t *, int, int, cred_t *); |
153 static int spdsock_open(queue_t *, dev_t *, int, int, cred_t *); |
155 static void spdsock_wput(queue_t *, mblk_t *); |
154 static void spdsock_wput(queue_t *, mblk_t *); |
156 static void spdsock_wsrv(queue_t *); |
155 static void spdsock_wsrv(queue_t *); |
157 static void spdsock_rsrv(queue_t *); |
156 static void spdsock_rsrv(queue_t *); |
158 static void *spdsock_stack_init(netstackid_t stackid, netstack_t *ns); |
157 static void *spdsock_stack_init(netstackid_t stackid, netstack_t *ns); |
|
158 static void spdsock_stack_shutdown(netstackid_t stackid, void *arg); |
159 static void spdsock_stack_fini(netstackid_t stackid, void *arg); |
159 static void spdsock_stack_fini(netstackid_t stackid, void *arg); |
160 static void spdsock_loadcheck(void *); |
160 static void spdsock_loadcheck(void *); |
161 static void spdsock_merge_algs(spd_stack_t *); |
161 static void spdsock_merge_algs(spd_stack_t *); |
162 static void spdsock_flush_one(ipsec_policy_head_t *, netstack_t *); |
162 static void spdsock_flush_one(ipsec_policy_head_t *, netstack_t *); |
163 static mblk_t *spdsock_dump_next_record(spdsock_t *); |
163 static mblk_t *spdsock_dump_next_record(spdsock_t *); |
274 /* |
274 /* |
275 * We want to be informed each time a stack is created or |
275 * We want to be informed each time a stack is created or |
276 * destroyed in the kernel, so we can maintain the |
276 * destroyed in the kernel, so we can maintain the |
277 * set of spd_stack_t's. |
277 * set of spd_stack_t's. |
278 */ |
278 */ |
279 netstack_register(NS_SPDSOCK, spdsock_stack_init, NULL, |
279 netstack_register(NS_SPDSOCK, spdsock_stack_init, |
280 spdsock_stack_fini); |
280 spdsock_stack_shutdown, spdsock_stack_fini); |
281 |
281 |
282 return (B_TRUE); |
282 return (B_TRUE); |
283 } |
283 } |
284 |
284 |
285 /* |
285 /* |
338 vmem_destroy(spdsock_vmem); |
338 vmem_destroy(spdsock_vmem); |
339 |
339 |
340 netstack_unregister(NS_SPDSOCK); |
340 netstack_unregister(NS_SPDSOCK); |
341 } |
341 } |
342 |
342 |
|
343 /* |
|
344 * Do pre-removal cleanup. |
|
345 */ |
|
346 /* ARGSUSED */ |
|
347 static void |
|
348 spdsock_stack_shutdown(netstackid_t stackid, void *arg) |
|
349 { |
|
350 spd_stack_t *spds = (spd_stack_t *)arg; |
|
351 |
|
352 if (spds->spds_mp_algs != NULL) { |
|
353 freemsg(spds->spds_mp_algs); |
|
354 spds->spds_mp_algs = NULL; |
|
355 } |
|
356 } |
|
357 |
343 /* ARGSUSED */ |
358 /* ARGSUSED */ |
344 static void |
359 static void |
345 spdsock_stack_fini(netstackid_t stackid, void *arg) |
360 spdsock_stack_fini(netstackid_t stackid, void *arg) |
346 { |
361 { |
347 spd_stack_t *spds = (spd_stack_t *)arg; |
362 spd_stack_t *spds = (spd_stack_t *)arg; |
348 |
363 |
349 freemsg(spds->spds_mp_algs); |
364 ASSERT(spds->spds_mp_algs == NULL); |
350 mutex_destroy(&spds->spds_param_lock); |
365 mutex_destroy(&spds->spds_param_lock); |
351 mutex_destroy(&spds->spds_alg_lock); |
366 mutex_destroy(&spds->spds_alg_lock); |
352 nd_free(&spds->spds_g_nd); |
367 nd_free(&spds->spds_g_nd); |
353 kmem_free(spds->spds_params, sizeof (lcl_param_arr)); |
368 kmem_free(spds->spds_params, sizeof (lcl_param_arr)); |
354 spds->spds_params = NULL; |
369 spds->spds_params = NULL; |
2792 bcopy(extv, spds->spds_extv_algs, |
2807 bcopy(extv, spds->spds_extv_algs, |
2793 sizeof (spd_ext_t *) * (SPD_EXT_MAX + 1)); |
2808 sizeof (spd_ext_t *) * (SPD_EXT_MAX + 1)); |
2794 if (spds->spds_mp_algs != NULL) |
2809 if (spds->spds_mp_algs != NULL) |
2795 freemsg(spds->spds_mp_algs); |
2810 freemsg(spds->spds_mp_algs); |
2796 spds->spds_mp_algs = mp; |
2811 spds->spds_mp_algs = mp; |
2797 spds->spds_algs_pending = B_TRUE; |
|
2798 mutex_exit(&spds->spds_alg_lock); |
2812 mutex_exit(&spds->spds_alg_lock); |
2799 if (auditing) { |
2813 if (auditing) { |
2800 cred_t *cr; |
2814 cred_t *cr; |
2801 pid_t cpid; |
2815 pid_t cpid; |
2802 |
2816 |
3150 spdsock_update_pending_algs(netstack_t *ns) |
3164 spdsock_update_pending_algs(netstack_t *ns) |
3151 { |
3165 { |
3152 spd_stack_t *spds = ns->netstack_spdsock; |
3166 spd_stack_t *spds = ns->netstack_spdsock; |
3153 |
3167 |
3154 mutex_enter(&spds->spds_alg_lock); |
3168 mutex_enter(&spds->spds_alg_lock); |
3155 if (spds->spds_algs_pending) { |
3169 if (spds->spds_mp_algs != NULL) { |
3156 (void) spdsock_do_updatealg(spds->spds_extv_algs, spds); |
3170 (void) spdsock_do_updatealg(spds->spds_extv_algs, spds); |
3157 spds->spds_algs_pending = B_FALSE; |
3171 freemsg(spds->spds_mp_algs); |
|
3172 spds->spds_mp_algs = NULL; |
3158 } |
3173 } |
3159 mutex_exit(&spds->spds_alg_lock); |
3174 mutex_exit(&spds->spds_alg_lock); |
3160 } |
3175 } |
3161 |
3176 |
3162 static void |
3177 static void |